* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id$ */
-
-///////////////////////////////////////////////////////////////////////////////
-// //
-// Object meta data: full description of a run dependent database object //
-// //
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include <TRegexp.h>
-#include <TObjArray.h>
-#include <TObjString.h>
-#include <TSystem.h>
+/////////////////////////////////////////////////////////////////////
+// //
+// class AliCDBMetaData //
+// Set of data describing the object //
+// but not used to identify the object //
+// //
+/////////////////////////////////////////////////////////////////////
#include "AliCDBMetaData.h"
#include "AliLog.h"
+#include <TObjString.h>
+#include <TTimeStamp.h>
ClassImp(AliCDBMetaData)
-
//_____________________________________________________________________________
AliCDBMetaData::AliCDBMetaData() :
- TObject(),
- fName(""),
- fFirstRun(-1),
- fLastRun(-1),
- fVersion(-1),
- fPeriod(-1),
- fFormat(""),
- fResponsible("Duck, Donald"),
- fExtraInfo("")
+TObject(),
+fObjectClassName(""),
+fResponsible(""),
+fBeamPeriod(0),
+fAliRootVersion(""),
+fComment(""),
+fProperties()
{
// default constructor
-// the default values mean no selection
- DecodeName();
-}
-//_____________________________________________________________________________
-AliCDBMetaData::AliCDBMetaData
- (const char* name, Int_t firstRun, Int_t lastRun, Int_t period,
- const char* objFormat, const char* responsible,
- const char* extraInfo):
- TObject(),
- fName(name),
- fFirstRun(firstRun),
- fLastRun(lastRun),
- fVersion(-1),
- fPeriod(period),
- fFormat(objFormat),
- fResponsible(responsible),
- fExtraInfo(extraInfo)
-{
-// constructor
- DecodeName();
+ fProperties.SetOwner(1);
}
//_____________________________________________________________________________
-AliCDBMetaData::AliCDBMetaData(const AliCDBMetaData& entry) :
- TObject(entry),
- fName(entry.fName),
- fFirstRun(entry.fFirstRun),
- fLastRun(entry.fLastRun),
- fVersion(entry.fVersion),
- fPeriod(entry.fPeriod),
- fFormat(entry.fFormat),
- fResponsible(entry.fResponsible),
- fExtraInfo(entry.fExtraInfo)
+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()
{
-// copy constructor
- DecodeName();
-}
+// constructor
-//_____________________________________________________________________________
-AliCDBMetaData& AliCDBMetaData::operator = (const AliCDBMetaData& entry)
-{
-// assignment operator
- fName = entry.fName;
- fFirstRun = entry.fFirstRun;
- fLastRun = entry.fLastRun;
- fVersion = entry.fVersion;
- fPeriod=entry.fPeriod;
- fFormat=entry.fFormat;
- fResponsible=entry.fResponsible;
- fExtraInfo=entry.fExtraInfo;
- DecodeName();
- return *this;
+ fProperties.SetOwner(1);
}
//_____________________________________________________________________________
-void AliCDBMetaData::EncodeName(){
-// Encode name from single elements ("Detector", "DBType", "DetSpecType" -> "Detector/DBType/DetSpecType")
- fName = fDetector+'/'+fDBType+'/'+fDetSpecType;
- if(fDBType == "*" && fDetSpecType == "*") fName = fDetector+'/'+'*';
- if(fDetector == "*" && fDBType == "*" && fDetSpecType == "*") fName = "*";
+AliCDBMetaData::~AliCDBMetaData() {
+// destructor
}
//_____________________________________________________________________________
-void AliCDBMetaData::DecodeName(){
-// Decode name into single elements ("Detector/DBType/DetSpecType" -> "Detector", "DBType", "DetSpecType")
-
- if(fName==""){fDetector=""; fDBType=""; fDetSpecType=""; return;}
-
- while(fName.EndsWith("/")) fName.Remove(fName.Last('/'));
- while(fName.BeginsWith("/")) fName.Remove(fName.First('/'),1);
-
- // fName= "fDetector/fDBType/fDetSpecType
- int nslashes=fName.CountChar('/');
-
- if(nslashes>2){AliError("Wrong format!\n");fDetector=""; fDBType=""; fDetSpecType="";}
-
- if(nslashes == 0){
- if(fName == "*"){fDetector="*"; fDBType="*"; fDetSpecType="*";}
- else{AliError("Wrong format!\n"); fDetector=""; fDBType=""; fDetSpecType="";}
- }
- if(nslashes == 1){
- if(fName.EndsWith("*"))
- {fDetector=fName(0, fName.Index('/')); fDBType="*"; fDetSpecType="*";}
- else {AliError("Wrong format!\n"); fDetector=""; fDBType=""; fDetSpecType="";}
- }
-
- if(nslashes == 2){
- int firstsl=fName.First('/'), lastsl=fName.Last('/'), lgth=fName.Length();
- fDetector=fName(0, firstsl);
- fDBType=fName(firstsl+1, lastsl-(firstsl+1));
- fDetSpecType=fName(lastsl+1, lgth-(lastsl+1));
- }
- EncodeName();
-}
+void AliCDBMetaData::SetProperty(const char* property, TObject* object) {
+// add something to the list of properties
-//_____________________________________________________________________________
-Bool_t AliCDBMetaData::IsStrictlyValid(Int_t runNumber, AliCDBMetaData* metaData) const
-{
-// check if the object is valid for runNumber. TRUE if metaData version is equal to this's version
-
- if ((fFirstRun >= 0) && (runNumber < fFirstRun)) return kFALSE;
- if ((fLastRun >= 0) && (runNumber > fLastRun)) return kFALSE;
- if (metaData) {
- if ((metaData->fVersion >= 0) && (metaData->fVersion != fVersion))
- return kFALSE;
- }
- return kTRUE;
+ fProperties.Add(new TObjString(property), object);
}
//_____________________________________________________________________________
-Bool_t AliCDBMetaData::IsValid(Int_t runNumber, AliCDBMetaData* metaData) const
-{
-// check if the object is valid for runNumber. TRUE if metaData version less or equal wrt to this's
-
- if ((fFirstRun >= 0) && (runNumber < fFirstRun)) return kFALSE;
- if ((fLastRun >= 0) && (runNumber > fLastRun)) return kFALSE;
- if (metaData) {
- if ((metaData->fVersion >= 0) && (metaData->fVersion < fVersion))
- return kFALSE;
- }
- return kTRUE;
+TObject* AliCDBMetaData::GetProperty(const char* property) const {
+// get a property specified by its name (property)
+
+ return fProperties.GetValue(property);
}
//_____________________________________________________________________________
-Int_t AliCDBMetaData::Compare(const TObject* object) const
-{
-// check whether this is preferred to object
-
- if (!object || !object->InheritsFrom(AliCDBMetaData::Class())) return 1;
- if (fVersion < ((AliCDBMetaData*)object)->GetVersion()) return -1;
- if (fVersion > ((AliCDBMetaData*)object)->GetVersion()) return 1;
- return 0;
+Bool_t AliCDBMetaData::RemoveProperty(const char* property) {
+// removes a property
+
+ TObjString objStrProperty(property);
+ TObjString* aKey = (TObjString*) fProperties.Remove(&objStrProperty);
+
+ if (aKey) {
+ delete aKey;
+ return kTRUE;
+ } else {
+ return kFALSE;
+ }
}
//_____________________________________________________________________________
-Bool_t AliCDBMetaData::Matches(const char* name, Int_t runNumber) const
-{
-// check whether name and run number match with this meta data
+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);
- if ((fFirstRun >= 0) && (runNumber < fFirstRun)) return kFALSE;
- if ((fLastRun >= 0) && (runNumber > fLastRun)) return kFALSE;
- if (!TString(name).Contains(TRegexp(fName))) return kFALSE;
- return kTRUE;
}
-
//_____________________________________________________________________________
-Bool_t operator == (const AliCDBMetaData& entry1, const AliCDBMetaData& entry2)
-{
-// compare two DB entries
-
- if (strcmp(entry1.GetName(), entry2.GetName()) != 0) return kFALSE;
- if (entry1.GetFirstRun() != entry2.GetFirstRun()) return kFALSE;
- if (entry1.GetLastRun() != entry2.GetLastRun()) return kFALSE;
- if (entry1.GetVersion() != entry2.GetVersion()) return kFALSE;
- return kTRUE;
+void AliCDBMetaData::PrintMetaData() {
+// print the object's metaData
+
+ 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()));
}
-
-