]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/CDB/AliCDBMetaData.cxx
Adding Domenico Colella as responsible for SPD part in TRI pp
[u/mrichter/AliRoot.git] / STEER / CDB / AliCDBMetaData.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /////////////////////////////////////////////////////////////////////
17 //                                                                 //
18 //  class AliCDBMetaData                                           //
19 //  Set of data describing the object                              //
20 //  but not used to identify the object                            //
21 //                                                                 //
22 /////////////////////////////////////////////////////////////////////
23
24 #include "AliCDBMetaData.h"
25 #include "AliLog.h"
26
27 #include <TObjString.h>
28 #include <TTimeStamp.h>
29
30 ClassImp(AliCDBMetaData)
31
32 //_____________________________________________________________________________
33 AliCDBMetaData::AliCDBMetaData() :
34   TObject(),
35   fObjectClassName(""),
36   fResponsible(""),
37   fBeamPeriod(0),
38   fAliRootVersion(""),
39   fComment(""),
40   fProperties() 
41 {
42   // default constructor
43
44   fProperties.SetOwner(1);
45 }
46
47 //_____________________________________________________________________________
48 AliCDBMetaData::AliCDBMetaData(const char *responsible, UInt_t beamPeriod,
49     const char* alirootVersion, const char* comment) :
50   TObject(),
51   fObjectClassName(""),
52   fResponsible(responsible),
53   fBeamPeriod(beamPeriod),
54   fAliRootVersion(alirootVersion),
55   fComment(comment),
56   fProperties() 
57 {
58   // constructor
59
60   fProperties.SetOwner(1);
61 }
62
63 //_____________________________________________________________________________
64 AliCDBMetaData::~AliCDBMetaData() {
65   // destructor
66
67 }
68
69 //_____________________________________________________________________________
70 void AliCDBMetaData::SetProperty(const char* property, TObject* object) {
71   // add something to the list of properties
72
73   fProperties.Add(new TObjString(property), object);
74 }
75
76 //_____________________________________________________________________________
77 TObject* AliCDBMetaData::GetProperty(const char* property) const {
78   // get a property specified by its name (property)
79
80   return fProperties.GetValue(property);
81 }
82
83 //_____________________________________________________________________________
84 Bool_t AliCDBMetaData::RemoveProperty(const char* property) {
85   // removes a property
86
87   TObjString objStrProperty(property);
88   TObjString* aKey = (TObjString*) fProperties.Remove(&objStrProperty); 
89
90   if (aKey) {
91     delete aKey;
92     return kTRUE;
93   } else {
94     return kFALSE;
95   }
96 }
97
98 //_____________________________________________________________________________
99 void AliCDBMetaData::AddDateToComment() {
100   // add the date to the comment.
101   // This method is supposed to be useful if called at the time when the object
102   // is created, so that later it can more easily be tracked, in particular
103   // when the date of the file can be lost or when one is interested in the
104   // date of creation, irrespective of a later copy of it
105
106   TTimeStamp ts(time(0));
107   TString comment(GetComment());
108   comment += Form("\tDate of production: %s\n", ts.AsString());
109   comment.Remove(comment.Last('+'));
110   SetComment(comment);
111
112 }
113
114 //_____________________________________________________________________________
115 void AliCDBMetaData::PrintMetaData() {
116   // print the object's metaData
117
118   TString message;
119   if(fObjectClassName != "")
120     message += TString::Format("\tObject's class name:  %s\n", fObjectClassName.Data());
121   if(fResponsible != "")
122     message += TString::Format("\tResponsible:          %s\n", fResponsible.Data());
123   if(fBeamPeriod != 0)
124     message += TString::Format("\tBeam period:          %d\n", fBeamPeriod);
125   if(fAliRootVersion != "")
126     message += TString::Format("\tAliRoot version:      %s\n", fAliRootVersion.Data());
127   if(fComment != "")
128     message += TString::Format("\tComment:              %s\n", fComment.Data());
129   if(fProperties.GetEntries() > 0){
130     message += "\tProperties key names:";
131
132     TIter iter(fProperties.GetTable());
133     TPair* aPair;
134     while ((aPair = (TPair*) iter.Next())) {
135       message += TString::Format("\t\t%s\n", ((TObjString* ) aPair->Key())->String().Data());
136     }
137   }
138   message += '\n';
139   Printf("**** Object's MetaData parameters **** \n%s", message.Data());
140 }