Jpp
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
JROOT::JRootClass Struct Reference

Auxiliary class to manage access to base classes and data members of ROOT class. More...

#include <JRootClass.hh>

Inheritance diagram for JROOT::JRootClass:
JLANG::JEquals< JRootClass > JROOT::JRootAddressableClass< JPointer_t > JROOT::JRootAddressableClass< char * > JROOT::JRootAddressableClass< const char * > JROOT::JRootReadableClass JROOT::JRootWritableClass

Public Member Functions

template<class JType_t >
 JRootClass (const JType< JType_t > &type)
 Constructor. More...
 
template<class JType_t , class JClass_t >
 JRootClass (JType_t JClass_t::*pd)
 Constructor. More...
 
TDictionary * getDictionary () const
 Get dictionary. More...
 
int getOffset () const
 Get offset of this class with respect to parent class. More...
 
TClass * getClass () const
 Get class. More...
 
const char * getTypename () const
 Get type name. More...
 
bool is_valid () const
 Check validity of this class. More...
 
bool equals (const JRootClass &object) const
 Test equality of ROOT classes. More...
 
JRootClass find (const char *name) const
 Find base class or data member with given name within current class. More...
 
JRootClass get (const TDataMember &data_member) const
 Get ROOT class of given data member. More...
 
JRootClass get (const TBaseClass &base_class) const
 Get ROOT class of given base class. More...
 
void print (std::ostream &out) const
 Print ROOT class information. More...
 

Static Public Member Functions

static bool is_class (const char *const class_name)
 Check class name against ROOT class names. More...
 
static bool is_class (const TBaseClass &base_class)
 Check base class against ROOT class names. More...
 
static bool is_class (const TDataMember &data_member)
 Check data member against ROOT class names. More...
 
static bool is_STLcontainer (const TBaseClass &base_class)
 Check if base class is STL container. More...
 
static bool is_STLcontainer (const TDataMember &data_member)
 Check if data member is STL container. More...
 
static bool is_STLstring (const TDataMember &data_member)
 Check if data member is STL string. More...
 
static bool is_static (const TDataMember &data_member)
 Check if data member is static. More...
 

Protected Member Functions

 JRootClass ()
 Default constructor. More...
 
 JRootClass (TDictionary *dictionary, int offset)
 Constructor. More...
 
void print (std::ostream &out, const std::string &prefix) const
 Print ROOT class information. More...
 

Static Protected Member Functions

static void print (std::ostream &out, const std::string &name, const std::string &type)
 Print ROOT class information. More...
 

Protected Attributes

TDictionary * dictionary
 pointer to ROOT dictionary More...
 
int offset
 offset with respect to data structure [B] More...
 

Detailed Description

Auxiliary class to manage access to base classes and data members of ROOT class.

Definition at line 38 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootClass() [1/4]

template<class JType_t >
JROOT::JRootClass::JRootClass ( const JType< JType_t > &  type)
inline

Constructor.

Parameters
typedata type

Definition at line 136 of file JRootClass.hh.

136  :
137  dictionary(TDictionary::GetDictionary(typeid(JType_t))),
138  offset(0)
139  {}

◆ JRootClass() [2/4]

template<class JType_t , class JClass_t >
JROOT::JRootClass::JRootClass ( JType_t JClass_t::*  pd)
inline

Constructor.

Parameters
pdpointer to C++ data member

Definition at line 148 of file JRootClass.hh.

148  :
149  dictionary(TDictionary::GetDictionary(typeid(JType_t))),
150  offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
151  {}

◆ JRootClass() [3/4]

JROOT::JRootClass::JRootClass ( )
inlineprotected

Default constructor.

Definition at line 317 of file JRootClass.hh.

317  :
318  dictionary(NULL),
319  offset(0)
320  {}

◆ JRootClass() [4/4]

JROOT::JRootClass::JRootClass ( TDictionary *  dictionary,
int  offset 
)
inlineprotected

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 329 of file JRootClass.hh.

330  :
332  offset (offset)
333  {}

Member Function Documentation

◆ is_class() [1/3]

static bool JROOT::JRootClass::is_class ( const char *const  class_name)
inlinestatic

Check class name against ROOT class names.

Parameters
class_nameclass name
Returns
true if valid class name; else false

Definition at line 47 of file JRootClass.hh.

48  {
49  return (class_name != NULL &&
50  strcmp(class_name, TClass ::Class()->GetName()) != 0 &&
51  strcmp(class_name, TObject::Class()->GetName()) != 0 &&
52  strcmp(class_name, "fgIsA") != 0 &&
53  strcmp(class_name, "atomic<TClass*>") != 0);
54  }

