]>
Commit | Line | Data |
---|---|---|
2c8628dd | 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 | ||
9e1ceb13 | 16 | ///////////////////////////////////////////////////////////////////// |
17 | // // | |
18 | // class AliCDBMetaData // | |
19 | // Set of data describing the object // | |
20 | // but not used to identify the object // | |
21 | // // | |
22 | ///////////////////////////////////////////////////////////////////// | |
2c8628dd | 23 | |
fe913d8f | 24 | #include "AliCDBMetaData.h" |
f05209ee | 25 | #include "AliLog.h" |
2c8628dd | 26 | |
9e1ceb13 | 27 | #include <TObjString.h> |
5b039c66 | 28 | #include <TTimeStamp.h> |
2c8628dd | 29 | |
fe913d8f | 30 | ClassImp(AliCDBMetaData) |
2c8628dd | 31 | |
2c8628dd | 32 | //_____________________________________________________________________________ |
17c7b9cd | 33 | AliCDBMetaData::AliCDBMetaData() : |
34 | TObject(), | |
35 | fObjectClassName(""), | |
c3a7b59a | 36 | fResponsible(""), |
37 | fBeamPeriod(0), | |
17c7b9cd | 38 | fAliRootVersion(""), |
fe12e09c | 39 | fComment(""), |
40 | fProperties() | |
17c7b9cd | 41 | { |
2c8628dd | 42 | // default constructor |
2c8628dd | 43 | |
9e1ceb13 | 44 | fProperties.SetOwner(1); |
2c8628dd | 45 | } |
46 | ||
c3a7b59a | 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 | ||
2c8628dd | 63 | //_____________________________________________________________________________ |
9e1ceb13 | 64 | AliCDBMetaData::~AliCDBMetaData() { |
65 | // destructor | |
2c8628dd | 66 | |
2c8628dd | 67 | } |
68 | ||
2c8628dd | 69 | //_____________________________________________________________________________ |
9e1ceb13 | 70 | void AliCDBMetaData::SetProperty(const char* property, TObject* object) { |
71 | // add something to the list of properties | |
f05209ee | 72 | |
9e1ceb13 | 73 | fProperties.Add(new TObjString(property), object); |
f05209ee | 74 | } |
75 | ||
76 | //_____________________________________________________________________________ | |
9e1ceb13 | 77 | TObject* AliCDBMetaData::GetProperty(const char* property) const { |
78 | // get a property specified by its name (property) | |
f05209ee | 79 | |
9e1ceb13 | 80 | return fProperties.GetValue(property); |
2c8628dd | 81 | } |
82 | ||
83 | //_____________________________________________________________________________ | |
9e1ceb13 | 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 | } | |
2c8628dd | 96 | } |
97 | ||
5b039c66 | 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 | ||
2c8628dd | 114 | //_____________________________________________________________________________ |
9e1ceb13 | 115 | void AliCDBMetaData::PrintMetaData() { |
116 | // print the object's metaData | |
117 | ||
62032124 | 118 | TString message; |
119 | if(fObjectClassName != "") | |
120 | message += Form("\tObject's class name: %s\n", fObjectClassName.Data()); | |
121 | if(fResponsible != "") | |
122 | message += Form("\tResponsible: %s\n", fResponsible.Data()); | |
123 | if(fBeamPeriod != 0) | |
124 | message += Form("\tBeam period: %d\n", fBeamPeriod); | |
125 | if(fAliRootVersion != "") | |
126 | message += Form("\tAliRoot version: %s\n", fAliRootVersion.Data()); | |
127 | if(fComment != "") | |
128 | message += Form("\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 += Form("\t\t%s\n", ((TObjString* ) aPair->Key())->String().Data()); | |
136 | } | |
9e1ceb13 | 137 | } |
c3a7b59a | 138 | message += '\n'; |
139 | AliInfo(Form("**** Object's MetaData parameters **** \n%s", message.Data())); | |
2c8628dd | 140 | } |