/usr/include/ThePEG/Utilities/DescribeClass.h is in libthepeg-dev 1.8.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | // -*- C++ -*-
//
// DescribeClass.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_DescribeClass_H
#define ThePEG_DescribeClass_H
#include "ThePEG/Utilities/ClassDescription.h"
namespace ThePEG {
/**
* Helper class for multiple base classes. If a class to be described
* by DescribeClass has multiple base classes, B1 and B2, they should
* be encoded by BaseClasses<B1,B2>. This can be done for up to four
* base classes.
*/
template <typename BaseT1, typename BaseT2 = int,
typename BaseT3 = int, typename BaseT4 = int>
struct BaseClasses {};
/**
* Traits class used by DescribeCLassT for transparent handling of one
* base class or a several base classes encoded by BaseClasses.
*/
template <typename T>
struct BaseClassesTraits {
/** The first base class */
typedef T Base1;
/** The second base class */
typedef int Base2;
/** The third base class */
typedef int Base3;
/** The fourth base class */
typedef int Base4;
};
/**
* Traits class used by DescribeCLassT for transparent handling of one
* base class or a several base classes encoded by BaseClasses.
*/
template <typename BaseT1, typename BaseT2, typename BaseT3, typename BaseT4>
struct BaseClassesTraits< BaseClasses<BaseT1,BaseT2,BaseT3,BaseT4> > {
/** The first base class */
typedef BaseT1 Base1;
/** The second base class */
typedef BaseT2 Base2;
/** The third base class */
typedef BaseT3 Base3;
/** The fourth base class */
typedef BaseT4 Base4;
};
/**
* Helper class used by DescribeClassT for transparent handling of
* classes with and without persistent I/O functions.
*/
template <typename T, bool NoPIO>
struct DescribeClassPIOHelper {
/**
* Call standard output function.
*/
static void output(const T & t, PersistentOStream & os) {
t.persistentOutput(os);
}
/**
* Call standard input function.
*/
static void input(T & t, PersistentIStream & is, int oldVersion) {
t.persistentInput(is, oldVersion);
}
};
/**
* Helper class used by DescribeClassT for transparent handling of
* classes with and without persistent I/O functions.
*/
template <typename T>
struct DescribeClassPIOHelper<T,true> {
/**
* Do nothing as T has no persistent I/O functions.
*/
static void output(const T &, PersistentOStream &) {}
/**
* Do nothing as T has no persistent I/O functions.
*/
static void input(T &, PersistentIStream &, int) {}
};
/**
* Helper class used by DescribeClassT for transparent handling of
* abstract and concrete classes.
*/
template <typename T, bool abstract>
struct DescribeClassAbstractHelper {
/**
* Default-creat an object.
*/
static typename ThePEG::Ptr<T>::pointer create() {
return new_ptr(T());
}
};
/**
* Helper class used y DescribeClassT for transparent handling of
* abstract and concrete classes.
*/
template <typename T>
struct DescribeClassAbstractHelper<T,true> {
/**
* Throw an exception as the class is bastract.
*/
static typename ThePEG::Ptr<T>::pointer create() {
throw std::logic_error("Tried to instantiate abstract class " +
ClassTraits<T>::className());
}
};
/**
* DescribeClassT and its derived companion classes DescribeClass
* DescribeAbstractClass, DescribeNoPIOClass and
* DescribeAbstractNoPIOClass, is a simplified interface to the type
* information system in ThePEG. For simple classes there is no need
* to specialize the ClassTraits and BaseClassTrait classes and to
* have a static member variable of ClassDescription in the class (as
* in the full ThePEG type info system). Instead it is enough to have
* one statically initialized variable of one of the DescraibeClass
* classes for each class. The Abstract and NoPIO versions of this
* class should be used for abstract classes and classes without
* persistent I/O functions respectively.
*/
template <typename T, typename BaseT, bool Abstract = false, bool NoPIO = false>
class DescribeClassT: public ClassDescriptionBase {
public:
ThePEG_DECLARE_TEMPLATE_POINTERS(T,TPtr);
ThePEG_DECLARE_POINTERS(Base,BPtr);
/**
* Constructor taking the name of the class, the dynamic library
* where it is located and an optional version number as argument.
*/
DescribeClassT(string cname, string lib, int vers = 0)
: ClassDescriptionBase(cname, typeid(T), vers, lib, Abstract) {
DescriptionList::Register(*this);
T::Init();
}
/**
* The descructor.
*/
virtual ~DescribeClassT() {}
/**
* Set up the base class information for this object.
*/
virtual void setup() {
DescriptionVector bases;
const ClassDescriptionBase * b =
DescriptionList::find(typeid(typename BaseClassesTraits<BaseT>::Base1));
if ( b ) bases.push_back(b);
b = DescriptionList::find(typeid(typename BaseClassesTraits<BaseT>::Base2));
if ( b ) bases.push_back(b);
b = DescriptionList::find(typeid(typename BaseClassesTraits<BaseT>::Base3));
if ( b ) bases.push_back(b);
b = DescriptionList::find(typeid(typename BaseClassesTraits<BaseT>::Base4));
if ( b ) bases.push_back(b);
baseClasses(bases.begin(), bases.end());
}
/**
* Default-create an object.
*/
virtual BPtr create() const {
return DescribeClassAbstractHelper<T,Abstract>::create();
}
/**
* Call standard output function.
*/
virtual void output(tcBPtr o, PersistentOStream & os) const {
tcTPtr t = dynamic_ptr_cast<tcTPtr>(o);
DescribeClassPIOHelper<T,NoPIO>::output(*t, os);
}
/**
* Call standard input function.
*/
virtual void input(tBPtr o, PersistentIStream & is, int oldVersion) const {
tTPtr t = dynamic_ptr_cast<tTPtr>(o);
DescribeClassPIOHelper<T,NoPIO>::input(*t, is, oldVersion);
}
};
/**
* DescribeClass and its companion classes DescribeAbstractClass,
* DescribeNoPIOClass and DescribeAbstractNoPIOClass, is a simplified
* interface to type information system in ThePEG. For simple classes
* there is no need to specialize the ClassTraits and BaseClassTrait
* classes and to have a static member variable of ClassDescription in
* the class (as in the full ThePEG type info system). Instead it is
* enough to have one statically initialized variable of one of the
* DescraibeClass classes for each class. The Abstract and NoPIO
* versions of this class may be used for abstract classes and
* classes without persistent I/O functions respectively.
*
* The template arguments are as follows:
* T : the class being described.
* BaseT : The base class of T. If several base classes these should be
* encoded s template arguments to the BaseClasses class
* (at most four base classes can be encoded).
* Abstract: shoule be set to true if class T is abstract.
* NoPIO : shoule be set to true if class T does not persistent I/O functions.
*/
template <typename T, typename BaseT = int,
bool Abstract = false, bool NoPIO = false>
class DescribeClass: public DescribeClassT<T,BaseT,Abstract,NoPIO> {
public:
/**
* Constructor taking the name of the class, the dynamic library
* where it is located and an optional version number as argument.
*/
DescribeClass(string cname, string lib, int vers = 0)
: DescribeClassT<T,BaseT,Abstract,NoPIO>(cname, lib, vers) {}
};
/**
* DescribeClass and its companion classes DescribeAbstractClass,
* DescribeNoPIOClass and DescribeAbstractNoPIOClass, is a simplified
* interface to type information system in ThePEG. For simple classes
* there is no need to specialize the ClassTraits and BaseClassTrait
* classes and to have a static member variable of ClassDescription in
* the class (as in the full ThePEG type info system). Instead it is
* enough to have one statically initialized variable of one of the
* DescraibeClass classes for each class. The Abstract and NoPIO
* versions of this class may be used for abstract classes and
* classes without persistent I/O functions respectively.
*
* The template arguments are as follows:
* T : the class being described.
* BaseT : The base class of T. If several base classes these should be
* encoded s template arguments to the BaseClasses class
* (at most four base classes can be encoded).
*/
template <typename T, typename BaseT = int>
class DescribeNoPIOClass: public DescribeClassT<T,BaseT,false,true> {
public:
/**
* Constructor taking the name of the class, the dynamic library
* where it is located and an optional version number as argument.
*/
DescribeNoPIOClass(string cname, string lib, int vers = 0)
: DescribeClassT<T,BaseT,false,true>(cname, lib, vers) {}
};
/**
* DescribeClass and its companion classes DescribeAbstractClass,
* DescribeNoPIOClass and DescribeAbstractNoPIOClass, is a simplified
* interface to type information system in ThePEG. For simple classes
* there is no need to specialize the ClassTraits and BaseClassTrait
* classes and to have a static member variable of ClassDescription in
* the class (as in the full ThePEG type info system). Instead it is
* enough to have one statically initialized variable of one of the
* DescraibeClass classes for each class. The Abstract and NoPIO
* versions of this class may be used for abstract classes and
* classes without persistent I/O functions respectively.
*
* The template arguments are as follows:
* T : the class being described.
* BaseT : The base class of T. If several base classes these should be
* encoded s template arguments to the BaseClasses class
* (at most four base classes can be encoded).
*/
template <typename T, typename BaseT = int>
class DescribeAbstractClass: public DescribeClassT<T,BaseT,true,false> {
public:
/**
* Constructor taking the name of the class, the dynamic library
* where it is located and an optional version number as argument.
*/
DescribeAbstractClass(string cname, string lib, int vers = 0)
:DescribeClassT<T,BaseT,true,false>(cname, lib, vers) {}
};
/**
* DescribeClass and its companion classes DescribeAbstractClass,
* DescribeNoPIOClass and DescribeAbstractNoPIOClass, is a simplified
* interface to type information system in ThePEG. For simple classes
* there is no need to specialize the ClassTraits and BaseClassTrait
* classes and to have a static member variable of ClassDescription in
* the class (as in the full ThePEG type info system). Instead it is
* enough to have one statically initialized variable of one of the
* DescraibeClass classes for each class. The Abstract and NoPIO
* versions of this class may be used for abstract classes and
* classes without persistent I/O functions respectively.
*
* The template arguments are as follows:
* T : the class being described.
* BaseT : The base class of T. If several base classes these should be
* encoded s template arguments to the BaseClasses class
* (at most four base classes can be encoded).
*/
template <typename T, typename BaseT = int>
class DescribeAbstractNoPIOClass: public DescribeClassT<T,BaseT,true,true> {
public:
/**
* Constructor taking the name of the class, the dynamic library
* where it is located and an optional version number as argument.
*/
DescribeAbstractNoPIOClass(string cname, string lib, int vers = 0)
:DescribeClassT<T,BaseT,true,true>(cname, lib, vers) {}
};
}
#endif /* ThePEG_DescribeClass_H */
|