1#ifndef __JROOT__JROOTCLASS__
2#define __JROOT__JROOTCLASS__
10#include <TDictionary.h>
12#include <TDataMember.h>
13#include <TBaseClass.h>
30namespace JPP {
using namespace JROOT; }
50 template<
class JType_t>
52 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
62 template<
class JType_t,
class JClass_t>
64 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
65 offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
163 if (name != NULL && strlen(name) != 0) {
173 for (TIter next(this->
getClass()->GetListOfDataMembers(kFALSE));
const TDataMember *p = (
const TDataMember*) next(); ) {
174 if (( option && strcmp (p->GetName(), name) == 0) ||
175 (!option && strcasecmp(p->GetName(), name) == 0)) {
176 return this->
get(*p);
182 for (TIter next(this->
getClass()->GetListOfBases());
const TBaseClass *p = (
const TBaseClass*) next(); ) {
188 rcs = rcs.
find(name, option);
210 return JRootClass(TDictionary::GetDictionary(
object.GetTypeName()),
223 return JRootClass(TDictionary::GetDictionary(
object.GetName()),
224 this->
getOffset() +
const_cast<TBaseClass&
>(
object).GetDelta());
233 inline void print(std::ostream& out)
const
260 inline void print(std::ostream& out,
const std::string& prefix)
const
268 for (TIter next(this->
getClass()->GetListOfBases());
const TBaseClass *p = (
const TBaseClass*) next(); ) {
270 this->
get(*p).
print(out, prefix +
"::" + p->GetName());
272 print(out, prefix +
"::" + p->GetName(), this->get(*p).getTypename());
275 for (TIter next(this->
getClass()->GetListOfDataMembers(kFALSE));
const TDataMember *p = (
const TDataMember*) next(); ) {
279 print(out, prefix + (
JRoot::is_static(*p) ?
"::" :
".") + p->GetName(), this->get(*p).getTypename());
293 inline static void print(std::ostream& out,
const std::string& name,
const std::string& type)
297 out << name <<
" " <<
'(' << type <<
')' << endl;
314 for (TIter next(parent.
getClass()->GetListOfDataMembers(kFALSE));
const TDataMember *p = (
const TDataMember*) next(); ) {
323 for (TIter next(parent.
getClass()->GetListOfBases());
const TBaseClass *p = (
const TBaseClass*) next(); ) {
346 template<
class JType_t,
class JClass_t>
361 if (buffer.empty()) {
363 TClass* rc =
dynamic_cast<TClass*
>(TDictionary::GetDictionary(
typeid(T)));
366 for (TIter next(rc->GetListOfDataMembers(kFALSE)); TDataMember *p = (TDataMember*) next(); ) {
383 template<
class JPo
inter_t>
448 if (
object.IsaPointer()) {
452 memcpy(&po, this->
getAddress() +
object.GetOffset(),
sizeof(
char*));
456 }
else if (strstr(
object.GetTypeName(),
"unique_ptr") != NULL) {
460 memcpy(&po, this->
getAddress() +
object.GetOffset(),
sizeof(
char*));
462 string buffer(
object.GetTypeName());
464 const string::size_type il = buffer.find_first_of(
"<");
465 const string::size_type ir = buffer.find_first_of(
">,");
467 buffer = buffer.substr(il + 1, ir - il - 1);
498 return this->
find(name);
579 operator const T&()
const
658 operator const T&()
const
694 if (this->
type != kOther_t) {
695 this->
address =
new char[TDataType::GetDataType(this->
type)->Size()];
710 this->
name = pb->GetName();
714 if (pb->GetExpectedType(cs, this->type) == 0) {
719 this->
dictionary = TDictionary::GetDictionary(TDataType::GetTypeName(this->
type));
721 if (this->
type != kOther_t) {
722 this->
address =
new char[TDataType::GetDataType(this->
type)->Size()];
734 if (this->
type != kOther_t) {
749 return this->
name.c_str();
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for cast operation.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
std::vector< TDataMember * > getListOfDataMembers()
Get list of ROOT data members for given class.
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Template definition of auxiliary base class for comparison of data structures.
Auxiliary class for a type holder.
ROOT readable class for TBranch.
JBranchClass()
Default constructor.
JBranchClass(const JBranchClass &bc)
Copy constructor.
EDataType getType() const
Get type.
JBranchClass(TBranch *pb)
Constructor.
void * getAddress()
Get branch address.
~JBranchClass()
Destructor.
const char *const getName() const
Get name.
Auxiliary class to manage access to base classes and data members of ROOT class objects.
JPointer_t pointer_type
Type definition of address.
bool is_valid() const
Check validity of this addressable class.
pointer_type getAddress() const
Get address.
JRootAddressableClass find(const char *const name) const
Find addressable base class or data member with given name within current class.
JRootAddressableClass operator[](const char *const name) const
Find addressable base class or data member with given name within current class.
JRootAddressableClass(const JRootClass &rc, pointer_type address)
Constructor.
JRootAddressableClass get(const TDataMember &object) const
Get addressable class of given data member.
JRootAddressableClass get(const TBaseClass &object) const
Get addressable class of given base class.
JRootAddressableClass()
Default constructor.
JRootAddressableClass(T &object)
Constructor.
Auxiliary class to manage access to base classes and data members of ROOT class.
TDictionary * getDictionary() const
Get dictionary.
JRootClass(const JType< JType_t > &type)
Constructor.
void print(std::ostream &out) const
Print ROOT class information.
TDictionary * dictionary
pointer to ROOT dictionary
const char * getTypename() const
Get type name.
bool is_valid() const
Check validity of this class.
JRootClass(JType_t JClass_t::*pd)
Constructor.
JRootClass()
Default constructor.
TClass * getClass() const
Get class.
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.
JRootClass get(const TBaseClass &object) const
Get ROOT class of given base class.
int offset
offset with respect to data structure [B]
JRootClass find(const char *const name, const bool option=true) const
Find base class or data member with given name within current class.
static void print(std::ostream &out, const std::string &name, const std::string &type)
Print ROOT class information.
JRootClass get(const TDataMember &object) const
Get ROOT class of given data member.
JRootClass(TDictionary *dictionary, int offset=0)
Constructor.
bool equals(const JRootClass &object) const
Test equality of ROOT classes.
ROOT class for reading into object.
JRootReadableClass(const JRootAddressableClass< char * > &rc)
Copy constructor.
JRootReadableClass()
Default constructor.
JRootReadableClass(TDictionary *dictionary, pointer_type address)
Constructor.
JRootReadableClass(T &object)
Constructor.
ROOT class for writing from object.
JRootWritableClass(const JRootAddressableClass< const char * > &rc)
Copy constructor.
JRootWritableClass()
Default constructor.
JRootWritableClass(const T &object)
Constructor.
JRootWritableClass(TDictionary *dictionary, pointer_type address)
Constructor.
static bool is_class(const char *const name)
Check name of class against internal ROOT class names.
static bool is_static(const TDataMember &object)
Check if data member is static.
static bool is_STLcontainer(const TBaseClass &object)
Check if base class is STL container.
static bool is_STLstring(const TDataMember &object)
Check if data member is STL string.