1 #ifndef __JROOT__JROOTCLASS__
2 #define __JROOT__JROOTCLASS__
11 #include <TDictionary.h>
13 #include <TDataMember.h>
14 #include <TBaseClass.h>
15 #include <TIterator.h>
28 namespace JPP {
using namespace JROOT; }
52 return (name != NULL &&
53 strcmp(name, TClass ::Class()->GetName()) != 0 &&
54 strcmp(name, TObject::Class()->GetName()) != 0 &&
55 strcmp(name,
"_Rb_tree_node_base") != 0 &&
56 strcmp(name,
"fgIsA") != 0 &&
57 strcmp(name,
"atomic<TClass*>") != 0);
67 static inline bool is_class(
const TBaseClass& base_class)
69 return is_class(base_class.GetName());
79 static inline bool is_class(
const TDataMember& data_member)
81 return is_class(data_member.GetTypeName());
93 return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
105 return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
117 return (strcmp(data_member.GetFullTypeName(),
"string") == 0 ||
118 strcmp(data_member.GetFullTypeName(),
"const string") == 0);
128 static inline bool is_static(
const TDataMember& data_member)
130 return (data_member.Property() & kIsStatic);
139 template<
class JType_t>
141 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
151 template<
class JType_t,
class JClass_t>
153 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
154 offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
239 if (name != NULL && strlen(name) != 0) {
249 for (std::unique_ptr<TIterator>
i(this->
getClass()->GetListOfDataMembers(kFALSE)->MakeIterator());
const TDataMember* p = (
const TDataMember*)
i->Next(); ) {
250 if (( option && strcmp (p->GetName(),
name) == 0) ||
251 (!option && strcasecmp(p->GetName(),
name) == 0)) {
252 return this->
get(*p);
258 for (std::unique_ptr<TIterator>
i(this->
getClass()->GetListOfBases()->MakeIterator()); TBaseClass* p = (TBaseClass*)
i->Next(); ) {
264 rcs = rcs.
find(name);
286 return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
287 this->
getOffset() + data_member.GetOffset());
299 return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
300 this->
getOffset() +
const_cast<TBaseClass&
>(base_class).GetDelta());
309 inline void print(std::ostream& out)
const
338 dictionary(dictionary),
357 if (this->
getClass()->GetListOfBases() != NULL) {
359 for (std::unique_ptr<TIterator>
i(this->
getClass()->GetListOfBases()->MakeIterator());
const TBaseClass* p = (
const TBaseClass*)
i->Next(); ) {
361 this->
get(*p).print(out, prefix +
"::" + p->GetName());
363 print(out, prefix +
"::" + p->GetName(), this->
get(*p).getTypename());
367 if (this->
getClass()->GetListOfDataMembers(kFALSE) != NULL) {
369 for (std::unique_ptr<TIterator>
i(this->
getClass()->GetListOfDataMembers(kFALSE)->MakeIterator());
const TDataMember* p = (
const TDataMember*)
i->Next(); ) {
371 this->
get(*p).print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName());
373 print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName(), this->
get(*p).getTypename());
392 out << name <<
" " <<
'(' << type <<
')' << endl;
400 template<
class JPo
inter_t>
426 template<
class JPo
inter_t>
512 return this->
find(name);
563 operator const T&()
const
566 return * (
const T*) this->getAddress();
582 return * (
T*) this->getAddress();
623 operator const T&()
const
626 return * (
const T*) this->getAddress();
646 for (std::unique_ptr<TIterator>
i(parent.
getClass()->GetListOfDataMembers(kFALSE)->MakeIterator());
const TDataMember* p = (
const TDataMember*)
i->Next(); ) {
655 for (std::unique_ptr<TIterator>
i(parent.
getClass()->GetListOfBases()->MakeIterator());
const TBaseClass* p = (
const TBaseClass*)
i->Next(); ) {
678 template<
class JType_t,
class JClass_t>
693 TClass* rc = (TClass*) TDictionary::GetDictionary(
typeid(
T));
695 for (std::unique_ptr<TIterator>
i(rc->GetListOfDataMembers(kFALSE)->MakeIterator()); TDataMember* p = (TDataMember*)
i->Next(); ) {
void print(std::ostream &out, const std::string &prefix) const
Print ROOT class information.
std::vector< TDataMember * > getListOfDataMembers()
Get list of ROOT data members for given class.
ROOT class for reading object.
JAddress_t::pointer_type pointer_type
int getOffset() const
Get offset of this class with respect to parent class.
JRootClass find(const char *const name, const bool option=true) const
Find base class or data member with given name within current class.
JRootAddressableClass(const JRootClass &rc, pointer_type address)
Constructor.
JRootClass(JType_t JClass_t::*pd)
Constructor.
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
void print(std::ostream &out) const
Print ROOT class information.
JRootClass(const JType< JType_t > &type)
Constructor.
const char * getTypename() const
Get type name.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JRootClass()
Default constructor.
then echo Enter input within $TIMEOUT_S seconds echo n User name
JRootAddressableClass(T &object)
Constructor.
JRootWritableClass(const JRootAddressableClass< const char * > &rc)
Copy constructor.
Auxiliary class for a type holder.
static bool is_STLcontainer(const TDataMember &data_member)
Check if data member is STL container.
JRootWritableClass(const T &object)
Constructor.
Auxiliary class to manage access to base classes and data members of ROOT class objects.
static bool is_STLstring(const TDataMember &data_member)
Check if data member is STL string.
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
TDictionary * getDictionary() const
Get dictionary.
static bool is_class(const TBaseClass &base_class)
Check base class against ROOT class names.
pointer_type getAddress() const
Get address.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Template definition of auxiliary base class for comparison of data structures.
bool equals(const JRootClass &object) const
Test equality of ROOT classes.
bool is_valid() const
Check validity of this class.
JRootReadableClass(T &object)
Constructor.
static void print(std::ostream &out, const std::string &name, const std::string &type)
Print ROOT class information.
Exception for cast operation.
TDictionary * dictionary
pointer to ROOT dictionary
JPointer_t pointer_type
Type definition of address.
bool is_valid() const
Check validity of this addressable class.
JAddress< JPointer_t > JAddress_t
static bool is_class(const TDataMember &data_member)
Check data member against ROOT class names.
TClass * getClass() const
Get class.
JRootAddressableClass find(const char *const name) const
Find addressable base class or data member with given name within current class.
JAddress(pointer_type p)
Constructor.
JType< T > getType()
Get type.
JRootAddressableClass operator[](const char *const name) const
Find addressable base class or data member with given name within current class.
JRootClass(TDictionary *dictionary, int offset)
Constructor.
Auxiliary class to manage access to base classes and data members of ROOT class.
static bool is_class(const char *const name)
Check name of class against ROOT classes.
int offset
offset with respect to data structure [B]
JRootReadableClass(const JRootAddressableClass< char * > &rc)
Copy constructor.
static bool is_static(const TDataMember &data_member)
Check if data member is static.
ROOT class for writing object.