|
|
|||
File indexing completed on 2026-08-06 09:38:29
0001 // -*- C++ -*- 0002 // 0003 // InputDescription.h is a part of ThePEG - Toolkit for HEP Event Generation 0004 // Copyright (C) 1999-2019 Leif Lonnblad 0005 // 0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details. 0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 0008 // 0009 #ifndef ThePEG_InputDescription_H 0010 #define ThePEG_InputDescription_H 0011 // This is the declaration of the InputDescription class. 0012 0013 #include "ThePEG/Config/ThePEG.h" 0014 #include "ThePEG/Utilities/ClassDescription.h" 0015 0016 namespace ThePEG { 0017 0018 /** @ingroup Persistency 0019 * InputDescription objects are used by the PersistentIStream class to 0020 * keep track of all classes it has read from a stream. It keeps a 0021 * pointer to the corresponding ClassDescription in case the class 0022 * read in was actually present in the current program, a version 0023 * number of the read class which may be different from the class 0024 * present in the current program and a list of base class 0025 * <code>InputDescription</code>s. 0026 * 0027 * @see PersistentIStream 0028 * @see Named 0029 * @see ClassDescription 0030 */ 0031 class InputDescription: public Named { 0032 0033 public: 0034 0035 /** A vector of pointers to InputDescription objects. */ 0036 typedef vector<const InputDescription *> DescriptionVector; 0037 0038 ThePEG_DECLARE_POINTERS(PersistentBase,BPtr); 0039 0040 public: 0041 0042 /** 0043 * The standard constructor. 0044 * @param newName the name of the class being read. 0045 * @param newVersion the version number of the class when written. 0046 */ 0047 InputDescription(string newName, int newVersion) 0048 : Named(newName), theDescription(0), theVersion(newVersion) {} 0049 0050 /** 0051 * Set the ClassDescriptionBase object of the class being read. 0052 */ 0053 void setDescription(const ClassDescriptionBase * cd) { 0054 theDescription = cd; 0055 } 0056 0057 /** 0058 * Add a base class description. 0059 */ 0060 void addBaseClass(const InputDescription * newBase) { 0061 theBaseClasses.push_back(newBase); 0062 } 0063 0064 /** 0065 * Return the list of base class descriptions. 0066 */ 0067 const DescriptionVector & descriptions() const { 0068 return theBaseClasses; 0069 } 0070 0071 /** 0072 * Create an object of the corresponding class. 0073 */ 0074 BPtr create() const { 0075 if ( theDescription ) return theDescription->create(); 0076 DescriptionVector::const_iterator dit = theBaseClasses.begin(); 0077 while ( dit != theBaseClasses.end() ) { 0078 BPtr obj = (*dit++)->create(); 0079 if ( obj ) return obj; 0080 } 0081 return BPtr(); 0082 } 0083 0084 /** 0085 * Read an object part of the corresponding class from a stream. 0086 * Will only read the part of the object corresponding to the 0087 * members of the class represented by this object. 0088 */ 0089 void input(tBPtr b, PersistentIStream & is) const { 0090 if ( theDescription ) theDescription->input(b, is, theVersion); 0091 } 0092 0093 private: 0094 0095 /** 0096 * The list of base class descriptions. 0097 */ 0098 DescriptionVector theBaseClasses; 0099 0100 /** 0101 * The description of the corresponding class in the current 0102 * program. 0103 */ 0104 const ClassDescriptionBase * theDescription; 0105 0106 /** 0107 * The version of the class to be read. 0108 */ 0109 int theVersion; 0110 0111 }; 0112 0113 } 0114 0115 #endif /* ThePEG_InputDescription_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|