Callback function for additional information about the stamp (Marian)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Oct 2007 13:11:43 +0000 (13:11 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Oct 2007 13:11:43 +0000 (13:11 +0000)
STEER/AliSysInfo.cxx
STEER/AliSysInfo.h

index 21ec4c6..fe746e4 100644 (file)
@@ -53,7 +53,9 @@ AliSysInfo::AliSysInfo():
     TObject(),
     fSysWatch(0),
     fTimer(0),
-    fMemStat(0)
+    fMemStat(0),
+    fCallBackFunc(0),
+    fNCallBack(0)
 {
   fTimer = new TStopwatch;
   fSysWatch  = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
@@ -119,6 +121,9 @@ void AliSysInfo::AddStamp(const char *sname, Int_t id0, Int_t id1, Int_t id2){
   gSystem->GetCpuInfo(&cpuInfo, 10);
   gSystem->GetMemInfo(&memInfo);
   gSystem->GetProcInfo(&procInfo);
+  procInfo.fMemVirtual*=0.001;  //size in MBy
+  procInfo.fMemResident*=0.001;  //size in MBy
+
   const char * hname = gSystem->HostName();
 
   static Int_t entry=0;
@@ -165,7 +170,9 @@ void AliSysInfo::AddStamp(const char *sname, Int_t id0, Int_t id1, Int_t id2){
   procInfoOld= procInfo;
 
   //  if (fInstance->fMemStat) fInstance->fMemStat->AddStamps(sname);
+  for (Int_t icallback=0; icallback<Instance()->fNCallBack; icallback++){
+    Instance()->fCallBackFunc[icallback](sname);
+  }
   entry++;
 }
 
@@ -176,8 +183,8 @@ TTree * AliSysInfo::MakeTree(const char *lname){
   tree->ReadFile(lname);
   tree->SetAlias("deltaT","stampSec-stampOldSec");
   tree->SetAlias("T","stampSec-first");
-  tree->SetAlias("deltaVM","(pI.fMemVirtual-pIOld.fMemVirtual)*0.001");
-  tree->SetAlias("VM","pI.fMemVirtual*0.001");
+  tree->SetAlias("deltaVM","(pI.fMemVirtual-pIOld.fMemVirtual)");
+  tree->SetAlias("VM","pI.fMemVirtual");
   return tree;
 }
 
@@ -210,3 +217,16 @@ void AliSysInfo::CloseMemStat(){
   //if (Instance()->fMemStat  == TMemStatManager::GetInstance()) Instance()->fMemStat->Close();
   //Instance()->fMemStat=0;
 }
+
+
+
+void AliSysInfo::AddCallBack(StampCallback_t callback){
+  //
+  // add cal back function
+  //
+  AliSysInfo *info =  Instance();
+  if (!info->fCallBackFunc)
+    info->fCallBackFunc = new StampCallback_t[100];
+  info->fCallBackFunc[info->fNCallBack]=callback;
+  info->fNCallBack++;
+}
index bc28a74..05b6967 100644 (file)
@@ -27,6 +27,8 @@ public:
   static void OpenMemStat();
   static void CloseMemStat();
   static Bool_t Contain(const char * str1, const char * str2);
+  typedef void (*StampCallback_t)(const Char_t * desription);
+  static  void AddCallBack(StampCallback_t callback);
 private:
   AliSysInfo(const AliSysInfo& source);
   AliSysInfo& operator= (const AliSysInfo& rec);
@@ -35,6 +37,8 @@ private:
   TStopwatch      *fTimer;          // timer
   TMemStatManager *fMemStat;      
   static AliSysInfo *   fInstance; //instance pointer
+  StampCallback_t *fCallBackFunc; // call back functions
+  Int_t           fNCallBack;        // number of call back functions
   ClassDef(AliSysInfo,0)
 };