9 #ifndef ThePEG_ClassTraits_H
10 #define ThePEG_ClassTraits_H
15 #include "ThePEG/Config/ThePEG.h"
18 #include "ThePEG/Persistency/PersistentOStream.fh"
19 #include "ThePEG/Persistency/PersistentIStream.fh"
20 #include "DescriptionList.h"
93 t->persistentOutput(os);
100 t->persistentInput(is, oldVersion);
133 template <
typename T>
141 static string className() {
return "double"; }
155 template <
typename Derived,
int BaseN>
166 #define ThePEG_DECLARE_BASE_CLASS_TRAITS_1(Class,Base) \
170 struct BaseClassTrait<Class,1>: public ClassTraitsType { \
172 typedef Base NthBase; \
175 #define ThePEG_DECLARE_BASE_CLASS_TRAITS_2(Class,Base1,Base2) \
179 struct BaseClassTrait<Class,1>: public ClassTraitsType { \
181 typedef Base1 NthBase; \
186 struct BaseClassTrait<Class,2>: public ClassTraitsType { \
188 typedef Base2 NthBase; \
191 #define ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,Name,Lib) \
195 struct ClassTraits<Class>: \
196 public ClassTraitsBase<Class> { \
198 static string className() { return Name; } \
206 static string library() { return Lib; } \
211 #define ThePEG_DECLARE_CLASS_TRAITS(Class,Base) \
212 ThePEG_DECLARE_BASE_CLASS_TRAITS_1(Class,Base) \
213 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,"ThePEG::" #Class,"") \
215 #define ThePEG_DECLARE_DYNAMIC_CLASS_TRAITS(Class,Base,Lib) \
216 ThePEG_DECLARE_BASE_CLASS_TRAITS_1(Class,Base) \
217 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,"ThePEG::" #Class,Lib) \
219 #define ThePEG_DECLARE_CLASS_TRAITS_2(Class,Base1,Base2) \
220 ThePEG_DECLARE_BASE_CLASS_TRAITS_2(Class,Base1,Base2) \
221 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,"ThePEG/::" #Class,"") \
223 #define ThePEG_DECLARE_DYNAMIC_CLASS_TRAITS_2(Class,Base1,Base2,Lib) \
224 ThePEG_DECLARE_BASE_CLASS_TRAITS_2(Class,Base1,Base2) \
225 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,"ThePEG::" #Class,Lib) \
227 #define ThePEG_DECLARE_NAMED_CLASS_TRAITS(Class,Base,Name) \
228 ThePEG_DECLARE_BASE_CLASS_TRAITS_1(Class,Base) \
229 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,Name,"") \
231 #define ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS(Class,Base,Name,Lib) \
232 ThePEG_DECLARE_BASE_CLASS_TRAITS_1(Class,Base) \
233 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,Name,Lib) \
235 #define ThePEG_DECLARE_NAMED_CLASS_TRAITS_2(Class,Base1,Base2,Name) \
236 ThePEG_DECLARE_BASE_CLASS_TRAITS_2(Class,Base1,Base2) \
237 ThePEG_DECLARE_NAMED_DYNAMIC_CLASS_TRAITS_(Class,Name,"") \
PersistentIStream is used to read persistent objects from a stream where they were previously written...
static tcTPtr cast(tcBPtr b)
Perform a dynamic cast from the given transient const pointer to a transient pointer to const T...
Define the base class from which all (polymorphic) classes in ThePEG are derived. ...
ClassTraitsType is an empty, non-polymorphic, base class.
TraitsType is an empty, non-polymorphic, base class.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
static void output(tcTPtr t, PersistentOStream &os)
Write the T part of an object to a persistent stream.
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
static string library(const type_info &ti)
Return the dynamic library of the class corresponding to the given type_info object.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
ConstRCPtr is a reference counted (smart) const pointer.
T1 dynamic_ptr_cast(const T2 &t2)
Replacement for the standard dynamic_cast.
This is the main namespace within which all identifiers in ThePEG are declared.
static int version()
Return the version of class T.
#define ThePEG_DECLARE_TEMPLATE_POINTERS(full, abbrev)
This macro helps us to declare pointers and stuff to standard classes.
static TPtr cast(BPtr b)
Perform a dynamic cast from the given pointer to a pointer to T.
static int version(const type_info &ti)
Return the version of the class corresponding to the given type_info object.
static string library()
The name of a file containing the dynamic library where the class T is implemented.
RCPtr is a reference counted (smart) pointer.
#define ThePEG_DECLARE_POINTERS(full, abbrev)
This macro helps us to declare pointers and stuff to standard classes.
static void input(tTPtr t, PersistentIStream &is, int oldVersion)
Read the T part of an object from a persistent stream.
static TPtr create()
Create a T object and return a smart pointer to it.
The default concrete implementation of ClassTraitsBase.
static string className()
Return the name of class T.
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
static cTPtr cast(cBPtr b)
Perform a dynamic cast from the given const pointer to a pointer to const T.
BaseClassTraits describes the base classes of the templated class.
static tTPtr cast(tBPtr b)
Perform a dynamic cast from the given transient pointer to a transient pointer to T...
static RCPtr Create()
Allocate and construct an object of class T and return a RCPtr to it.
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
static string className(const type_info &ti)
Return the name of the class corresponding to the given type_info object.