◆ is_class() [2/3]

static bool JROOT::JRootClass::is_class ( const TBaseClass &  base_class)
inlinestatic

Check base class against ROOT class names.

Parameters
base_classbase class
Returns
true if valid class name; else false

Definition at line 63 of file JRootClass.hh.

64  {
65  return is_class(base_class.GetName());
66  }

◆ is_class() [3/3]

static bool JROOT::JRootClass::is_class ( const TDataMember &  data_member)
inlinestatic

Check data member against ROOT class names.

Parameters
data_memberdata member
Returns
true if valid class name; else false

Definition at line 75 of file JRootClass.hh.

76  {
77  return is_class(data_member.GetTypeName());
78  }

◆ is_STLcontainer() [1/2]

static bool JROOT::JRootClass::is_STLcontainer ( const TBaseClass &  base_class)
inlinestatic

Check if base class is STL container.

Parameters
base_classbase class
Returns
true if STL congtainer; else false

Definition at line 87 of file JRootClass.hh.

88  {
89  return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
90  }

◆ is_STLcontainer() [2/2]

static bool JROOT::JRootClass::is_STLcontainer ( const TDataMember &  data_member)
inlinestatic

Check if data member is STL container.

Parameters
data_memberdata member
Returns
true if STL congtainer; else false

Definition at line 99 of file JRootClass.hh.

100  {
101  return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
102  }

◆ is_STLstring()

static bool JROOT::JRootClass::is_STLstring ( const TDataMember &  data_member)
inlinestatic

Check if data member is STL string.

Parameters
data_memberdata member
Returns
true if STL string; else false

Definition at line 111 of file JRootClass.hh.

112  {
113  return (strcmp(data_member.GetFullTypeName(), "string") == 0 ||
114  strcmp(data_member.GetFullTypeName(), "const string") == 0);
115  }

◆ is_static()

static bool JROOT::JRootClass::is_static ( const TDataMember &  data_member)
inlinestatic

Check if data member is static.

Parameters
data_memberdata member
Returns
true if static; else false

Definition at line 124 of file JRootClass.hh.

125  {
126  return (data_member.Property() & kIsStatic);
127  }

◆ getDictionary()

TDictionary* JROOT::JRootClass::getDictionary ( ) const
inline

Get dictionary.

Returns
pointer to dictionary

Definition at line 159 of file JRootClass.hh.

160  {
161  return dictionary;
162  }

◆ getOffset()

int JROOT::JRootClass::getOffset ( ) const
inline

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 170 of file JRootClass.hh.

171  {
172  return offset;
173  }

◆ getClass()

TClass* JROOT::JRootClass::getClass ( ) const
inline

Get class.

Returns
pointer to class

Definition at line 181 of file JRootClass.hh.

182  {
183  return dynamic_cast<TClass*>(dictionary);
184  }

◆ getTypename()

const char* JROOT::JRootClass::getTypename ( ) const
inline

Get type name.

Returns
type name

Definition at line 192 of file JRootClass.hh.

193  {
194  if (dictionary != NULL)
195  return dictionary->GetName();
196  else
197  return NULL;
198  }

◆ is_valid()

bool JROOT::JRootClass::is_valid ( ) const
inline

Check validity of this class.

Returns
true if valid class; else false

Definition at line 206 of file JRootClass.hh.

207  {
208  return (this->getDictionary() != NULL && is_class(this->getTypename()));
209  }

◆ equals()

bool JROOT::JRootClass::equals ( const JRootClass object) const
inline

Test equality of ROOT classes.

Parameters
objectROOT class
Returns
true if both ROOT classes are same type; else false

Definition at line 218 of file JRootClass.hh.

219  {
220  return (this-> getTypename() != NULL &&
221  object.getTypename() != NULL &&
222  strcmp(this->getTypename(), object.getTypename()) == 0);
223  }

◆ find()

JRootClass JROOT::JRootClass::find ( const char *  name) const
inline

Find base class or data member with given name within current class.

Parameters
namename of base class or data member

Definition at line 231 of file JRootClass.hh.

