Changeset 1222 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 02/21/02 14:46:59 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1218 r1222 40 40 41 41 #include <TClass.h> // IsA 42 #include <TBaseClass.h> // GetClassPointer 42 43 #include <TROOT.h> // TROOT::Identlevel 43 44 #include <TMethodCall.h> // TMethodCall, AsciiWrite … … 216 217 // Write out a data member given as a TDataMember object to an output stream. 217 218 // 218 Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const219 Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member) const 219 220 { 220 221 if (!member) 221 222 return kFALSE; 222 223 223 if (!member->IsPersistent() )224 return kFALSE; 225 226 /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root224 if (!member->IsPersistent() || member->Property()&kIsStatic) 225 return kFALSE; 226 227 /*const*/ TMethodCall *call = ((TDataMember*)member)->GetterMethod(); //FIXME: Root 227 228 if (!call) 228 return kFALSE; 229 { 230 *fLog << warn << "Sorry, no getter method found for " << member->GetName() << endl; 231 return kFALSE; 232 } 229 233 230 234 switch (call->ReturnType()) … … 256 260 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const 257 261 { 258 return WriteDataMember(out, IsA()->GetDataMember(member)); 262 /*const*/ TClass *cls = IsA()->GetBaseDataMember(member); 263 if (!cls) 264 return kFALSE; 265 266 return WriteDataMember(out, cls->GetDataMember(member)); 267 } 268 269 // -------------------------------------------------------------------------- 270 // 271 // Write out a data member from a given TList of TDataMembers. 272 // returns kTRUE when at least one member was successfully written 273 // 274 Bool_t MParContainer::WriteDataMember(ostream &out, const TList *list) const 275 { 276 Bool_t rc = kFALSE; 277 278 TDataMember *data = NULL; 279 280 TIter Next(list); 281 while ((data=(TDataMember*)Next())) 282 rc |= WriteDataMember(out, data); 283 284 return rc; 259 285 } 260 286 … … 267 293 // Only data members which are of integer (Bool_t, Int_t, ...) or 268 294 // floating point (Float_t, Double_t, ...) type are written. 269 // 270 void MParContainer::AsciiWrite(ostream &out) const 295 // returns kTRUE when at least one member was successfully written 296 // 297 Bool_t MParContainer::AsciiWrite(ostream &out) const 271 298 { 272 299 // *fLog << warn << "To use the the ascii output of " << GetName(); 273 300 // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl; 274 301 275 TDataMember *data = NULL; 276 277 TIter Next(IsA()->GetListOfDataMembers()); 278 while ((data=(TDataMember*)Next())) 279 WriteDataMember(out, data); 280 } 302 Bool_t rc = WriteDataMember(out, IsA()->GetListOfDataMembers()); 303 304 TIter NextBaseClass(IsA()->GetListOfBases()); 305 TBaseClass *base; 306 while ((base = (TBaseClass*) NextBaseClass())) 307 { 308 /*const*/ TClass *cls = base->GetClassPointer(); 309 310 if (!cls) 311 continue; 312 313 rc |= WriteDataMember(out, cls->GetListOfDataMembers()); 314 } 315 316 return rc; 317 } -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1218 r1222 67 67 68 68 Bool_t WriteDataMember(ostream &out, const char *member) const; 69 Bool_t WriteDataMember(ostream &out, TDataMember *member) const; 69 Bool_t WriteDataMember(ostream &out, const TDataMember *member) const; 70 Bool_t WriteDataMember(ostream &out, const TList *list) const; 70 71 71 72 virtual void AsciiRead(ifstream &fin); 72 virtual voidAsciiWrite(ostream &out) const;73 virtual Bool_t AsciiWrite(ostream &out) const; 73 74 74 75 ClassDef(MParContainer, 0) //The basis for all parameter containers -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r1219 r1222 154 154 155 155 if (memb->GetName()[0]=='\0') 156 cont->AsciiWrite(*fOut); 156 { 157 if (!cont->AsciiWrite(*fOut)) 158 continue; 159 } 157 160 else 158 161 { … … 167 170 } 168 171 169 if (written) 170 *fOut << endl; 172 if (!written) 173 return; 174 175 *fOut << endl; 171 176 172 177 if (num!=0) 173 *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;178 *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl; 174 179 } 175 180
Note:
See TracChangeset
for help on using the changeset viewer.