00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include <iostream>
00012 using std::cout;
00013 using std::endl;
00014
00015 #include "Record/RecMinos.h"
00016 #include "Record/RecMinosHdr.h"
00017
00018 ClassImp(RecMinos)
00019
00020
00021 RecMinos::RecMinos()
00022 : fHeader(new RecMinosHdr())
00023 {
00024
00025 fComponents.SetOwner(true);
00026 fTemporaries.SetOwner(true);
00027 }
00028
00029
00030 RecMinos::RecMinos(RecMinosHdr* header)
00031 : fHeader(header)
00032 {
00033
00034 fComponents.SetOwner(true);
00035 fTemporaries.SetOwner(true);
00036 }
00037
00038
00039
00040 RecMinos::~RecMinos()
00041 {
00042
00043 fComponents.Delete();
00044 fTemporaries.Delete();
00045
00046 if (fHeader) delete fHeader; fHeader = 0;
00047
00048 }
00049
00050
00051 void RecMinos::AdoptComponent(TObject* component)
00052 {
00053 fComponents.Add(component);
00054 }
00055
00056 void RecMinos::AdoptTemporary(TObject* temporary)
00057 {
00058 fTemporaries.Add(temporary);
00059 }
00060
00061
00062 TObject* RecMinos::RemoveComponent(TObject* component)
00063 {
00064 return fComponents.Remove(component);
00065 }
00066
00067 TObject* RecMinos::RemoveTemporary(TObject* temporary)
00068 {
00069 return fTemporaries.Remove(temporary);
00070 }
00071
00072
00073 const TObject* RecMinos::FindComponent(const char *classname,
00074 const char *objname) const
00075 {
00076
00077
00078
00079
00080
00081
00082
00083
00084 TString classtr("");
00085 if (classname)
00086 classtr.Append(TString(classname).Strip(TString::kBoth));
00087
00088 TString objstr("");
00089 if (objname)
00090 objstr.Append(TString(objname).Strip(TString::kBoth));
00091
00092 TObjArrayIter itr(&fComponents,kIterBackward);
00093 TObject *obj;
00094
00095 while ((obj = itr())) {
00096
00097
00098 if (classtr.IsNull() || obj->InheritsFrom(classtr)) {
00099
00100
00101 if (objstr.IsNull() || (objstr == obj->GetName()))
00102 return obj;
00103 }
00104 }
00105 return 0;
00106
00107 }
00108
00109
00110 const TObject* RecMinos::FindTemporary(const char *classname,
00111 const char *objname) const
00112 {
00113
00114
00115
00116
00117
00118
00119
00120
00121 TString classtr("");
00122 if (classname)
00123 classtr.Append(TString(classname).Strip(TString::kBoth));
00124
00125 TString objstr("");
00126 if (objname)
00127 objstr.Append(TString(objname).Strip(TString::kBoth));
00128
00129 TObjArrayIter itr(&fTemporaries,kIterBackward);
00130 TObject *obj;
00131
00132 while ((obj = itr())) {
00133
00134
00135 if (classtr.IsNull() || obj->InheritsFrom(classtr)) {
00136
00137
00138 if (objstr.IsNull() || (objstr == obj->GetName()))
00139 return obj;
00140 }
00141 }
00142 return 0;
00143
00144 }
00145
00146
00147 const VldContext* RecMinos::GetVldContext() const
00148 {
00149
00150
00151 const RecMinosHdr* head = GetHeader();
00152 if (head) return &(head->GetVldContext());
00153 return 0;
00154 }
00155
00156
00157 void RecMinos::Print(Option_t * ) const
00158 {
00159 cout << "RecMinos::Print Header: " << endl;
00160 if (fHeader) fHeader -> Print();
00161 else cout << " ... no RecMinosHdr" << endl;
00162 fJobHistory.Print();
00163
00164 TObject *obj;
00165
00166 cout << "RecMinos::Print Components: " << endl;
00167 TObjArrayIter itr(&fComponents);
00168 while ((obj = itr())) {
00169 cout << obj->ClassName() << " " << obj->GetName() << endl;
00170 }
00171
00172 }
00173
00174
00175
00176 void RecMinos::HasBeenModified() {
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 fTempTags.RemoveKey("outstream");
00195 return;
00196
00197 }
00198
00199
00200
00201 void RecMinos::PersistedToOutputStream(const char* stream,
00202 const char* file, const char* tree, int index) {
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 Registry outStreamRegistry;
00235 int nout = 0;
00236 if ( fTempTags.Get("outstream",outStreamRegistry) ) {
00237 outStreamRegistry.Get("nout",nout);
00238 }
00239 outStreamRegistry.UnLockValues();
00240
00241
00242 Registry newOutStream;
00243 newOutStream.Set("stream",stream);
00244 newOutStream.Set("file",file);
00245 newOutStream.Set("tree",tree);
00246 newOutStream.Set("index",index);
00247
00248
00249 char cnoutkey[20];
00250 sprintf(cnoutkey,"%i",nout);
00251 outStreamRegistry.Set(cnoutkey,newOutStream);
00252 nout++;
00253 outStreamRegistry.Set("nout",nout);
00254 outStreamRegistry.LockValues();
00255
00256
00257
00258 fTempTags.UnLockValues();
00259 fTempTags.Set("outstream",outStreamRegistry);
00260 fTempTags.LockValues();
00261
00262 }
00263
00264
00265
00266 bool RecMinos::IsPersistedToOutputStream(const char* stream,
00267 const char* file,const char* tree,int index) const {
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 std::string s(stream);
00284 std::string f(file);
00285 std::string t(tree);
00286
00287 Registry outStreamRegistry;
00288 int nout = 0;
00289 if ( fTempTags.Get("outstream",outStreamRegistry) ) {
00290 outStreamRegistry.Get("nout",nout);
00291 for ( int iout = 0; iout < nout; iout++) {
00292 char cioutkey[20];
00293 sprintf(cioutkey,"%i",iout);
00294 Registry outStream;
00295 outStreamRegistry.Get(cioutkey,outStream);
00296 bool isMatch = true;
00297 if ( !s.empty() ) {
00298 const char* cstream = 0;
00299 outStream.Get("stream",cstream);
00300 if ( std::string(cstream) != s ) isMatch = false;
00301 }
00302 if ( !f.empty() ) {
00303 const char* cfile = 0;
00304 outStream.Get("file",cfile);
00305 if ( std::string(cfile) != f ) isMatch = false;
00306 }
00307
00308 if ( !t.empty() ) {
00309 const char* ctree = 0;
00310 outStream.Get("tree",ctree);
00311 if ( std::string(ctree) != t ) isMatch = false;
00312 }
00313 if ( index > -1 ) {
00314 int storedindex = -1;
00315 outStream.Get("index",storedindex);
00316 if ( storedindex != index ) isMatch = false;
00317 }
00318 if ( isMatch ) {
00319 return true;
00320 }
00321 }
00322 }
00323
00324 return false;
00325
00326 }
00327
00328
00329
00330
00331 bool RecMinos::IsTransient() const {
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 int isTransient = 1;
00344 fTempTags.Get("isTransient",isTransient);
00345 return ( isTransient ) ? true : false;
00346
00347 }
00348
00349
00350
00351
00352 void RecMinos::SetTransient(bool isTransient) {
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 fTempTags.UnLockValues();
00365 if ( isTransient ) fTempTags.Set("isTransient",1);
00366 else fTempTags.Set("isTransient",0);
00367 fTempTags.LockValues();
00368 return;
00369
00370 }
00371
00372