232  {
233  if (name != NULL && strlen(name) != 0) {
234 
235  if (strcmp(getTypename(), name) == 0) {
236  return *this;
237  }
238 
239  if (this->getClass() != NULL) {
240 
241  // check for data member
242 
243  const TDataMember* p = this->getClass()->GetDataMember(name);
244 
245  if (p != NULL) {
246  return this->get(*p);
247  }
248 
249  // check for base classes
250 
251  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
252 
253  for (TBaseClass* p; (p = (TBaseClass*) i->Next()) != NULL; ) {
254 
255  if (is_class(*p) && !is_STLcontainer(*p)) {
256 
257  JRootClass rcs = this->get(*p);
258 
259  rcs = rcs.find(name);
260 
261  if (rcs.is_valid()) {
262  return rcs;
263  }
264  }
265  }
266  }
267  }
268 
269  return JRootClass(); // invalid value
270  }

◆ get() [1/2]

JRootClass JROOT::JRootClass::get ( const TDataMember &  data_member) const
inline

Get ROOT class of given data member.

Parameters
data_memberdata member

Definition at line 278 of file JRootClass.hh.

279  {
280  return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
281  this->getOffset() + data_member.GetOffset());
282  }

◆ get() [2/2]

JRootClass JROOT::JRootClass::get ( const TBaseClass &  base_class) const
inline

Get ROOT class of given base class.

Parameters
base_classbase class

Definition at line 290 of file JRootClass.hh.

291  {
292  return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
293  this->getOffset() + const_cast<TBaseClass&>(base_class).GetDelta());
294  }

◆ print() [1/3]

void JROOT::JRootClass::print ( std::ostream &  out) const
inline

Print ROOT class information.

Parameters
outoutput stream

Definition at line 302 of file JRootClass.hh.

303  {
304  print(out, getTypename());
305  }

◆ print() [2/3]

void JROOT::JRootClass::print ( std::ostream &  out,
const std::string &  prefix 
) const
inlineprotected

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 342 of file JRootClass.hh.

343  {
344  if (this->is_valid()) {
345 
346  print(out, prefix, this->getTypename());
347 
348  if (this->getClass() != NULL) {
349 
350  if (this->getClass()->GetListOfBases() != NULL) {
351 
352  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
353 
354  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
355  if (!is_STLcontainer(*p))
356  this->get(*p).print(out, prefix + "::" + p->GetName());
357  else
358  print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
359  }
360  }
361 
362  if (this->getClass()->GetListOfDataMembers() != NULL) {
363 
364  TIterator* i = this->getClass()->GetListOfDataMembers()->MakeIterator();
365 
366  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
367  if (!is_STLstring(*p) && !is_STLcontainer(*p))
368  this->get(*p).print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName());
369  else
370  print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
371  }
372  }
373  }
374  }
375  }

◆ print() [3/3]

static void JROOT::JRootClass::print ( std::ostream &  out,
const std::string &  name,
const std::string &  type 
)
inlinestaticprotected

Print ROOT class information.

Parameters
outoutput stream
namename
typetype

Definition at line 385 of file JRootClass.hh.

386  {
387  using namespace std;
388 
389  out << name << " " << '(' << type << ')' << endl;
390  }

Member Data Documentation

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 310 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 311 of file JRootClass.hh.


The documentation for this struct was generated from the following file:
JROOT::JRootClass::JRootClass
JRootClass()
Default constructor.
Definition: JRootClass.hh:317
JROOT::JRootClass::getClass
TClass * getClass() const
Get class.
Definition: JRootClass.hh:181
JROOT::JRootClass::get
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
Definition: JRootClass.hh:278
JROOT::JRootClass::getOffset
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:170
JROOT::JRootClass::is_class
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:47
JROOT::JRootClass::is_STLcontainer
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition: JRootClass.hh:87
JROOT::JRootClass::dictionary
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:310
JROOT::JRootClass::is_static
static bool is_static(const TDataMember &data_member)
Check if data member is static.
Definition: JRootClass.hh:124
JROOT::JRootClass
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:38
JROOT::JRootClass::offset
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:311
JROOT::JRootClass::getTypename
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:192
std
Definition: jaanetDictionary.h:36
JROOT::JRootClass::getDictionary
TDictionary * getDictionary() const
Get dictionary.
Definition: JRootClass.hh:159
JROOT::JRootClass::is_valid
bool is_valid() const
Check validity of this class.
Definition: JRootClass.hh:206
JROOT::JRootClass::is_STLstring
static bool is_STLstring(const TDataMember &data_member)
Check if data member is STL string.
Definition: JRootClass.hh:111
JROOT::JRootClass::print
void print(std::ostream &out) const
Print ROOT class information.
Definition: JRootClass.hh:302
JROOT::JRootClass::find
JRootClass find(const char *name) const
Find base class or data member with given name within current class.
Definition: JRootClass.hh:231