FLAME  devel
 All Classes Functions Variables Typedefs Enumerations Pages
Classes | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
StateBase Struct Referenceabstract

The abstract base class for all simulation state objects. More...

#include <base.h>

Inheritance diagram for StateBase:
Inheritance graph
[legend]

Classes

struct  ArrayInfo
 Used with StateBase::getArray() to describe a single parameter. More...
 
struct  clone_tag
 Used with clone ctor. More...
 

Public Member Functions

virtual void assign (const StateBase &other)=0
 
virtual void show (std::ostream &, int level=0) const
 
virtual bool getArray (unsigned index, ArrayInfo &Info)
 Introspect named parameter of the derived class. More...
 
virtual StateBaseclone () const =0
 

Public Attributes

size_t next_elem
 
double pos
 absolute longitudinal position at end of Element
 

Protected Member Functions

 StateBase (const Config &c)
 
 StateBase (const StateBase &c, clone_tag)
 For use in clone()
 

Detailed Description

The abstract base class for all simulation state objects.

Represents the state of some bunch of particles moving through a Machine

Definition at line 28 of file base.h.

Constructor & Destructor Documentation

StateBase::StateBase ( const Config c)
protected

Construct a new state

By convention an empty Config() should be valid.

Definition at line 18 of file base.cpp.

Member Function Documentation

void StateBase::assign ( const StateBase other)
pure virtual

virtual equivalent to operator=() Should only be used with another State originating from the same Machine from Machine::allocState() or clone().

Implemented in MomentState, MatrixState, and VectorState.

Definition at line 30 of file base.cpp.

virtual StateBase* StateBase::clone ( ) const
pure virtual

Allocate a new instance which is a copy of this one. Caller is responsible to delete the returned pointer

Implemented in MomentState, MatrixState, and VectorState.

bool StateBase::getArray ( unsigned  index,
ArrayInfo Info 
)
virtual

Introspect named parameter of the derived class.

Parameters
idxThe index of the parameter
Infomailbox to be filled with information about this paramter
Returns
true if 'idx' is valid and Info was filled in, otherwise false

To introspect call this with index increasing from zero until false is returned.

Sub-classes are required to maintain a fixed number of parameters. The same ArrayInfo::name should alwaysbe returned for a given index. Similarly ArrayInfo::ndim and ArrayInfo.type should not change.

ArrayInfo::ptr, ArrayInfo::dim, ArrayInfo::stride are allowed to change when the state is passed to Machine::propagate().

Therefore, if getArray() for an instance has returned true for some index, then a caller may assume that all future calls to getArray() for this instance will also return true. However, the caller must still re-call getArray() in future as the storage and sizes may have changed.

Reimplemented in MomentState, MatrixState, and VectorState.

Definition at line 35 of file base.cpp.

virtual void StateBase::show ( std::ostream &  ,
int  level = 0 
) const
inlinevirtual

Print information about the state. level is a hint as to the verbosity expected by the caller.

Reimplemented in MomentState, and MatrixState.

Definition at line 45 of file base.h.

Member Data Documentation

size_t StateBase::next_elem

Index of ElementVoid in Machine to follow this the current one. May be altered within ElementVoid::advance() to achieve branching or looping.

Definition at line 34 of file base.h.


The documentation for this struct was generated from the following files: