thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Interfaced.h
1// -*- C++ -*-
2//
3// Interfaced.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_Interfaced_H
10#define ThePEG_Interfaced_H
11// This is the declaration of the Interfaced class.
12
14#include "InterfacedBase.h"
15#include "ThePEG/PDT/PID.h"
16
17namespace ThePEG {
18
39
41 friend class Repository;
42
44 friend class EventGenerator;
45
46public:
47
51 virtual ~Interfaced();
52
57public:
58
68 virtual bool defaultInit();
69
77
83
87 bool used() const { return theUseFlag; }
88
93 void useMe() const { if ( !used() ) setUsed(); }
94
99 tEGPtr generator() const { return theGenerator; }
101
102public:
103
111
117 void persistentInput(PersistentIStream & is, int version);
119
123 static void Init();
124
125protected:
126
131
136 static void registerRepository(IBPtr, string newName);
137
145 void reporeg(IBPtr object, string name) const;
146
153 template <typename PtrT>
154 bool setDefaultReference(PtrT & ptr, string classname, string objectname) {
155 if ( ptr ) return true;
156 const ClassDescriptionBase * db = DescriptionList::find(classname);
157 if ( !db ) return false;
158 ptr = dynamic_ptr_cast<PtrT>(db->create());
159 if ( !ptr ) return false;
160 reporeg(ptr, objectname);
161 if ( !ptr->defaultInit() ) return false;
162 return true;
163 }
164
168 Interfaced() : theUseFlag(false) {}
169
173 Interfaced(const string & newName)
174 : InterfacedBase(newName), theUseFlag(false) {}
175
181
182protected:
183
189
190private:
191
195 void setUsed() const;
196
201
205 mutable bool theUseFlag;
206
210 string doDefaultInit(string);
211
212private:
213
218
222 Interfaced & operator=(const Interfaced &) = delete;
223
224};
225
232template <>
233struct BaseClassTrait<Interfaced,1>: public ClassTraitsType {
235 typedef InterfacedBase NthBase;
236};
237
242template <>
243struct ClassTraits<Interfaced>: public ClassTraitsBase<Interfaced> {
245 static string className() { return "ThePEG::Interfaced"; }
246};
247
250}
251
252#endif /* ThePEG_Interfaced_H */
This is the main config header file for ThePEG.
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data.
ClassDescriptionBase is the base class for all class description classes.
virtual BPtr create() const =0
Create an object of the described class.
static const ClassDescriptionBase * find(const type_info &ti)
Get the description of a class giving its type_info object.
The EventGenerator class manages a whole event generator run.
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
string name() const
Returns the name of this object, without the path.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
void useMe() const
Should be called to indicate that this object has actually been used.
Definition: Interfaced.h:93
static AbstractClassDescription< Interfaced > initInterfaced
Standard Initialization object.
Definition: Interfaced.h:217
bool used() const
Returns true if this object has actally been used.
Definition: Interfaced.h:87
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
void reporeg(IBPtr object, string name) const
Register the given object in the Repository with the given name in a subdirectory with the same name ...
Interfaced(const Interfaced &i)
Protected copy-constructor.
Definition: Interfaced.h:179
PDPtr getParticleData(PID) const
Return a pointer to the ParticleData object corresponding to the given id number.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
Interfaced(const string &newName)
Protected constructor taking a name as argument.
Definition: Interfaced.h:173
Interfaced()
Protected default constructor.
Definition: Interfaced.h:168
bool theUseFlag
Flag to tell whether this object has been used or not.
Definition: Interfaced.h:205
static void registerRepository(IBPtr, string newName)
Register an Interfaced object with the Repository, giving it a name.
virtual ~Interfaced()
Empty virtual destructor.
static void Init()
Standard Init function.
tEGPtr theGenerator
A pointer to the EventGenerator controlling the run.
Definition: Interfaced.h:200
PPtr getParticle(PID) const
Create a new Particle instance given a id number.
void setUsed() const
Used internally by 'useMe'.
static void registerRepository(IBPtr)
Register an Interfaced object with the Repository.
string doDefaultInit(string)
Command interface function which calls defaultInit().
virtual bool defaultInit()
Functions which are to be used during the actual event generation, after the setup is complete.
bool setDefaultReference(PtrT &ptr, string classname, string objectname)
If the pointer, ptr, to an object is not set, create an object of class classname and register it wit...
Definition: Interfaced.h:154
void setGenerator(tEGPtr generator)
Protected function to reset the generator pointer, required for automatic decayer generation in Herwi...
Definition: Interfaced.h:188
Interfaced & operator=(const Interfaced &)=delete
Private and non-existent assignment operator.
tEGPtr generator() const
Return a pointer to the EventGenerator controlling the run.
Definition: Interfaced.h:99
PID is a helper class implementing the type of PDG particle ids.
Definition: PID.h:23
PersistentIStream is used to read persistent objects from a stream where they were previously written...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
Repository inherits from the BaseRepository class.
Definition: Repository.h:45
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30