From 6604302955fb1841457d518f1f1fb64295c41737 Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 20 Apr 2007 12:11:12 +0000 Subject: [PATCH] Coding conventions --- HLT/BASE/AliHLTComponent.cxx | 20 ++++-- HLT/BASE/AliHLTComponent.h | 8 +-- HLT/BASE/AliHLTDataBuffer.cxx | 5 +- HLT/BASE/AliHLTDataBuffer.h | 17 +++-- HLT/BASE/AliHLTLogging.cxx | 94 ++++++++++++-------------- HLT/BASE/AliHLTLogging.h | 35 +++++++--- HLT/SampleLib/AliHLTDummyComponent.cxx | 1 + 7 files changed, 103 insertions(+), 77 deletions(-) diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index fe4ce04d436..aa7632d02f5 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -25,7 +25,7 @@ using namespace std; #endif -#include "AliHLTStdIncludes.h" +//#include "AliHLTStdIncludes.h" #include "AliHLTComponent.h" #include "AliHLTComponentHandler.h" #include "AliHLTMessage.h" @@ -200,12 +200,14 @@ int AliHLTComponent::DoInit( int argc, const char** argv ) if (argc==0 && argv==NULL) { // this is currently just to get rid of the warning "unused parameter" } + fEventCount=0; return 0; } int AliHLTComponent::DoDeinit() { // see header file for function documentation + fEventCount=0; return 0; } @@ -322,6 +324,7 @@ int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vectorGetName()); + TClass* objclass=msg.GetClass(); + pObj=msg.ReadObject(objclass); + if (pObj && objclass) { + HLTDebug("object %p type %s created", pObj, objclass->GetName()); } else { } } else { @@ -557,6 +561,7 @@ TObject* AliHLTComponent::GetInputObject(int idx, const char* classname, int bFo int AliHLTComponent::CleanupInputObjects() { + // see header file for function documentation if (!fpInputObjects) return 0; TObjArray* array=fpInputObjects; fpInputObjects=NULL; @@ -650,7 +655,7 @@ const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock() return pBlock; } -int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) +int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const { // see header file for function documentation int iResult=-ENOENT; @@ -773,6 +778,7 @@ int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iSize, const AliHLTCom int AliHLTComponent::EstimateObjectSize(TObject* pObject) const { + // see header file for function documentation if (!pObject) return -EINVAL; AliHLTMessage msg(kMESS_OBJECT); msg.WriteObject(pObject); diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index 703267e64ec..c18ff34db5a 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -22,7 +22,7 @@ #include #include "AliHLTLogging.h" #include "AliHLTDataTypes.h" -#include "AliHLTDefinitions.h" +//#include "AliHLTDefinitions.h" /* Matthias Dec 2006 * The names have been changed for Aliroot's coding conventions sake @@ -550,7 +550,7 @@ class AliHLTComponent : public AliHLTLogging { * Get the number of input blocks. * @return number of input blocks */ - int GetNumberOfInputBlocks(); + int GetNumberOfInputBlocks() const; /** * Get the first object of a specific data type from the input data. @@ -754,7 +754,7 @@ class AliHLTComponent : public AliHLTLogging { * * @internal */ - int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1); + int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1) const; /** * Get index in the array of input bocks. @@ -764,7 +764,7 @@ class AliHLTComponent : public AliHLTLogging { * * @internal */ - int FindInputBlock(const AliHLTComponentBlockData* pBlock); + int FindInputBlock(const AliHLTComponentBlockData* pBlock) const; /** * Create an object from a specified input block. diff --git a/HLT/BASE/AliHLTDataBuffer.cxx b/HLT/BASE/AliHLTDataBuffer.cxx index 8044ad34e96..d0ecff5b641 100644 --- a/HLT/BASE/AliHLTDataBuffer.cxx +++ b/HLT/BASE/AliHLTDataBuffer.cxx @@ -28,8 +28,9 @@ using namespace std; #include "AliHLTDataBuffer.h" #include "AliHLTConsumerDescriptor.h" #include "AliHLTComponent.h" -#include -#include "AliHLTSystem.h" +#include +//#include +//#include "AliHLTSystem.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTDataBuffer) diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index 5bba4074dbd..c78d8d6502e 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -12,11 +12,10 @@ @note The class is used in Offline (AliRoot) context */ -#include #include #include "AliHLTLogging.h" #include "AliHLTDataTypes.h" -#include "AliHLTDefinitions.h" +//#include "AliHLTDefinitions.h" #include "TObject.h" //#include "TList.h" @@ -193,7 +192,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @struct AliHLTDataSegment * @brief Descriptor of a data segment within the buffer. */ - struct AliHLTDataSegment { + class AliHLTDataSegment { + public: AliHLTDataSegment() : fDataType(), @@ -226,7 +226,16 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @struct AliHLTRawBuffer * @brief Descriptor of the raw data buffer which can host several segments. */ - struct AliHLTRawBuffer { + class AliHLTRawBuffer { + public: + /** standard constructor */ + AliHLTRawBuffer() : fSize(0), fTotalSize(0), fPtr(NULL) {} + /** not a valid copy constructor, defined according to effective C++ style */ + AliHLTRawBuffer(const AliHLTRawBuffer&) : fSize(0), fTotalSize(0), fPtr(NULL) {} + /** not a valid assignment op, but defined according to effective C++ style */ + AliHLTRawBuffer& operator=(const AliHLTRawBuffer&) {return *this;} + /** standard destructor */ + virtual ~AliHLTRawBuffer() {} /** size of the currently occupied partition of the buffer */ AliHLTUInt32_t fSize; // see above /** total size of the buffer, including safety margin */ diff --git a/HLT/BASE/AliHLTLogging.cxx b/HLT/BASE/AliHLTLogging.cxx index 24e75671dea..6c8a17060a0 100644 --- a/HLT/BASE/AliHLTLogging.cxx +++ b/HLT/BASE/AliHLTLogging.cxx @@ -32,15 +32,11 @@ using namespace std; #include "AliHLTStdIncludes.h" #include "AliHLTLogging.h" #include "TString.h" -#include "TArrayC.h" #include "Varargs.h" #include #include #include -/** target stream for AliRoot logging methods */ -ostringstream gLogstr; - #ifndef NOALIROOT_LOGGING /** * Notification callback for AliRoot logging methods @@ -49,23 +45,13 @@ void LogNotification(AliLog::EType_t level, const char* message) { AliHLTLogging hltlog; hltlog.SwitchAliLog(0); - hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", gLogstr.str().c_str()); - gLogstr.clear(); + hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", AliHLTLogging::fgLogstr.str().c_str()); + AliHLTLogging::fgLogstr.clear(); string empty(""); - gLogstr.str(empty); + AliHLTLogging::fgLogstr.str(empty); } #endif -/** - * The global logging buffer. - * The buffer is created with an initial size and grown dynamically on - * demand. - */ -TArrayC gAliHLTLoggingTarget(200); - -/** the maximum size of the buffer */ -const int gALIHLTLOGGING_MAXBUFFERSIZE=10000; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTLogging) @@ -100,8 +86,9 @@ AliHLTLogging& AliHLTLogging::operator=(const AliHLTLogging&) return *this; } -AliHLTComponentLogSeverity AliHLTLogging::fGlobalLogFilter=kHLTLogAll; -AliHLTfctLogging AliHLTLogging::fLoggingFunc=NULL; +ostringstream AliHLTLogging::fgLogstr; +AliHLTComponentLogSeverity AliHLTLogging::fgGlobalLogFilter=kHLTLogAll; +AliHLTfctLogging AliHLTLogging::fgLoggingFunc=NULL; int AliHLTLogging::fgUseAliLog=1; AliHLTLogging::~AliHLTLogging() @@ -109,20 +96,23 @@ AliHLTLogging::~AliHLTLogging() // see header file for class documentation } +TArrayC AliHLTLogging::fgAliHLTLoggingTarget(200); +const int AliHLTLogging::fgkALIHLTLOGGINGMAXBUFFERSIZE=10000; + int AliHLTLogging::Init(AliHLTfctLogging pFun) { // see header file for class documentation - if (fLoggingFunc!=NULL && fLoggingFunc!=pFun) { - (*fLoggingFunc)(NULL/*fParam*/, kHLTLogWarning, "AliHLTLogging::Init", "no key", "overriding previously initialized logging function"); + if (fgLoggingFunc!=NULL && fgLoggingFunc!=pFun) { + (*fgLoggingFunc)(NULL/*fParam*/, kHLTLogWarning, "AliHLTLogging::Init", "no key", "overriding previously initialized logging function"); } - fLoggingFunc=pFun; + fgLoggingFunc=pFun; // older versions of AliLog does not support the notification callback and // stringstreams, but they support the logging macros in general #ifndef NOALIROOT_LOGGING #ifndef NO_ALILOG_NOTIFICATION AliLog* log=new AliLog; log->SetLogNotification(LogNotification); - log->SetStreamOutput(&gLogstr); + log->SetStreamOutput(&fgLogstr); #endif // NO_ALILOG_NOTIFICATION #endif // NOALIROOT_LOGGING @@ -175,29 +165,29 @@ int AliHLTLogging::Message(void *param, AliHLTComponentLogSeverity severity, #ifndef NOALIROOT_LOGGING int AliHLTLogging::AliMessage(AliHLTComponentLogSeverity severity, - const char* origin_class, const char* origin_func, + const char* originClass, const char* originFunc, const char* file, int line, const char* message) { // see header file for class documentation switch (severity) { case kHLTLogBenchmark: - AliLog::Message(AliLog::kInfo, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line); break; case kHLTLogDebug: - AliLog::Message(AliLog::kDebug, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kDebug, message, "HLT", originClass, originFunc, file, line); break; case kHLTLogInfo: - AliLog::Message(AliLog::kInfo, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line); break; case kHLTLogWarning: - AliLog::Message(AliLog::kWarning, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line); break; case kHLTLogError: - AliLog::Message(AliLog::kError, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kError, message, "HLT", originClass, originFunc, file, line); break; case kHLTLogFatal: - AliLog::Message(AliLog::kWarning, message, "HLT", origin_class, origin_func, file, line); + AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line); break; default: break; @@ -221,32 +211,32 @@ const char* AliHLTLogging::BuildLogString(const char *format, va_list ap) const char* fmt = format; if (fmt==NULL) fmt=va_arg(ap, const char*); - gAliHLTLoggingTarget[0]=0; + fgAliHLTLoggingTarget[0]=0; while (fmt!=NULL) { - iResult=vsnprintf(gAliHLTLoggingTarget.GetArray(), gAliHLTLoggingTarget.GetSize(), fmt, ap); + iResult=vsnprintf(fgAliHLTLoggingTarget.GetArray(), fgAliHLTLoggingTarget.GetSize(), fmt, ap); if (iResult==-1) // for compatibility with older version of vsnprintf - iResult=gAliHLTLoggingTarget.GetSize()*2; - else if (iResult=gALIHLTLOGGING_MAXBUFFERSIZE) + if (fgAliHLTLoggingTarget.GetSize()>=fgkALIHLTLOGGINGMAXBUFFERSIZE) { - gAliHLTLoggingTarget[gAliHLTLoggingTarget.GetSize()-1]=0; + fgAliHLTLoggingTarget[fgAliHLTLoggingTarget.GetSize()-1]=0; break; } // check limitation and grow the buffer - if (iResult>gALIHLTLOGGING_MAXBUFFERSIZE) iResult=gALIHLTLOGGING_MAXBUFFERSIZE; - gAliHLTLoggingTarget.Set(iResult+1); + if (iResult>fgkALIHLTLOGGINGMAXBUFFERSIZE) iResult=fgkALIHLTLOGGINGMAXBUFFERSIZE; + fgAliHLTLoggingTarget.Set(iResult+1); // copy the original list and skip the first argument if this was the format string #ifdef R__VA_COPY va_end(ap); R__VA_COPY(ap, bap); #else - gAliHLTLoggingTarget[gAliHLTLoggingTarget.GetSize()-1]=0; + fgAliHLTLoggingTarget[fgAliHLTLoggingTarget.GetSize()-1]=0; break; #endif //R__VA_COPY if (format==NULL) va_arg(ap, const char*); @@ -255,7 +245,7 @@ const char* AliHLTLogging::BuildLogString(const char *format, va_list ap) va_end(bap); #endif //R__VA_COPY - return gAliHLTLoggingTarget.GetArray(); + return fgAliHLTLoggingTarget.GetArray(); } int AliHLTLogging::Logging(AliHLTComponentLogSeverity severity, @@ -267,8 +257,8 @@ int AliHLTLogging::Logging(AliHLTComponentLogSeverity severity, if (iResult>0) { va_list args; va_start(args, format); - if (fLoggingFunc) { - iResult = (*fLoggingFunc)(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args )); + if (fgLoggingFunc) { + iResult = (*fgLoggingFunc)(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args )); } else { #ifndef NOALIROOT_LOGGING if (fgUseAliLog) @@ -283,7 +273,7 @@ int AliHLTLogging::Logging(AliHLTComponentLogSeverity severity, } int AliHLTLogging::LoggingVarargs(AliHLTComponentLogSeverity severity, - const char* origin_class, const char* origin_func, + const char* originClass, const char* originFunc, const char* file, int line, ... ) const { // see header file for class documentation @@ -295,23 +285,23 @@ int AliHLTLogging::LoggingVarargs(AliHLTComponentLogSeverity severity, if (iResult>0) { const char* separator=""; TString origin; - if (origin_class) { - origin+=origin_class; + if (originClass) { + origin+=originClass; separator="::"; } - if (origin_func) { + if (originFunc) { origin+=separator; - origin+=origin_func; + origin+=originFunc; } va_list args; va_start(args, line); - if (fLoggingFunc) { - iResult=(*fLoggingFunc)(NULL/*fParam*/, severity, origin.Data(), GetKeyword(), AliHLTLogging::BuildLogString(NULL, args )); + if (fgLoggingFunc) { + iResult=(*fgLoggingFunc)(NULL/*fParam*/, severity, origin.Data(), GetKeyword(), AliHLTLogging::BuildLogString(NULL, args )); } else { #ifndef NOALIROOT_LOGGING if (fgUseAliLog) - iResult=AliMessage(severity, origin_class, origin_func, file, line, AliHLTLogging::BuildLogString(NULL, args )); + iResult=AliMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args )); else #endif iResult=Message(NULL/*fParam*/, severity, origin.Data(), GetKeyword(), AliHLTLogging::BuildLogString(NULL, args )); @@ -325,7 +315,7 @@ int AliHLTLogging::CheckFilter(AliHLTComponentLogSeverity severity) const { // see header file for class documentation - int iResult=severity==kHLTLogNone || (severity&fGlobalLogFilter)>0 && (severity&fLocalLogFilter)>0; + int iResult=severity==kHLTLogNone || (severity&fgGlobalLogFilter)>0 && (severity&fLocalLogFilter)>0; return iResult; } @@ -333,7 +323,7 @@ void AliHLTLogging::SetGlobalLoggingLevel(AliHLTComponentLogSeverity level) { // see header file for class documentation - fGlobalLogFilter=level; + fgGlobalLogFilter=level; } void AliHLTLogging::SetLocalLoggingLevel(AliHLTComponentLogSeverity level) diff --git a/HLT/BASE/AliHLTLogging.h b/HLT/BASE/AliHLTLogging.h index 10552190490..e266319a381 100644 --- a/HLT/BASE/AliHLTLogging.h +++ b/HLT/BASE/AliHLTLogging.h @@ -14,6 +14,7 @@ #include "AliHLTDataTypes.h" #include "AliHLTStdIncludes.h" #include "TObject.h" +#include "TArrayC.h" //#define LOG_PREFIX "" // logging prefix, for later extensions @@ -83,7 +84,7 @@ public: // logging function with two origin parameters, used by the log macros // int LoggingVarargs(AliHLTComponentLogSeverity severity, - const char* origin_class, const char* origin_func, + const char* originClass, const char* originFunc, const char* file, int line, ... ) const; // apply filter, return 1 if message should pass @@ -110,7 +111,7 @@ public: * Print message through AliRoot log channels. */ static int AliMessage(AliHLTComponentLogSeverity severity, - const char* origin_class, const char* origin_func, + const char* originClass, const char* originFunc, const char* file, int line, const char* message); #endif @@ -122,7 +123,13 @@ public: */ static const char* BuildLogString(const char *format, va_list ap); - virtual void* GetParameter() {return NULL;} + /** + * Get parameter given by the external caller. + * This functionality is not yet implemented. It is intended + * to pass the parameter pointer given to the component at + * initialization back to the caller. + */ + virtual void* GetParameter() const {return NULL;} /** * Switch logging through AliLog on or off @@ -130,23 +137,35 @@ public: */ void SwitchAliLog(int sw) {fgUseAliLog=(sw!=0);} + /** target stream for AliRoot logging methods */ + static ostringstream fgLogstr; //! transient + protected: private: /** the global logging filter */ - static AliHLTComponentLogSeverity fGlobalLogFilter; // see above + static AliHLTComponentLogSeverity fgGlobalLogFilter; // see above /** the local logging filter for one class */ AliHLTComponentLogSeverity fLocalLogFilter; // see above /** logging callback from the framework */ - static AliHLTfctLogging fLoggingFunc; // see above + static AliHLTfctLogging fgLoggingFunc; // see above /** default keyword */ const char* fpDefaultKeyword; //! transient /** current keyword */ const char* fpCurrentKeyword; //! transient /** switch for logging through AliLog, default on */ static int fgUseAliLog; // see above + /** + * The global logging buffer. + * The buffer is created with an initial size and grown dynamically on + * demand. + */ + static TArrayC fgAliHLTLoggingTarget; //! transient + + /** the maximum size of the buffer */ + static const int fgkALIHLTLOGGINGMAXBUFFERSIZE; //! transient - ClassDef(AliHLTLogging, 1) + ClassDef(AliHLTLogging, 2) }; /* the class AliHLTKeyword is a simple helper class used by the HLTLogKeyword macro @@ -195,8 +214,8 @@ class AliHLTKeyword { } private: - AliHLTLogging* fpParent; - const char* fpOriginal; + AliHLTLogging* fpParent; //! transient + const char* fpOriginal; //! transient }; #endif diff --git a/HLT/SampleLib/AliHLTDummyComponent.cxx b/HLT/SampleLib/AliHLTDummyComponent.cxx index 009237f6eda..f26f1e90f8f 100644 --- a/HLT/SampleLib/AliHLTDummyComponent.cxx +++ b/HLT/SampleLib/AliHLTDummyComponent.cxx @@ -27,6 +27,7 @@ using namespace std; #include "AliHLTSystem.h" #include "AliHLTDummyComponent.h" +#include "AliHLTDefinitions.h" #include #include -- 2.39.3