thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Interface
InterfacedBase.h
1
// -*- C++ -*-
2
//
3
// InterfacedBase.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_InterfacedBase_H
10
#define ThePEG_InterfacedBase_H
11
// This is the declaration of the InterfacedBase class.
12
13
#include "
ThePEG/Config/ThePEG.h
"
14
#include "ThePEG/Utilities/Named.h"
15
#include "ThePEG/Utilities/ClassDescription.h"
16
#include "ThePEG/Utilities/HoldFlag.h"
17
#include "InterfacedBase.xh"
18
19
namespace
ThePEG
{
20
45
class
InterfacedBase
:
public
PersistentBase
,
public
Named
{
46
48
friend
class
BaseRepository
;
49
51
friend
class
InterfaceBase
;
52
54
friend
class
EventGenerator
;
55
56
public
:
57
61
enum
InitState
{
62
initializing
= -1,
66
uninitialized
= 0,
67
initialized
= 1,
68
runready
= 2
70
};
71
72
public
:
73
77
virtual
~InterfacedBase
();
78
83
string
fullName
()
const
{
return
Named::name
(); }
84
88
string
name
()
const
{
89
return
Named::name
().substr(
Named::name
().rfind(
'/'
)+1);
90
}
91
96
string
path
()
const
{
97
string::size_type slash =
Named::name
().rfind(
'/'
);
98
string
ret;
99
if
( slash != string::npos ) ret =
Named::name
().substr(0,slash);
100
return
ret;
101
}
102
106
string
comment
()
const
{
return
theComment
; }
107
115
void
setup
(istream & is) {
116
readSetup
(is);
117
getline(is,
theComment
);
118
}
119
120
protected
:
121
132
virtual
void
readSetup
(istream & is);
133
156
virtual
void
doupdate
() {}
157
179
virtual
void
doinit
() {}
180
196
virtual
void
doinitrun
() {}
197
208
virtual
void
dofinish
() {}
209
215
virtual
IVector
getReferences
() {
return
IVector
(); }
216
224
virtual
void
rebind
(
const
TranslationMap
&) {}
226
227
public
:
228
234
void
update
() {
235
if
(
initState
)
return
;
236
HoldFlag<InitState>
hold(
initState
,
initializing
,
initialized
);
237
doupdate
();
238
}
239
243
void
init
() {
244
if
(
initState
)
return
;
245
HoldFlag<InitState>
hold(
initState
,
initializing
,
initialized
);
246
doinit
();
247
}
248
255
virtual
bool
preInitialize
()
const
;
256
260
void
initrun
() {
261
if
(
initState
==
runready
||
initState
==
initializing
)
return
;
262
HoldFlag<InitState>
hold(
initState
,
initializing
,
runready
);
263
doinitrun
();
264
}
265
269
void
finish
() {
270
if
(
initState
==
uninitialized
||
initState
==
initializing
)
return
;
271
HoldFlag<InitState>
hold(
initState
,
initializing
,
uninitialized
);
272
dofinish
();
273
}
274
280
void
touch
() {
isTouched
=
true
; }
281
285
void
reset
() {
initState
=
uninitialized
; }
286
290
void
clear
() {
291
reset
();
292
untouch
();
293
}
294
298
InitState
state
()
const
{
return
initState
; }
299
304
bool
locked
()
const
{
return
isLocked
; }
305
310
bool
touched
()
const
{
return
isTouched
; }
312
317
virtual
IBPtr
fullclone
()
const
{
return
clone
(); }
318
325
void
persistentOutput
(
PersistentOStream
& os)
const
;
326
332
void
persistentInput
(
PersistentIStream
& is,
int
version);
334
338
static
void
Init
();
339
340
protected
:
341
346
virtual
IBPtr
clone
()
const
= 0;
347
351
InterfacedBase
()
352
:
Named
(
""
),
isLocked
(false),
isTouched
(true),
353
initState
(
uninitialized
) {}
354
358
InterfacedBase
(
string
newName)
359
:
Named
(newName),
isLocked
(false),
isTouched
(true),
360
initState
(
uninitialized
) {}
361
365
InterfacedBase
(
const
InterfacedBase
& i)
366
:
Base
(i),
Named
(i),
isLocked
(false),
isTouched
(true),
367
initState
(
uninitialized
),
theComment
(i.
theComment
),
368
objectDefaults
(i.
objectDefaults
) {}
369
370
private
:
371
375
void
name
(
string
newName) {
Named::name
(newName); }
376
380
void
lock
() {
isLocked
=
true
; }
381
385
void
unlock
() {
isLocked
=
false
; }
386
390
void
untouch
() {
isTouched
=
false
; }
391
392
private
:
393
397
string
addComment
(
string
);
398
399
private
:
400
404
bool
isLocked
;
405
410
bool
isTouched
;
411
416
InitState
initState
;
417
421
string
theComment
;
422
426
map<string,string>
objectDefaults
;
427
428
public
:
429
434
virtual
void
debugme
()
const
;
435
436
private
:
437
441
static
AbstractClassDescription<InterfacedBase>
initInterfacedBase
;
442
446
InterfacedBase
&
operator=
(
const
InterfacedBase
&) =
delete
;
447
448
protected
:
449
453
struct
UpdateChecker
{
455
UpdateChecker
(
bool
&
touched
) :
isTouched
(
touched
) {}
457
UpdateChecker
(
const
UpdateChecker
& uc) :
isTouched
(uc.
isTouched
) {}
459
static
void
check
(
tIBPtr
,
bool
&);
461
template
<
typename
ptr>
void
operator()
(
const
ptr & i) {
462
check
(i,
isTouched
);
463
}
465
bool
&
isTouched
;
466
};
467
471
struct
UpdateMapChecker
{
473
UpdateMapChecker
(
bool
&
touched
) :
isTouched
(
touched
) {}
475
UpdateMapChecker
(
const
UpdateMapChecker
& uc) :
isTouched
(uc.
isTouched
) {}
477
template
<
typename
ref>
void
operator()
(
const
ref & i) {
478
UpdateChecker::check
(i.second,
isTouched
);
479
}
481
bool
&
isTouched
;
482
};
483
484
};
485
492
template
<>
493
struct
BaseClassTrait
<
InterfacedBase
,1>:
public
ClassTraitsType
{
495
typedef
PersistentBase
NthBase
;
496
};
497
502
template
<>
503
struct
ClassTraits<InterfacedBase>:
public
ClassTraitsBase<InterfacedBase> {
505
static
string
className
() {
return
"ThePEG::InterfacedBase"
; }
506
};
507
510
}
511
512
#endif
/* ThePEG_InterfacedBase_H */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::AbstractClassDescription
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data.
Definition:
ClassDescription.h:282
ThePEG::BaseRepository
BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their ...
Definition:
BaseRepository.h:45
ThePEG::EventGenerator
The EventGenerator class manages a whole event generator run.
Definition:
EventGenerator.h:68
ThePEG::HoldFlag
HoldFlag objects are used to temporarily change the value of an object, restoring the original value ...
Definition:
HoldFlag.h:23
ThePEG::InterfaceBase
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition:
InterfaceBase.h:59
ThePEG::InterfacedBase
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
Definition:
InterfacedBase.h:45
ThePEG::InterfacedBase::dofinish
virtual void dofinish()
Finalize this object.
Definition:
InterfacedBase.h:208
ThePEG::InterfacedBase::~InterfacedBase
virtual ~InterfacedBase()
The virtual (empty) destructor;.
ThePEG::InterfacedBase::doinit
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
Definition:
InterfacedBase.h:179
ThePEG::InterfacedBase::touched
bool touched() const
Return true if the state of this object has been changed since the last call to update().
Definition:
InterfacedBase.h:310
ThePEG::InterfacedBase::setup
void setup(istream &is)
Read setup info from a standard istream is.
Definition:
InterfacedBase.h:115
ThePEG::InterfacedBase::clone
virtual IBPtr clone() const =0
Return a simple clone of this object.
ThePEG::InterfacedBase::clear
void clear()
Calls reset() and unTouch().
Definition:
InterfacedBase.h:290
ThePEG::InterfacedBase::InitState
InitState
Enumeration reflecting the state of an InterfacedBase object.
Definition:
InterfacedBase.h:61
ThePEG::InterfacedBase::initialized
@ initialized
The object has been initialized.
Definition:
InterfacedBase.h:67
ThePEG::InterfacedBase::uninitialized
@ uninitialized
The object has not been initialized.
Definition:
InterfacedBase.h:66
ThePEG::InterfacedBase::runready
@ runready
The object is initialized and the initrun() method has been called.
Definition:
InterfacedBase.h:68
ThePEG::InterfacedBase::initializing
@ initializing
The object is currently being initialized.
Definition:
InterfacedBase.h:62
ThePEG::InterfacedBase::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
ThePEG::InterfacedBase::InterfacedBase
InterfacedBase(string newName)
Protected constructor with the name given as argument.
Definition:
InterfacedBase.h:358
ThePEG::InterfacedBase::fullclone
virtual IBPtr fullclone() const
Return a full clone of this object possibly doing things to the clone to make it sane.
Definition:
InterfacedBase.h:317
ThePEG::InterfacedBase::Init
static void Init()
Standard Init function.
ThePEG::InterfacedBase::state
InitState state() const
Return the state of initialization of this object.
Definition:
InterfacedBase.h:298
ThePEG::InterfacedBase::initState
InitState initState
Indicate if this object has been initialized or not, or if it is being initialized.
Definition:
InterfacedBase.h:416
ThePEG::InterfacedBase::initrun
void initrun()
Calls the doinitrun() function with recursion prevention.
Definition:
InterfacedBase.h:260
ThePEG::InterfacedBase::isTouched
bool isTouched
True if this object has been chaged since the last call to update().
Definition:
InterfacedBase.h:410
ThePEG::InterfacedBase::preInitialize
virtual bool preInitialize() const
Return true if this object needs to be initialized before all other objects (except those for which t...
ThePEG::InterfacedBase::initInterfacedBase
static AbstractClassDescription< InterfacedBase > initInterfacedBase
Standard Initialization object.
Definition:
InterfacedBase.h:441
ThePEG::InterfacedBase::name
string name() const
Returns the name of this object, without the path.
Definition:
InterfacedBase.h:88
ThePEG::InterfacedBase::addComment
string addComment(string)
Used by the interface to add comments.
ThePEG::InterfacedBase::theComment
string theComment
A comment assigned to this object.
Definition:
InterfacedBase.h:421
ThePEG::InterfacedBase::rebind
virtual void rebind(const TranslationMap &)
Rebind pointer to other Interfaced objects.
Definition:
InterfacedBase.h:224
ThePEG::InterfacedBase::InterfacedBase
InterfacedBase()
Protected default constructor.
Definition:
InterfacedBase.h:351
ThePEG::InterfacedBase::name
void name(string newName)
Set a new name (full name including path).
Definition:
InterfacedBase.h:375
ThePEG::InterfacedBase::reset
void reset()
Set the state of this object to uninitialized.
Definition:
InterfacedBase.h:285
ThePEG::InterfacedBase::doupdate
virtual void doupdate()
Check sanity of the object during the setup phase.
Definition:
InterfacedBase.h:156
ThePEG::InterfacedBase::objectDefaults
map< string, string > objectDefaults
A map listing object-specific defaults set for the given interfaces.
Definition:
InterfacedBase.h:426
ThePEG::InterfacedBase::untouch
void untouch()
Clear the isTouched flag.
Definition:
InterfacedBase.h:390
ThePEG::InterfacedBase::touch
void touch()
This function should be called every time something in this object has changed in a way that a sanity...
Definition:
InterfacedBase.h:280
ThePEG::InterfacedBase::lock
void lock()
Lock this object.
Definition:
InterfacedBase.h:380
ThePEG::InterfacedBase::init
void init()
Calls the doinit() function with recursion prevention.
Definition:
InterfacedBase.h:243
ThePEG::InterfacedBase::readSetup
virtual void readSetup(istream &is)
Read setup info from a standard istream is.
ThePEG::InterfacedBase::path
string path() const
Returns the path to this object including the trailing '/'.
Definition:
InterfacedBase.h:96
ThePEG::InterfacedBase::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
ThePEG::InterfacedBase::locked
bool locked() const
Return true if the BaseRepository is not allowed to change the state of this object.
Definition:
InterfacedBase.h:304
ThePEG::InterfacedBase::InterfacedBase
InterfacedBase(const InterfacedBase &i)
Protected copy-constructor.
Definition:
InterfacedBase.h:365
ThePEG::InterfacedBase::update
void update()
Calls the doupdate() function with recursion prevention.
Definition:
InterfacedBase.h:234
ThePEG::InterfacedBase::unlock
void unlock()
Unlock this object.
Definition:
InterfacedBase.h:385
ThePEG::InterfacedBase::comment
string comment() const
Returns a comment assigned to this object.
Definition:
InterfacedBase.h:106
ThePEG::InterfacedBase::getReferences
virtual IVector getReferences()
Return a vector of all pointers to Interfaced objects used in this object.
Definition:
InterfacedBase.h:215
ThePEG::InterfacedBase::operator=
InterfacedBase & operator=(const InterfacedBase &)=delete
Private and non-existent assignment operator.
ThePEG::InterfacedBase::fullName
string fullName() const
Returns the full name of this object including its path, e.g.
Definition:
InterfacedBase.h:83
ThePEG::InterfacedBase::isLocked
bool isLocked
True if this object is not to be changed by the user interface.
Definition:
InterfacedBase.h:404
ThePEG::InterfacedBase::debugme
virtual void debugme() const
Print out debugging information for this object on std::cerr.
ThePEG::InterfacedBase::doinitrun
virtual void doinitrun()
Initialize this object.
Definition:
InterfacedBase.h:196
ThePEG::InterfacedBase::finish
void finish()
Calls the dofinish() function with recursion prevention.
Definition:
InterfacedBase.h:269
ThePEG::Named
The Named class is a simple concrete base class to used by classes of objects with a name.
Definition:
Named.h:24
ThePEG::Named::name
const string & name() const
Return name.
Definition:
Named.h:42
ThePEG::PersistentIStream
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Definition:
PersistentIStream.h:48
ThePEG::PersistentOStream
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
Definition:
PersistentOStream.h:51
ThePEG::Pointer::RCPtr
RCPtr is a reference counted (smart) pointer.
Definition:
RCPtr.h:60
ThePEG::Pointer::TransientRCPtr
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition:
RCPtr.h:519
ThePEG::Rebinder
Rebinder is a class associating pairs of pointers to objects.
Definition:
Rebinder.h:27
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::IVector
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition:
Containers.h:67
ThePEG::BaseClassTrait
BaseClassTraits describes the base classes of the templated class.
Definition:
ClassTraits.h:156
ThePEG::BaseClassTrait::NthBase
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition:
ClassTraits.h:161
ThePEG::Base
Define the base class from which all (polymorphic) classes in ThePEG are derived.
Definition:
ThePEG.h:54
ThePEG::ClassTraitsBase::className
static string className()
Return the name of class T.
Definition:
ClassTraits.h:66
ThePEG::ClassTraitsType
ClassTraitsType is an empty, non-polymorphic, base class.
Definition:
ClassTraits.h:30
ThePEG::InterfacedBase::UpdateChecker
Functor class to be used to update a range of dependent object.
Definition:
InterfacedBase.h:453
ThePEG::InterfacedBase::UpdateChecker::UpdateChecker
UpdateChecker(bool &touched)
Constructor.
Definition:
InterfacedBase.h:455
ThePEG::InterfacedBase::UpdateChecker::check
static void check(tIBPtr, bool &)
Call the check function for an object.
ThePEG::InterfacedBase::UpdateChecker::UpdateChecker
UpdateChecker(const UpdateChecker &uc)
Constructor.
Definition:
InterfacedBase.h:457
ThePEG::InterfacedBase::UpdateChecker::operator()
void operator()(const ptr &i)
Function call operator.
Definition:
InterfacedBase.h:461
ThePEG::InterfacedBase::UpdateChecker::isTouched
bool & isTouched
set to false if any check() call fails.
Definition:
InterfacedBase.h:465
ThePEG::InterfacedBase::UpdateMapChecker
Functor class to be used to update a range of dependent object in a map.
Definition:
InterfacedBase.h:471
ThePEG::InterfacedBase::UpdateMapChecker::isTouched
bool & isTouched
Reference to the bool variable to be set.
Definition:
InterfacedBase.h:481
ThePEG::InterfacedBase::UpdateMapChecker::UpdateMapChecker
UpdateMapChecker(const UpdateMapChecker &uc)
Constructor.
Definition:
InterfacedBase.h:475
ThePEG::InterfacedBase::UpdateMapChecker::UpdateMapChecker
UpdateMapChecker(bool &touched)
Constructor.
Definition:
InterfacedBase.h:473
ThePEG::InterfacedBase::UpdateMapChecker::operator()
void operator()(const ref &i)
Function call operator.
Definition:
InterfacedBase.h:477
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6