thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
Repository.h
1 // -*- C++ -*-
2 //
3 // Repository.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_Repository_H
10 #define ThePEG_Repository_H
11 // This is the declaration of the Repository class.
12 
13 #include "ThePEG/Config/ThePEG.h"
14 #include "BaseRepository.h"
15 #include "EventGenerator.h"
16 #include "ThePEG/PDT/ParticleData.h"
17 #include "ThePEG/PDT/MatcherBase.h"
18 
19 namespace ThePEG {
20 
45 class Repository: public BaseRepository {
46 
47 public:
48 
50  typedef map<string,EGPtr> GeneratorMap;
51 
52 public:
53 
59  Repository();
60 
65  ~Repository();
66 
67 public:
68 
76  static void Register(IBPtr);
77 
83  static void Register(IBPtr, string newName);
85 
94  static void defaultParticle(tPDPtr);
95 
100  static PDPtr defaultParticle(PID id);
101 
109  static tPDPtr findParticle(string name);
110 
114  static const ParticleDataSet & allParticles() { return particles(); }
115 
119  static const MatcherSet & allMatchers() { return matchers(); }
120 
124  static tPMPtr findMatcher(string name);
125 
131  static string copyParticle(tPDPtr, string);
133 
140  static EGPtr makeRun(tEGPtr eg, string name);
141 
146  static void saveRun(string EGname, string name, string filename);
148 
156  static string load(string filename);
157 
161  static void save(string filename);
162 
166  static void save() { save(currentFileName()); }
167 
171  static void stats(ostream &);
173 
179  static void help(string command, ostream & os);
180 
185  static void remove(tIBPtr);
186 
193  static string remove(const ObjectSet & rmset);
194 
203  static void read(istream & is, ostream & os, string prompt = "");
204 
216  static string read(string filename, ostream & os);
217 
224  static string exec(string cmd, ostream &);
225 
235  static string modifyEventGenerator(EventGenerator & eg, string filename,
236  ostream & os, bool initOnly = false);
237 
242  static void resetEventGenerator(EventGenerator & eg);
244 
248  static string version();
249 
253  static string banner();
254 
255 private:
256 
260  static void registerParticle(tPDPtr);
261 
265  static void registerMatcher(tPMPtr);
266 
270  static void execAndCheckReply(string, ostream &);
271 
272 protected:
273 
280  static ParticleMap & defaultParticles();
281 
285  static ParticleDataSet & particles();
286 
290  static MatcherSet & matchers();
291 
295  static GeneratorMap & generators();
296 
300  static string & currentFileName();
301 
302 public:
303 
308  static int & exitOnError();
309 
316  static void cleanup();
318 
319 private:
320 
325  Repository(const Repository &);
326 
331  Repository & operator=(const Repository &) = delete;
332 
336  static int ninstances;
337 
338 
339 };
340 
341 }
342 
343 #endif /* ThePEG_Repository_H */
Repository()
The default constructor is the only one that should be used.
PID is a helper class implementing the type of PDG particle ids.
Definition: PID.h:23
static void read(istream &is, ostream &os, string prompt="")
Read commands from a stream and send them one by one to exec().
static tPDPtr findParticle(string name)
Get a pointer to a particle based on the given path or name.
ThePEG::Ptr< InterfacedBase >::transient_pointer tIBPtr
Alias for a transient pointer to InterfacedBase .
Definition: Pointers.h:62
static int & exitOnError()
If non-zero the setup program will exit with this error code as soon as an error is encountered...
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
~Repository()
The destructor will do some clean-up when the last Repository is deleted.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
static void defaultParticle(tPDPtr)
Add a particle to the list of default ones.
This is the main config header file for ThePEG.
static string modifyEventGenerator(EventGenerator &eg, string filename, ostream &os, bool initOnly=false)
Insert the given EventGenerator and its dependent Interfaced objects into the repository and read com...
static GeneratorMap & generators()
All isolated generators mapped to their run name.
static string banner()
Return a string with a ThePEG banner.
static ParticleMap & defaultParticles()
The set of default particles.
static void cleanup()
Call this function to clean up the repository at the end of your program if you are using the static ...
static string version()
Return the version number of ThePEG.
static string load(string filename)
Load a whole repository from the given file.
static void registerMatcher(tPMPtr)
Used by Register.
static EGPtr makeRun(tEGPtr eg, string name)
Isolate an event generator, eg, and save it to disk in a file named name (with .run appended...
static const ParticleDataSet & allParticles()
Return the set of all particles in the repository.
Definition: Repository.h:114
static MatcherSet & matchers()
The set of all matchers.
static void Register(IBPtr)
Register an object with BaseRepository::Register() and add it to the list of particles or matchers if...
static const MatcherSet & allMatchers()
Return the set of all matchers in the repository.
Definition: Repository.h:119
BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their ...
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
static void save()
Save the repository to the default file.
Definition: Repository.h:166
static string & currentFileName()
The default file name used by save().
static string copyParticle(tPDPtr, string)
Special function for copying particles.
static void help(string command, ostream &os)
Print out a help message.
static tPMPtr findMatcher(string name)
Find a matcher with a given generic name.
static ParticleDataSet & particles()
The set of all particles.
static void resetEventGenerator(EventGenerator &eg)
Reset the given EventGenerator; equivalent to modifyEventGenerator without reading an input file...
static void stats(ostream &)
Write some statistics about the repository to the standard output.
static void registerParticle(tPDPtr)
Used by Register.
Repository & operator=(const Repository &)=delete
It makes no sense to copy a Repository, so this assignment is not implemented.
static string exec(string cmd, ostream &)
Interpret the command in cmd and return possible messages.
static void execAndCheckReply(string, ostream &)
Used by read()
map< string, EGPtr > GeneratorMap
A map of EventGenerator objects indexed by their run name.
Definition: Repository.h:50
static int ninstances
Count the number of repositorys instantiated.
Definition: Repository.h:336
The EventGenerator class manages a whole event generator run.
static void saveRun(string EGname, string name, string filename)
Isolate an event generatorn, named EGname, set its run name and save it to a file named filename...