thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
DescriptionList.h
1 // -*- C++ -*-
2 //
3 // DescriptionList.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_DescriptionList_H
10 #define ThePEG_DescriptionList_H
11 // This is the declaration of the DescriptionList class.
12 
13 #include "ThePEG/Config/ThePEG.h"
14 #include "ClassDescription.fh"
15 
16 namespace ThePEG {
17 
23 
24 public:
25 
26 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG
27 
28  typedef map<const type_info *, ClassDescriptionBase *> DescriptionMap;
29 #else
30 
31  typedef map<string, ClassDescriptionBase *> DescriptionMap;
32 #endif
33 
36  typedef map<string, ClassDescriptionBase *> StringMap;
37 
38 public:
39 
43  static void Register(ClassDescriptionBase &);
44 
48  static inline const ClassDescriptionBase * find(const type_info & ti) {
49 #ifndef THEPEG_DYNAMIC_TYPE_INFO_BUG
50  DescriptionMap::const_iterator it = descriptionMap().find(&ti);
51 #else
52  DescriptionMap::const_iterator it = descriptionMap().find(ti.name());
53 #endif
54  if ( it == descriptionMap().end() ) return 0;
55  return (*it).second;
56  }
57 
61  static string className(const type_info & ti);
62 
66  static int version(const type_info & ti);
67 
72  static string library(const type_info & ti);
73 
77  static inline const ClassDescriptionBase * find(const string & name) {
78  StringMap::const_iterator it = stringMap().find(name);
79  if ( it == stringMap().end() ) return 0;
80  return it->second;
81  }
82 
87  static inline const DescriptionMap & all() { return descriptionMap(); }
88 
93  static void printHierarchies(ostream & os);
94 
95 protected:
96 
100  static void hookup();
101 
105  static void insert(ClassDescriptionBase & pb);
106 
112  static DescriptionMap & descriptionMap();
113 
119  static StringMap & stringMap();
120 
121 };
122 
123 }
124 
125 #endif /* ThePEG_DescriptionList_H */
static DescriptionMap & descriptionMap()
Return the static set of descriptions mapped to the relevant type_info objects.
ClassDescriptionBase is the base class for all class description classes.
static void printHierarchies(ostream &os)
Print the classes in the list and their base classes to a stream.
static const ClassDescriptionBase * find(const type_info &ti)
Get the description of a class giving its type_info object.
static void Register(ClassDescriptionBase &)
Insert a description in the list.
static string library(const type_info &ti)
Return the dynamic library of the class corresponding to the given type_info object.
static void hookup()
Hookup the base class descriptions in the list.
map< string, ClassDescriptionBase * > StringMap
Map of class descriptions indexed by platform-independent class names.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
This is the main config header file for ThePEG.
static const ClassDescriptionBase * find(const string &name)
Get the description of a class giving its name.
static int version(const type_info &ti)
Return the version of the class corresponding to the given type_info object.
map< const type_info *, ClassDescriptionBase * > DescriptionMap
Map of class descriptions indexed by type_info objects.
The DescriptionList keeps a static list of descriptions of classes included in the current run...
static StringMap & stringMap()
Return the static set of descriptions mapped to the corresponding class names.
static void insert(ClassDescriptionBase &pb)
Insert a class description.
static const DescriptionMap & all()
Return the static set of descriptions mapped to the relevant type_info objects.
static string className(const type_info &ti)
Return the name of the class corresponding to the given type_info object.