]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Coding conventions
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Apr 2007 12:11:12 +0000 (12:11 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Apr 2007 12:11:12 +0000 (12:11 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h
HLT/BASE/AliHLTDataBuffer.cxx
HLT/BASE/AliHLTDataBuffer.h
HLT/BASE/AliHLTLogging.cxx
HLT/BASE/AliHLTLogging.h
HLT/SampleLib/AliHLTDummyComponent.cxx

index fe4ce04d436adc0c8b972c3bb3f4bfea6879de94..aa7632d02f53597573d8e072acda32418ed62ebf 100644 (file)
@@ -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, vector<Al
 
 void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const
 {
+  // see header file for function documentation
   const char* fmt="publisher \'%s\'";
   if (format) fmt=format;
   HLTMessage(fmt, (DataType2Text(dt)).c_str());
@@ -429,7 +432,7 @@ int AliHLTComponent::IncrementEventCounter()
   return fEventCount;
 }
 
-int AliHLTComponent::GetNumberOfInputBlocks()
+int AliHLTComponent::GetNumberOfInputBlocks() const
 {
   // see header file for function documentation
   if (fpInputBlocks!=NULL) {
@@ -486,7 +489,7 @@ const TObject* AliHLTComponent::GetNextInputObject(int bForce)
   return pObj;
 }
 
-int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx)
+int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx) const
 {
   // see header file for function documentation
   int iResult=-ENOENT;
@@ -512,9 +515,10 @@ TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
        if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
          HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
          AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
-         pObj=msg.ReadObject(msg.GetClass());
-         if (pObj && msg.GetClass()) {
-           HLTDebug("object %p type %s created", pObj, msg.GetClass()->GetName());
+         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);
index 703267e64ec764d954cfc64f2fb5e108365fd963..c18ff34db5a38b74e3fe88b3f9a8f8e59606badc 100644 (file)
@@ -22,7 +22,7 @@
 #include <string>
 #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.
index 8044ad34e96bca33de7b6356d495be286eb089b9..d0ecff5b6410089fbec56c9bccf836cfeb9264f6 100644 (file)
@@ -28,8 +28,9 @@ using namespace std;
 #include "AliHLTDataBuffer.h"
 #include "AliHLTConsumerDescriptor.h"
 #include "AliHLTComponent.h"
-#include <string>
-#include "AliHLTSystem.h"
+#include <cerrno>
+//#include <string>
+//#include "AliHLTSystem.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTDataBuffer)
index 5bba4074dbd8e5ed5ef410fe7ac18d1f3fa10729..c78d8d6502e1171e21a48cafe5f909a4293574c5 100644 (file)
     @note   The class is used in Offline (AliRoot) context
 */
 
-#include <cerrno>
 #include <vector>
 #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 */
index 24e75671deaaa4148c1e5f1897f576f7ff1211d1..6c8a17060a0d843e8d496ee3ddf1b43b847547a8 100644 (file)
@@ -32,15 +32,11 @@ using namespace std;
 #include "AliHLTStdIncludes.h"
 #include "AliHLTLogging.h"
 #include "TString.h"
-#include "TArrayC.h"
 #include "Varargs.h"
 #include <string>
 #include <sstream>
 #include <iostream>
 
-/** 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<gAliHLTLoggingTarget.GetSize())
+      iResult=fgAliHLTLoggingTarget.GetSize()*2;
+    else if (iResult<fgAliHLTLoggingTarget.GetSize())
       break;
 
     // terminate if buffer is already at the limit
-    if (gAliHLTLoggingTarget.GetSize()>=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)
index 105521904905c07b99417d9f27dd913e7ea61660..e266319a381912e9f079f22777f636c8e5f5aa4c 100644 (file)
@@ -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
 
index 009237f6eda0e5eecbc202bba3e9c422976e7c6a..f26f1e90f8ff29745e9aee9394b8c4701dba5cf2 100644 (file)
@@ -27,6 +27,7 @@ using namespace std;
 
 #include "AliHLTSystem.h"
 #include "AliHLTDummyComponent.h"
+#include "AliHLTDefinitions.h"
 #include <stdlib.h>
 #include <errno.h>