REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
Wrapper class for different type objects
Supports both class objects(string, vector, TRestMetadata, etc.) and basic type objects(int, double, etc.). Implements object wrapping, type assembly, data member reflection, memory streaming, and string conversion. We set a type alias any
for this class.
Example 1: Type assembly & Value assignment
Example 2: Object wrapping & Memory streaming
Example 3: Convert to string
Definition at line 286 of file TRestReflector.h.
Public Member Functions | |
void | Assembly () |
Assembly a new object, and save its address. The old object will be destroied if not null. | |
void | Destroy () const |
Destroy the current object. It will make the class to be zombie. | |
TRestReflector | GetDataMember (const std::string &name) |
Find the class's datamember as TRestReflector object, including those from base class. | |
TRestReflector | GetDataMember (int ID) |
Get the i-th datamember of the class, ignoring those from base class. | |
std::string | GetDataMemberValueString (const std::string &name) |
Get the value of datamember as std::string. | |
std::vector< std::string > | GetListOfDataMembers () const |
Get a list of the class's datamembers as a std::vector of std::string, including those from base class. | |
int | GetNumberOfDataMembers () const |
Get the number of data members of a class. | |
template<typename T > | |
T | GetValue () |
Get the value of the wrapped type, not recommended to use. | |
template<class T > | |
void | InitFromTemplate () |
bool | IsZombie () const |
If this object type wrapper is invalid. | |
template<class T > | |
operator T* () | |
void | operator>> (const TRestReflector &to) |
Deep copy the content of the wrapped object to to . | |
void | ParseString (const std::string &str) const |
Set the value of the wrapped object from std::string. | |
void | PrintMemory (int bytepreline=16) |
Print the Hex memory std::map of the wrappered object. | |
template<class T > | |
void | SetValue (const T &val) |
Set the value of the wrapped type. | |
std::string | ToString () const |
Convert the wrapped object to std::string. | |
TRestReflector () | |
Default constructor. | |
template<class T > | |
TRestReflector (const T &obj) | |
Constructor to wrap an object. Any typed object can be revieved as argument. | |
template<class T > | |
TRestReflector (T *obj) | |
Constructor to wrap an object pointer. | |
TRestReflector (void *address, const std::string &type) | |
Constructor from a certain address and a certain type. | |
Data Fields | |
char * | address = 0 |
Address of the wrapped object. | |
TClass * | cl = 0 |
Pointer to the corresponding TClass helper, if the wrapped object is in class type. | |
bool | is_data_type = false |
Pointer to the corresponding TDataType helper, if the wrapped object is in data type. | |
std::string | name = "" |
Name field. | |
int | size = 0 |
Size of the object. | |
std::string | type = "" |
Type of the wrapped object. | |
const std::type_info * | typeinfo = 0 |
value of typeid(T).name() of the wrapped object | |
Private Member Functions | |
int | InitDictionary () |
Prepare the ROOT dictionary for this type. | |
Private Attributes | |
bool | onheap = false |
If on heap, we can call Destroy() to TRestReflector. True only when initialized from Assembly() | |
Friends | |
std::ostream & | operator<< (std::ostream &cin, TRestReflector ptr) |
Output overload by calling ToString();. | |
|
inline |
Type conversion operator. With this, one can implicitly convert TRestReflector object to pointer of certain type. For example, TRestEvent* eve = REST_Reflection::Assembly("TRestRawSignalEvent");
Definition at line 360 of file TRestReflector.h.