1 #ifndef __JROOT__JROOTCLASS__
2 #define __JROOT__JROOTCLASS__
9 #include <TDictionary.h>
11 #include <TDataMember.h>
12 #include <TBaseClass.h>
13 #include <TIterator.h>
26 namespace JPP {
using namespace JROOT; }
48 static inline bool is_class(
const char*
const class_name)
50 return (class_name != NULL &&
51 strcmp(class_name, TClass ::Class()->GetName()) != 0 &&
52 strcmp(class_name, TObject::Class()->GetName()) != 0 &&
53 strcmp(class_name,
"_Rb_tree_node_base") != 0 &&
54 strcmp(class_name,
"fgIsA") != 0 &&
55 strcmp(class_name,
"atomic<TClass*>") != 0);
65 static inline bool is_class(
const TBaseClass& base_class)
67 return is_class(base_class.GetName());
77 static inline bool is_class(
const TDataMember& data_member)
79 return is_class(data_member.GetTypeName());
91 return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
103 return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
115 return (strcmp(data_member.GetFullTypeName(),
"string") == 0 ||
116 strcmp(data_member.GetFullTypeName(),
"const string") == 0);
126 static inline bool is_static(
const TDataMember& data_member)
128 return (data_member.Property() & kIsStatic);
137 template<
class JType_t>
139 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
149 template<
class JType_t,
class JClass_t>
151 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
152 offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
235 if (name != NULL && strlen(name) != 0) {
245 const TDataMember* p = this->
getClass()->GetDataMember(name);
248 return this->
get(*p);
253 TIterator* i = this->
getClass()->GetListOfBases()->MakeIterator();
255 for (TBaseClass* p; (p = (TBaseClass*) i->Next()) != NULL; ) {
261 rcs = rcs.
find(name);
282 return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
283 this->
getOffset() + data_member.GetOffset());
294 return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
295 this->
getOffset() +
const_cast<TBaseClass&
>(base_class).GetDelta());
304 inline void print(std::ostream& out)
const
333 dictionary(dictionary),
344 inline void print(std::ostream& out,
const std::string& prefix)
const
352 if (this->
getClass()->GetListOfBases() != NULL) {
354 TIterator* i = this->
getClass()->GetListOfBases()->MakeIterator();
356 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
358 this->
get(*p).print(out, prefix +
"::" + p->GetName());
360 print(out, prefix +
"::" + p->GetName(), this->
get(*p).getTypename());
364 if (this->
getClass()->GetListOfDataMembers() != NULL) {
366 TIterator* i = this->
getClass()->GetListOfDataMembers()->MakeIterator();
368 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
370 this->
get(*p).print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName());
372 print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName(), this->
get(*p).getTypename());
387 inline static void print(std::ostream& out,
const std::string&
name,
const std::string& type)
391 out << name <<
" " <<
'(' << type <<
')' << endl;
399 template<
class JPo
inter_t>
425 template<
class JPo
inter_t>
507 return this->
find(name);
558 operator const T&()
const
561 return * (
const T*) this->getAddress();
577 return * (
T*) this->getAddress();
618 operator const T&()
const
621 return * (
const T*) this->getAddress();
643 i = parent.
getClass()->GetListOfDataMembers()->MakeIterator();
645 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
654 i = parent.
getClass()->GetListOfBases()->MakeIterator();
656 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
679 template<
class JType_t,
class JClass_t>
void print(std::ostream &out, const std::string &prefix) const
Print ROOT class information.
ROOT class for reading object.
JRootAddressableClass find(const char *name) const
Find addressable base class or data member with given name within current class.
JAddress_t::pointer_type pointer_type
int getOffset() const
Get offset of this class with respect to parent 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.
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
const char * getTypename() const
Get type name.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JRootClass()
Default constructor.
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.
JRootAddressableClass operator[](const char *name) const
Find addressable base class or data member with given name within current class.
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.
JAddress(pointer_type p)
Constructor.
JType< T > getType()
Get type.
JRootClass(TDictionary *dictionary, int offset)
Constructor.
Auxiliary class to manage access to base classes and data members of ROOT class.
JRootClass find(const char *name) const
Find base class or data member with given name within current class.
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.