]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCDBMetaData.cxx
Coverity:
[u/mrichter/AliRoot.git] / STEER / AliCDBMetaData.cxx
index cdb325d931f99799ef871096762fa1b9b18cb606..779bd5445956f10cc31389ae41ac52a925cdfba1 100644 (file)
@@ -25,6 +25,7 @@
 #include "AliLog.h"
 
 #include <TObjString.h>
+#include <TTimeStamp.h>
 
 ClassImp(AliCDBMetaData)
 
@@ -32,16 +33,33 @@ ClassImp(AliCDBMetaData)
 AliCDBMetaData::AliCDBMetaData() :
 TObject(),
 fObjectClassName(""),
-fResponsible(""),      
-fBeamPeriod(0),        
+fResponsible(""),
+fBeamPeriod(0),
 fAliRootVersion(""),
-fComment("")   
+fComment(""),
+fProperties()  
 {
 // default constructor
 
        fProperties.SetOwner(1);
 }
 
+//_____________________________________________________________________________
+AliCDBMetaData::AliCDBMetaData(const char *responsible, UInt_t beamPeriod,
+                               const char* alirootVersion, const char* comment) :
+TObject(),
+fObjectClassName(""),
+fResponsible(responsible),
+fBeamPeriod(beamPeriod),
+fAliRootVersion(alirootVersion),
+fComment(comment),
+fProperties()  
+{
+// constructor
+
+       fProperties.SetOwner(1);
+}
+
 //_____________________________________________________________________________
 AliCDBMetaData::~AliCDBMetaData() {
 // destructor
@@ -77,22 +95,46 @@ Bool_t AliCDBMetaData::RemoveProperty(const char* property) {
        }
 }
 
+//_____________________________________________________________________________
+void AliCDBMetaData::AddDateToComment() {
+// add the date to the comment.
+// This method is supposed to be useful if called at the time when the object
+// is created, so that later it can more easily be tracked, in particular
+// when the date of the file can be lost or when one is interested in the
+// date of creation, irrespective of a later copy of it
+
+       TTimeStamp ts(time(0));
+       TString comment(GetComment());
+       comment += Form("\tDate of production: %s\n", ts.AsString());
+       comment.Remove(comment.Last('+'));
+       SetComment(comment);
+
+}
+
 //_____________________________________________________________________________
 void AliCDBMetaData::PrintMetaData() {
 // print the object's metaData
 
-       AliInfo("**** Object's MetaData set ****");
-       AliInfo(Form("  Object's class name:    %s", fObjectClassName.Data()));
-       AliInfo(Form("  Responsible:            %s", fResponsible.Data()));
-       AliInfo(Form("  Beam period:            %d", fBeamPeriod));
-       AliInfo(Form("  AliRoot version:        %s", fAliRootVersion.Data()));
-       AliInfo(Form("  Comment:                %s", fComment.Data()));
-       AliInfo("  Properties key names:");
-
-       TIter iter(fProperties.GetTable());     
-       TPair* aPair;
-       while ((aPair = (TPair*) iter.Next())) {
-               AliInfo(Form("                  %s",((TObjString* )aPair->Key())->String().Data()));
+       TString message;
+       if(fObjectClassName != "")
+               message += Form("\tObject's class name: %s\n", fObjectClassName.Data());
+       if(fResponsible != "")
+               message += Form("\tResponsible:         %s\n", fResponsible.Data());
+       if(fBeamPeriod != 0)
+               message += Form("\tBeam period:         %d\n", fBeamPeriod);
+       if(fAliRootVersion != "")
+               message += Form("\tAliRoot version:     %s\n", fAliRootVersion.Data());
+       if(fComment != "")
+               message += Form("\tComment:             %s\n", fComment.Data());
+       if(fProperties.GetEntries() > 0){
+               message += "\tProperties key names:";
+
+               TIter iter(fProperties.GetTable());
+               TPair* aPair;
+               while ((aPair = (TPair*) iter.Next())) {
+                       message += Form("\t\t%s\n", ((TObjString* ) aPair->Key())->String().Data());
+               }
        }
-       
+       message += '\n';
+       AliInfo(Form("**** Object's MetaData parameters **** \n%s", message.Data()));
 }