00001 // -*- C++ -*- 00002 // 00003 // InputDescription.h is a part of ThePEG - Toolkit for HEP Event Generation 00004 // Copyright (C) 1999-2007 Leif Lonnblad 00005 // 00006 // ThePEG is licenced under version 2 of the GPL, see COPYING for details. 00007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 00008 // 00009 #ifndef ThePEG_InputDescription_H 00010 #define ThePEG_InputDescription_H 00011 // This is the declaration of the InputDescription class. 00012 00013 #include "ThePEG/Config/ThePEG.h" 00014 #include "ThePEG/Utilities/ClassDescription.h" 00015 00016 namespace ThePEG { 00017 00031 class InputDescription: public Named { 00032 00033 public: 00034 00036 typedef vector<const InputDescription *> DescriptionVector; 00037 00038 ThePEG_DECLARE_POINTERS(PersistentBase,BPtr); 00039 00040 public: 00041 00047 InputDescription(string newName, int newVersion) 00048 : Named(newName), theDescription(0), theVersion(newVersion) {} 00049 00053 void setDescription(const ClassDescriptionBase * cd) { 00054 theDescription = cd; 00055 } 00056 00060 void addBaseClass(const InputDescription * newBase) { 00061 theBaseClasses.push_back(newBase); 00062 } 00063 00067 const DescriptionVector & descriptions() const { 00068 return theBaseClasses; 00069 } 00070 00074 BPtr create() const { 00075 if ( theDescription ) return theDescription->create(); 00076 DescriptionVector::const_iterator dit = theBaseClasses.begin(); 00077 while ( dit != theBaseClasses.end() ) { 00078 BPtr obj = (*dit++)->create(); 00079 if ( obj ) return obj; 00080 } 00081 return BPtr(); 00082 } 00083 00089 void input(tBPtr b, PersistentIStream & is) const { 00090 if ( theDescription ) theDescription->input(b, is, theVersion); 00091 } 00092 00093 private: 00094 00098 DescriptionVector theBaseClasses; 00099 00104 const ClassDescriptionBase * theDescription; 00105 00109 int theVersion; 00110 00111 }; 00112 00113 } 00114 00115 #endif /* ThePEG_InputDescription_H */