The core simulate Machine engine. More...
#include <base.h>
Inherits noncopyable.
Public Types | |
typedef p_elements_t::iterator | iterator |
Beamline element iterator. | |
typedef p_elements_t::const_iterator | const_iterator |
Beamline element iterator (const version) | |
typedef value_proxy_iterator < p_lookup_t::iterator > | lookup_iterator |
iterator for use with equal_range() and equal_range_type() | |
Public Member Functions | |
Machine (const Config &c) | |
Construct a new Machine. More... | |
void | propagate (StateBase *S, size_t start=0, size_t max=-1) const |
Pass the given bunch State through this Machine. More... | |
StateBase * | allocState (const Config &c) const |
Allocate (with "operator new") an appropriate State object. More... | |
StateBase * | allocState () const |
const Config & | conf () const |
Fetch Config used to construct this Machine. | |
void | reconfigure (size_t idx, const Config &c) |
Change the configuration of a single element. More... | |
const std::string & | simtype () const |
Return the sim_type string found during construction. | |
std::ostream * | trace () const |
The current tracing stream, or NULL. | |
void | set_trace (std::ostream *v) |
Assign new tracing stream. More... | |
size_t | size () const |
ElementVoid * | operator[] (size_t i) |
Access a beamline element. | |
const ElementVoid * | operator[] (size_t i) const |
Access a beamline element. | |
ElementVoid * | at (size_t i) |
Access a beamline element. | |
const ElementVoid * | at (size_t i) const |
Access a beamline element. | |
iterator | begin () |
Points to the first element. | |
const_iterator | begin () const |
Points to the first element. | |
iterator | end () |
Points just after the last element. | |
const_iterator | end () const |
Points just after the last element. | |
ElementVoid * | find (const std::string &name, size_t nth=0) |
std::pair< lookup_iterator, lookup_iterator > | all_range () |
std::pair< lookup_iterator, lookup_iterator > | equal_range (const std::string &name) |
std::pair< lookup_iterator, lookup_iterator > | equal_range_type (const std::string &name) |
Static Public Member Functions | |
template<typename State > | |
static void | registerState (const char *name) |
Register a new State with the simulation framework. More... | |
template<typename Element > | |
static void | registerElement (const char *sname, const char *ename) |
Register a new Element type with the simulation framework. More... | |
static void | registeryCleanup () |
Discard all registered State and Element type information. More... | |
static void | set_logger (const boost::shared_ptr< Logger > &p) |
Static Public Attributes | |
static int | log_detail = FLAME_WARN |
Friends | |
std::ostream & | operator<< (std::ostream &, const Machine &m) |
The core simulate Machine engine.
Provides std::vector<ElementVoid*>-like access to individual elements
Machine::Machine | ( | const Config & | c | ) |
Construct a new Machine.
c | A Config instance, such as that returned by GLPSParser::parse_file(). |
Allocate (with "operator new") an appropriate State object.
c | Configuration describing the initial state |
std::exception | sub-classes for various errors, mostly incorrect Config. |
|
inline |
|
inline |
|
inline |
|
inline |
Find the nth element with the given name
void Machine::propagate | ( | StateBase * | S, |
size_t | start = 0 , |
||
size_t | max = -1 |
||
) | const |
Pass the given bunch State through this Machine.
S | The initial state, will be updated with the final state |
start | The index of the first Element the state will pass through |
max | The maximum number of elements through which the state will be passed |
std::exception | sub-classes for various errors. If an exception is thrown then the state of S is undefined. |
void Machine::reconfigure | ( | size_t | idx, |
const Config & | c | ||
) |
|
inlinestatic |
Register a new Element type with the simulation framework.
Add a new element to an existing sim_type (see registerState()).
sname | A sim_type name |
ename | The new element type name |
std::logic_error | if sname has not been registered, or if ename is already registered |
|
inlinestatic |
Register a new State with the simulation framework.
The first step to adding a new sim_type.
name | The new sim_type name |
std::logic_error | if name is already registered |
|
static |
Discard all registered State and Element type information.
Clears all previous registerations made by registerState() and registerElement().
Suggested use case is to call just before process exit so that valgrind doesn't flag these as leaks
|
inline |
Assign new tracing stream.
v | new stream or NULL to clear |
The trace stream will be written to during Machine::propagate() as a debugging aid.
|
inline |