BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Class that provides introspection to its members. More...
#include <published.h>
Public Member Functions | |
bool | NameExists (const std::string &name) const |
template<typename T > | |
Published< C >::template AttributeMap< T > & | attribute_map () const |
Protected Types | |
template<typename T > | |
using | AttributeMap = typename std::unordered_map< std::string, T C::* > |
Define AttributeMap of string and class member pointer. | |
Protected Member Functions | |
template<typename T > | |
void | publish (const std::string &name, T C::*mp) |
Make pointer to member from class C and type T with accessible with a name. | |
void | set (C *instance, const C *instance2, const std::string &name) |
Set member with name of class instance to value of second instance. | |
template<typename T > | |
AttributeMap< T > & | attribute_map () const |
Access method to static map for type T and class C. | |
template<typename T > | |
T | get (const C *instance, const std::string &name) const |
Get method for class C. | |
void | set (C *instance, const std::string &name, double value) |
void | set (C *instance, const std::string &name, GMAD::Array *const &value) |
template<typename T > | |
void | set (C *instance, const std::string &name, const T &value) |
Private Member Functions | |
template<typename T > | |
T C::* | member (const std::string &name) const |
Access to member pointer. | |
Private Attributes | |
std::set< std::string > | allNames |
A cache of all names defined through publish(). | |
Class that provides introspection to its members.
In the parser the keywords in the ASCII files need to be matched to the correct member variable. However, C++ has no introspection ability. This class provides this artificially.
All members need to be added explicitly to a hash table (unordered_map) with the method publish. Note that the name can be different from the actual member name
adapted into a class from http://stackoverflow.com/questions/19557881/convert-string-character-to-class-member-method-in-c
Definition at line 46 of file published.h.
|
protected |
Define AttributeMap of string and class member pointer.
Definition at line 69 of file published.h.
Published< C >::template AttributeMap< T > & GMAD::Published< C >::attribute_map | ( | ) | const |
Definition at line 254 of file published.h.
|
protected |
Get method for class C.
Definition at line 231 of file published.h.
|
private |
Access to member pointer.
Definition at line 240 of file published.h.
|
inline |
Definition at line 49 of file published.h.
|
protected |
Make pointer to member from class C and type T with accessible with a name.
Definition at line 92 of file published.h.
|
protected |
Set member with name of class instance to value of second instance.
Definition at line 172 of file published.h.
|
protected |
Set member with name of class instance to value. Throws std::runtime_error if not found
Definition at line 135 of file published.h.
|
protected |
Set member with name of class instance to value. Throws std::runtime_error if not found
Definition at line 99 of file published.h.
Referenced by GMAD::Parameters::inherit_properties(), GMAD::Element::set(), GMAD::Element::set_value(), and GMAD::Parameters::set_value().
|
protected |
Set member with name of class instance to value. Throws std::runtime_error if not found
Definition at line 147 of file published.h.
|
private |
A cache of all names defined through publish().
Definition at line 85 of file published.h.