Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:32

0001 // -*- C++ -*-
0002 //
0003 // DescriptionList.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_DescriptionList_H
0010 #define ThePEG_DescriptionList_H
0011 // This is the declaration of the DescriptionList class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ClassDescription.fh"
0015 
0016 namespace ThePEG {
0017 
0018 /**
0019  * The <code>DescriptionList</code> keeps a static list of descriptions
0020  * of classes included in the current run.
0021  */
0022 class DescriptionList {
0023 
0024 public:
0025 
0026 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG
0027   /** Map of class descriptions indexed by type_info objects. */
0028   typedef map<const type_info *, ClassDescriptionBase *> DescriptionMap;
0029 #else
0030   /** Map of class descriptions indexed by type_info objects. */
0031   typedef map<string, ClassDescriptionBase *> DescriptionMap;
0032 #endif
0033 
0034   /** Map of class descriptions indexed by platform-independent class
0035    * names. */
0036   typedef map<string, ClassDescriptionBase *> StringMap;
0037 
0038 public:
0039 
0040   /**
0041    * Insert a description in the list.
0042    */
0043   static void Register(ClassDescriptionBase &);
0044 
0045   /**
0046    * Get the description of a class giving its type_info object.
0047    */
0048   static inline const ClassDescriptionBase * find(const type_info & ti) {
0049 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG
0050     DescriptionMap::const_iterator it =  descriptionMap().find(&ti);
0051 #else
0052     DescriptionMap::const_iterator it =  descriptionMap().find(ti.name());
0053 #endif
0054     if ( it == descriptionMap().end() ) return 0;
0055     return (*it).second;
0056   }
0057 
0058   /**
0059    * Return the name of the class corresponding to the given type_info object.
0060    */
0061   static string className(const type_info & ti);
0062 
0063   /**
0064    * Return the version of the class corresponding to the given type_info object.
0065    */
0066   static int version(const type_info & ti);
0067 
0068   /**
0069    * Return the dynamic library of the class corresponding to the
0070    * given type_info object.
0071    */
0072   static string library(const type_info & ti);
0073 
0074   /**
0075    * Get the description of a class giving its name.
0076    */
0077   static inline const ClassDescriptionBase * find(const string & name) {
0078     StringMap::const_iterator it =  stringMap().find(name);
0079     if ( it == stringMap().end() ) return 0;
0080     return it->second;
0081   }
0082 
0083   /**
0084    * Return the static set of descriptions mapped to the relevant
0085    * type_info objects.
0086    */
0087   static inline const DescriptionMap & all() { return descriptionMap(); }
0088 
0089   /**
0090    * Print the classes in the list and their base classes to a
0091    * stream. Mainly intended for debugging purposes.
0092    */
0093   static void printHierarchies(ostream & os);
0094 
0095 protected:
0096 
0097   /**
0098    * Hookup the base class descriptions in the list.
0099    */
0100   static void hookup();
0101 
0102   /**
0103    * Insert a class description.
0104    */
0105   static void insert(ClassDescriptionBase & pb);
0106 
0107   /**
0108    * Return the static set of descriptions mapped to the relevant
0109    * type_info objects. This function has a static DescriptionMap
0110    * variable which is initialized the first time it is called.
0111    */
0112   static DescriptionMap & descriptionMap();
0113 
0114   /**
0115    * Return the static set of descriptions mapped to the corresponding
0116    * class names. This function has a static StringMap variable which
0117    * is initialized the first time it is called.
0118    */
0119   static StringMap & stringMap();
0120 
0121 };
0122 
0123 }
0124 
0125 #endif /* ThePEG_DescriptionList_H */