00001 // -*- C++ -*- 00002 // 00003 // DescriptionList.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_DescriptionList_H 00010 #define ThePEG_DescriptionList_H 00011 // This is the declaration of the DescriptionList class. 00012 00013 #include "ThePEG/Config/ThePEG.h" 00014 #include "ClassDescription.fh" 00015 00016 namespace ThePEG { 00017 00022 class DescriptionList { 00023 00024 public: 00025 00026 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG 00027 00028 typedef map<const type_info *, ClassDescriptionBase *> DescriptionMap; 00029 #else 00030 00031 typedef map<string, ClassDescriptionBase *> DescriptionMap; 00032 #endif 00033 00036 typedef map<string, ClassDescriptionBase *> StringMap; 00037 00038 public: 00039 00043 static void Register(ClassDescriptionBase &); 00044 00048 static inline const ClassDescriptionBase * find(const type_info & ti) { 00049 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG 00050 DescriptionMap::const_iterator it = descriptionMap().find(&ti); 00051 #else 00052 DescriptionMap::const_iterator it = descriptionMap().find(ti.name()); 00053 #endif 00054 if ( it == descriptionMap().end() ) return 0; 00055 return (*it).second; 00056 } 00057 00058 00062 static inline const ClassDescriptionBase * find(const string & name) { 00063 StringMap::const_iterator it = stringMap().find(name); 00064 if ( it == stringMap().end() ) return 0; 00065 return it->second; 00066 } 00067 00072 static inline const DescriptionMap & all() { return descriptionMap(); } 00073 00078 static void printHierarchies(ostream & os); 00079 00080 protected: 00081 00085 static void hookup(); 00086 00090 static void insert(ClassDescriptionBase & pb); 00091 00097 static DescriptionMap & descriptionMap(); 00098 00104 static StringMap & stringMap(); 00105 00106 }; 00107 00108 } 00109 00110 #endif /* ThePEG_DescriptionList_H */