ThePEG  1.8.0
TypeInfo.h
1 // -*- C++ -*-
2 //
3 // TypeInfo.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 */