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; }
45 static inline bool is_class(
const char*
const class_name)
47 return (class_name != NULL &&
48 strcmp(class_name, TClass ::Class()->GetName()) != 0 &&
49 strcmp(class_name, TObject::Class()->GetName()) != 0 &&
50 strcmp(class_name,
"fgIsA") != 0 &&
51 strcmp(class_name,
"atomic<TClass*>") != 0);
61 static inline bool is_class(
const TBaseClass& base_class)
63 return is_class(base_class.GetName());
73 static inline bool is_class(
const TDataMember& data_member)
75 return is_class(data_member.GetTypeName());
87 return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
99 return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
111 return (strcmp(data_member.GetFullTypeName(),
"string") == 0 ||
112 strcmp(data_member.GetFullTypeName(),
"const string") == 0);
122 static inline bool is_static(
const TDataMember& data_member)
124 return (data_member.Property() & kIsStatic);
135 dictionary(TDictionary::GetDictionary(typeid(T))),
221 if (name != NULL && strlen(name) != 0) {
231 const TDataMember* p = this->
getClass()->GetDataMember(name);
234 return this->
get(*p);
239 TIterator* i = this->
getClass()->GetListOfBases()->MakeIterator();
241 for (TBaseClass* p; (p = (TBaseClass*) i->Next()) != NULL; ) {
247 cls = cls.
find(name);
268 return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
269 this->
getOffset() + data_member.GetOffset());
280 return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
281 this->
getOffset() +
const_cast<TBaseClass&
>(base_class).GetDelta());
290 inline void print(std::ostream& out)
const
319 dictionary(dictionary),
330 inline void print(std::ostream& out,
const std::string& prefix)
const
338 if (this->
getClass()->GetListOfBases() != NULL) {
340 TIterator* i = this->
getClass()->GetListOfBases()->MakeIterator();
342 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
344 this->
get(*p).print(out, prefix +
"::" + p->GetName());
346 print(out, prefix +
"::" + p->GetName(), this->
get(*p).getTypename());
350 if (this->
getClass()->GetListOfDataMembers() != NULL) {
352 TIterator* i = this->
getClass()->GetListOfDataMembers()->MakeIterator();
354 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
356 this->
get(*p).print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName());
358 print(out, prefix + (
is_static(*p) ?
"::" :
".") + p->GetName(), this->
get(*p).getTypename());
373 inline static void print(std::ostream& out,
const std::string& name,
const std::string& type)
377 out << name <<
" " <<
'(' << type <<
')' << endl;
385 template<
bool is_const>
508 operator const T&()
const
511 return * (
const T*) this->getAddress();
527 return * (T*) this->getAddress();
544 * (T*) this->getAddress() = value;
598 operator const T&()
const
601 return * (
const T*) this->getAddress();
void print(std::ostream &out, const std::string &prefix) const
Print ROOT class information.
int getOffset() const
Get offset of this class with respect to parent 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.
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
JRootClassWriter(const T &object)
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.
pointer_type getAddress() const
Get address.
JRootClassReader operator[](const char *name) const
Get ROOT class reader with given name within current class.
JRootAddressableClass(T &object)
Constructor.
JRootClass(const JType< T > &type)
Constructor.
Auxiliary class for a type holder.
JAddress< is_const > JAddress_t
JRootAddressableClass(const JRootClass &rcs, pointer_type address)
Constructor.
static bool is_STLcontainer(const TDataMember &data_member)
Check if data member is STL container.
Auxiliary class to manage access to base classes and data members of ROOT class objects.
JRootClassReader & operator=(const T &value)
Assignment operator.
bool is_valid() const
Check validity of this addressable class.
JAddressTypedef< is_const >::pointer_type pointer_type
Type definition of address.
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.
ROOT class for writing object.
friend bool operator==(const JRootClass &first, const JRootClass &second)
Test equality of ROOT classes.
TDictionary * getDictionary() const
Get dictionary.
JRootClassReader(const JRootAddressableClass< false > &rcs)
Copy constructor.
static bool is_class(const TBaseClass &base_class)
Check base class against ROOT class names.
ROOT class for reading object.
bool is_valid() const
Check validity of this class.
Simple address wrapper for const and non-const pointers.
static void print(std::ostream &out, const std::string &name, const std::string &type)
Print ROOT class information.
JRootClassWriter operator[](const char *name) const
Get ROOT class writer with given name within current class.
Exception for cast operation.
JRootClassWriter(const JRootAddressableClass< true > &rcs)
Copy constructor.
TDictionary * dictionary
pointer to ROOT dictionary
static bool is_class(const TDataMember &data_member)
Check data member against ROOT class names.
TClass * getClass() const
Get class.
JRootClass(TDictionary *dictionary, int offset)
Constructor.
JRootAddressableClass find(const char *name) const
Find addressable base class or data member with given name within current class.
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]
JRootClassReader(T &object)
Constructor.
static bool is_static(const TDataMember &data_member)
Check if data member is static.
JAddress_t::pointer_type pointer_type