Changeset 1218 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 02/21/02 12:08:03 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MFilterList.cc
r1080 r1218 143 143 const char *name = filter->GetName(); 144 144 145 // FIXME: We agreed to put the task into list in an ordered way.146 147 145 if (fFilters.FindObject(filter)) 148 146 { -
trunk/MagicSoft/Mars/mbase/MGList.cc
r1116 r1218 98 98 // Is this another bug in root? 99 99 // 100 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07) 100 101 if (!obj->IsA()->InheritsFrom(TGWidget::Class())) 101 102 return NULL; 103 #endif 102 104 103 105 return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj); -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1211 r1218 214 214 // -------------------------------------------------------------------------- 215 215 // 216 // Write out a data member given as a TDataMember object to an output stream. 217 // 218 Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const 219 { 220 if (!member) 221 return kFALSE; 222 223 if (!member->IsPersistent()) 224 return kFALSE; 225 226 /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root 227 if (!call) 228 return kFALSE; 229 230 switch (call->ReturnType()) 231 { 232 case TMethodCall::kLong: 233 Long_t l; 234 call->Execute((void*)this, l); // FIXME: const, root 235 out << l << " "; 236 return kTRUE; 237 238 case TMethodCall::kDouble: 239 Double_t d; 240 call->Execute((void*)this, d); // FIXME: const, root 241 out << d << " "; 242 return kTRUE; 243 244 case TMethodCall::kOther: 245 /* someone may want to enhance this? */ 246 return kFALSE; 247 } 248 249 return kFALSE; 250 } 251 252 // -------------------------------------------------------------------------- 253 // 254 // Write out a data member given by name to an output stream. 255 // 256 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const 257 { 258 return WriteDataMember(out, IsA()->GetDataMember(member)); 259 } 260 261 // -------------------------------------------------------------------------- 262 // 216 263 // If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a 217 264 // container, you may overload this function. If you don't overload it … … 221 268 // floating point (Float_t, Double_t, ...) type are written. 222 269 // 223 void MParContainer::AsciiWrite(o fstream &fout) const270 void MParContainer::AsciiWrite(ostream &out) const 224 271 { 225 272 // *fLog << warn << "To use the the ascii output of " << GetName(); … … 230 277 TIter Next(IsA()->GetListOfDataMembers()); 231 278 while ((data=(TDataMember*)Next())) 232 { 233 if (!data->IsPersistent()) 234 continue; 235 236 /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root 237 if (!call) 238 continue; 239 240 switch (call->ReturnType()) 241 { 242 case TMethodCall::kLong: 243 Long_t l; 244 call->Execute((void*)this, l); // FIXME: const, root 245 fout << l << " "; 246 continue; 247 248 case TMethodCall::kDouble: 249 Double_t d; 250 call->Execute((void*)this, d); // FIXME: const, root 251 fout << d << " "; 252 continue; 253 254 case TMethodCall::kOther: 255 /* someone may want to enhance this? */ 256 continue; 257 } 258 } 259 } 279 WriteDataMember(out, data); 280 } -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1086 r1218 22 22 class ofstream; 23 23 class ifstream; 24 25 class TDataMember; 24 26 25 27 class MParContainer : public TObject … … 64 66 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } 65 67 68 Bool_t WriteDataMember(ostream &out, const char *member) const; 69 Bool_t WriteDataMember(ostream &out, TDataMember *member) const; 70 66 71 virtual void AsciiRead(ifstream &fin); 67 virtual void AsciiWrite(o fstream &fout) const;72 virtual void AsciiWrite(ostream &out) const; 68 73 69 74 ClassDef(MParContainer, 0) //The basis for all parameter containers -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r1192 r1218 44 44 #include <fstream.h> 45 45 46 #include <TClass.h> // IsA 47 #include <TMethodCall.h> // TMethodCall, AsciiWrite 48 #include <TDataMember.h> // TDataMember, AsciiWrite 49 46 50 #include "MLog.h" 47 51 #include "MLogManip.h" … … 81 85 Init(filename, name, title); 82 86 83 AddContainer(contname); 87 if (contname) 88 AddContainer(contname); 84 89 } 85 90 … … 100 105 Init(filename, name, title); 101 106 102 AddContainer(cont); 107 if (cont) 108 AddContainer(cont); 103 109 } 104 110 … … 111 117 { 112 118 fContNames.SetOwner(); 119 fMembers.SetOwner(); 113 120 114 121 delete fOut; … … 130 137 Int_t num = fContainer.GetEntries(); 131 138 132 TIter Next(&fContainer); 133 134 while ((cont=(MParContainer*)Next())) 139 TIter NextCont(&fContainer); 140 TIter NextMemb(&fMembers); 141 142 while ((cont=(MParContainer*)NextCont())) 135 143 { 144 const TObject *memb = NextMemb(); 145 136 146 if (!cont->IsReadyToSave()) 137 147 continue; 138 148 139 cont->AsciiWrite(*fOut); 149 if (memb->GetName()[0]=='\0') 150 cont->AsciiWrite(*fOut); 151 else 152 { 153 if (!cont->WriteDataMember(*fOut, memb->GetName())) 154 continue; 155 } 156 140 157 *fOut << " "; 141 158 written = kTRUE; … … 183 200 } 184 201 185 AddContainer(cont );202 AddContainer(cont, obj->GetTitle()); 186 203 } 187 204 … … 193 210 // Add another container (by name) to be written to the ascii file. 194 211 // The container will be output one after each other in one line. 195 // 196 void MWriteAsciiFile::AddContainer(const char *cname) 197 { 198 TNamed *named = new TNamed(cname, ""); 212 // If you want to write only one data member of the container 213 // specify the name of the data member (eg. fAlpha) Make sure, 214 // that a "GetteMethod" for this data type exists (strif the f and 215 // replace it by Get) 216 // 217 void MWriteAsciiFile::AddContainer(const char *cname, const char *member) 218 { 219 TNamed *named = new TNamed(cname, member); 199 220 fContNames.AddLast(named); 200 221 } … … 204 225 // Add another container (by pointer) to be written to the ascii file. 205 226 // The container will be output one after each other in one line. 206 // 207 void MWriteAsciiFile::AddContainer(MParContainer *cont) 227 // If you want to write only one data member of the container 228 // specify the name of the data member (eg. fAlpha) Make sure, 229 // that a "GetteMethod" for this data type exists (strif the f and 230 // replace it by Get) 231 // 232 void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member) 208 233 { 209 234 fContainer.AddLast(cont); 210 } 211 235 236 TNamed *named = new TNamed(member, ""); 237 fMembers.AddLast(named); 238 } 239
Note:
See TracChangeset
for help on using the changeset viewer.