thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
TypeInfo.h
1 // -*- C++ -*-
2 //
3 // TypeInfo.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_TypeInfo_H
10 #define ThePEG_TypeInfo_H
11 
12 #include "DescriptionList.h"
13 
14 namespace ThePEG {
15 
19 struct TypeInfo {
20 
22  template <typename T>
23  static string name(const T &)
24  {
25  const ClassDescriptionBase * cd = DescriptionList::find(typeid(T));
26  if ( cd ) return cd->name();
27  return "**** CLASS NOT REGISTERED ****";
28  }
29 
31  template <typename T>
32  static int version(const T &)
33  {
34  const ClassDescriptionBase * cd = DescriptionList::find(typeid(T));
35  if ( cd ) return cd->version();
36  return -1;
37  }
38 
39 };
40 
41 }
42 
43 #endif /* ThePEG_TypeInfo_H */
ClassDescriptionBase is the base class for all class description classes.
static const ClassDescriptionBase * find(const type_info &ti)
Get the description of a class giving its type_info object.
TypeInfo is a simple wrapper around the ClassDescription system in ThePEG.
Definition: TypeInfo.h:19
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
static int version(const T &)
Return the version number of the class of the given object.
Definition: TypeInfo.h:32
int version() const
The version of the described class.
static string name(const T &)
Return the name of the class of the given object.
Definition: TypeInfo.h:23
const string & name() const
Return name.
Definition: Named.h:42