Changeset 5994 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 01/25/05 14:47:59 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MContinue.cc
r5956 r5994 241 241 // MyContinue.0: MHillas.fSize>1000 242 242 // MyContinue.1: MHillas.fSize<10000 243 // or 243 // or (the syntax might change in the future!) 244 244 // MyContinue.Condition: <MMyClass> 245 245 // MMyClass.Variable1: ... … … 250 250 Int_t MContinue::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 251 251 { 252 MFilter *f = 0; 252 253 if (IsEnvDefined(env, prefix, "Condition", print)) 253 254 { … … 256 257 if (txt.BeginsWith("<") && txt.EndsWith(">")) 257 258 { 258 *fLog << err << "NOT YET IMPLEMENTED..." << endl; 259 return kERROR; 259 const TString name = txt(1, txt.Length()-2); 260 f = (MFilter*)GetNewObject(name, MFilter::Class()); 261 if (!f) 262 return kERROR; 260 263 } 261 264 } 262 265 263 MF *f = new MF; 266 if (!f) 267 f = new MF; 264 268 f->SetName(fName); 265 269 -
trunk/MagicSoft/Mars/mbase/MContinue.h
r5956 r5994 30 30 Int_t PostProcess(); 31 31 32 // MContinue 32 33 enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15), kAllowEmpty = BIT(16) }; 33 34 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r5986 r5994 465 465 } 466 466 467 // -------------------------------------------------------------------------- 468 // 469 // Return the pointer to the TClass (from the root dictionary) which 470 // corresponds to the class with name name. 471 // 472 // Make sure, that a new object of this type can be created. 473 // 474 // In case of failure return NULL 475 // 476 TClass *MParContainer::GetConstructor(const char *name) const 477 { 478 // 479 // try to get class from root environment 480 // 481 TClass *cls = gROOT->GetClass(name); 482 Int_t rc = 0; 483 if (!cls) 484 rc =1; 485 else 486 { 487 if (!cls->Property()) 488 rc = 5; 489 if (!cls->Size()) 490 rc = 4; 491 if (!cls->IsLoaded()) 492 rc = 3; 493 if (!cls->HasDefaultConstructor()) 494 rc = 2; 495 } 496 497 if (!rc) 498 return cls; 499 500 *fLog << err << dbginf << GetDescriptor() << " - Cannot create new instance of class '" << name << "': "; 501 switch (rc) 502 { 503 case 1: 504 *fLog << "gROOT->GetClass() returned NULL." << endl; 505 return NULL; 506 case 2: 507 *fLog << "no default constructor." << endl; 508 return NULL; 509 case 3: 510 *fLog << "not loaded." << endl; 511 return NULL; 512 case 4: 513 *fLog << "zero size." << endl; 514 return NULL; 515 case 5: 516 *fLog << "no property." << endl; 517 return NULL; 518 } 519 520 *fLog << "rtlprmft." << endl; 521 522 return NULL; 523 } 524 525 // -------------------------------------------------------------------------- 526 // 527 // Return a new object of class 'name'. Make sure that the object 528 // derives from the class base. 529 // 530 // In case of failure return NULL 531 // 532 // The caller is responsible of deleting the object! 533 // 534 MParContainer *MParContainer::GetNewObject(const char *name, TClass *base) const 535 { 536 TClass *cls = GetConstructor(name); 537 if (!cls || !base) 538 return NULL; 539 540 if (!cls->InheritsFrom(base)) 541 { 542 *fLog << " - Class doesn't inherit from " << base->GetName() << endl; 543 return NULL; 544 } 545 546 // 547 // create the parameter container of the the given class type 548 // 549 TObject *obj = (TObject*)cls->New(); 550 if (!obj) 551 { 552 *fLog << " - Class has no default constructor." << endl; 553 *fLog << " - An abstract member functions of a base class is not overwritten." << endl; 554 return NULL; 555 } 556 557 return (MParContainer*)obj; 558 } 559 560 // -------------------------------------------------------------------------- 561 // 562 // Return a new object of class 'name'. Make sure that the object 563 // derives from the class base. 564 // 565 // In case of failure return NULL 566 // 567 // The caller is responsible of deleting the object! 568 // 569 MParContainer *MParContainer::GetNewObject(const char *name, const char *base) const 570 { 571 TClass *cls = GetConstructor(name); 572 if (!cls || !base) 573 return NULL; 574 575 if (!cls->InheritsFrom(base)) 576 { 577 *fLog << " - Class doesn't inherit from " << base << endl; 578 return NULL; 579 } 580 581 // 582 // create the parameter container of the the given class type 583 // 584 TObject *obj = (TObject*)cls->New(); 585 if (!obj) 586 { 587 *fLog << " - Class has no default constructor." << endl; 588 *fLog << " - An abstract member functions of a base class is not overwritten." << endl; 589 return NULL; 590 } 591 592 return (MParContainer*)obj; 593 } 594 467 595 TMethodCall *MParContainer::GetterMethod(const char *name) const 468 596 { -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r5986 r5994 53 53 54 54 Bool_t fReadyToSave; // should be set to true if the contents of the container is changed somehow 55 56 TClass *GetConstructor(const char *name) const; 55 57 56 58 public: … … 140 142 const char *GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const; 141 143 144 MParContainer *GetNewObject(const char *name, const char *base) const; 145 MParContainer *GetNewObject(const char *name, TClass *base=MParContainer::Class()) const; 146 142 147 ClassDef(MParContainer, 0) //The basis for all parameter containers 143 148 }; -
trunk/MagicSoft/Mars/mbase/MTaskEnv.cc
r5307 r5994 100 100 MTask *MTaskEnv::GetTask(const char *name) const 101 101 { 102 // 103 // try to get class from root environment 104 // 105 TClass *cls = gROOT->GetClass(name); 106 Int_t rc = 0; 107 if (!cls) 108 rc =1; 109 else 110 { 111 if (!cls->Property()) 112 rc = 5; 113 if (!cls->Size()) 114 rc = 4; 115 if (!cls->IsLoaded()) 116 rc = 3; 117 if (!cls->HasDefaultConstructor()) 118 rc = 2; 119 } 120 121 if (rc) 122 { 123 *fLog << err << dbginf << "Cannot create new instance of class '" << name << "': "; 124 switch (rc) 125 { 126 case 1: 127 *fLog << "gROOT->GetClass() returned NULL." << endl; 128 return NULL; 129 case 2: 130 *fLog << "no default constructor." << endl; 131 return NULL; 132 case 3: 133 *fLog << "not loaded." << endl; 134 return NULL; 135 case 4: 136 *fLog << "zero size." << endl; 137 return NULL; 138 case 5: 139 *fLog << "no property." << endl; 140 return NULL; 141 } 142 } 143 144 if (!cls->InheritsFrom(MTask::Class())) 145 { 146 *fLog << " - Class doesn't inherit from MTask." << endl; 102 MTask *task = (MTask*)GetNewObject(name, MTask::Class()); 103 if (!task) 147 104 return NULL; 148 }149 150 //151 // create the parameter container of the the given class type152 //153 MTask *task = (MTask*)cls->New();154 if (!task)155 {156 *fLog << " - Class has no default constructor." << endl;157 *fLog << " - An abstract member functions of a base class is not overwritten." << endl;158 return NULL;159 }160 105 161 106 task->SetName(fName);
Note:
See TracChangeset
for help on using the changeset viewer.