Jpp
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
JROOT::JRootAddressableClass< JPointer_t > Struct Template Reference

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

#include <JRootClass.hh>

Inheritance diagram for JROOT::JRootAddressableClass< JPointer_t >:
JROOT::JRootClass JROOT::JAddress< JPointer_t > JLANG::JEquals< JRootClass >

Public Types

typedef JAddress< JPointer_t > JAddress_t
 
typedef JAddress_t::pointer_type pointer_type
 

Public Member Functions

template<class T >
 JRootAddressableClass (T &object)
 Constructor. More...
 
pointer_type getAddress () const
 Get address. More...
 
bool is_valid () const
 Check validity of this addressable class. More...
 
JRootAddressableClass find (const char *name) const
 Find addressable base class or data member with given name within current class. More...
 
JRootAddressableClass get (const TDataMember &data_member) const
 Get addressable class of given data member. More...
 
JRootAddressableClass get (const TBaseClass &base_class) const
 Get addressable class of given base class. More...
 
JRootAddressableClass operator[] (const char *name) const
 Find addressable base class or data member with given name within current class. 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 equals (const JRootClass &object) const
 Test equality of ROOT classes. 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...
 

Public Attributes

pointer_type address
 

Protected Member Functions

 JRootAddressableClass (const JRootClass &rc, pointer_type address)
 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

template<class JPointer_t>
struct JROOT::JRootAddressableClass< JPointer_t >

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

This class augments the class JRootClass with addressing capabilities.

Definition at line 424 of file JRootClass.hh.

Member Typedef Documentation

◆ JAddress_t

template<class JPointer_t>
typedef JAddress<JPointer_t> JROOT::JRootAddressableClass< JPointer_t >::JAddress_t

Definition at line 428 of file JRootClass.hh.

◆ pointer_type

template<class JPointer_t>
typedef JAddress_t::pointer_type JROOT::JRootAddressableClass< JPointer_t >::pointer_type

Definition at line 429 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootAddressableClass() [1/2]

template<class JPointer_t>
template<class T >
JROOT::JRootAddressableClass< JPointer_t >::JRootAddressableClass ( T &  object)
inline

Constructor.

Parameters
objecttemplate object

Definition at line 437 of file JRootClass.hh.

437  :
438  JRootClass(JType<T>()),
439  JAddress_t((pointer_type) &object)
440  {}

◆ JRootAddressableClass() [2/2]

template<class JPointer_t>
JROOT::JRootAddressableClass< JPointer_t >::JRootAddressableClass ( const JRootClass rc,
pointer_type  address 
)
inlineprotected

Constructor.

Parameters
rcROOT class
addressaddress

Definition at line 516 of file JRootClass.hh.

516  :
517  JRootClass(rc),
519  {}

Member Function Documentation

◆ getAddress()

template<class JPointer_t>
pointer_type JROOT::JRootAddressableClass< JPointer_t >::getAddress ( ) const
inline

Get address.

Returns
pointer to object

Definition at line 448 of file JRootClass.hh.

449  {
450  return this->address + getOffset();
451  }

◆ is_valid()

template<class JPointer_t>
bool JROOT::JRootAddressableClass< JPointer_t >::is_valid ( ) const
inline

Check validity of this addressable class.

Returns
true if valid addressable class; else false

Definition at line 459 of file JRootClass.hh.

460  {
461  return (JRootClass::is_valid() && this->address != NULL);
462  }

◆ find()

template<class JPointer_t>
JRootAddressableClass JROOT::JRootAddressableClass< JPointer_t >::find ( const char *  name) const
inline

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

Parameters
namename of base class or data member

Definition at line 470 of file JRootClass.hh.

471  {
472  return JRootAddressableClass(JRootClass::find(name), this->address);
473  }

◆ get() [1/2]

template<class JPointer_t>
JRootAddressableClass JROOT::JRootAddressableClass< JPointer_t >::get ( const TDataMember &  data_member) const
inline

Get addressable class of given data member.

Parameters
data_memberdata member

Definition at line 481 of file JRootClass.hh.

482  {
483  return JRootAddressableClass(JRootClass::get(data_member), this->address);
484  }

◆ get() [2/2]

template<class JPointer_t>
JRootAddressableClass JROOT::JRootAddressableClass< JPointer_t >::get ( const TBaseClass &  base_class) const
inline

Get addressable class of given base class.

Parameters
base_classbase class

Definition at line 492 of file JRootClass.hh.

493  {
494  return JRootAddressableClass(JRootClass::get(base_class), this->address);
495  }

◆ operator[]()

template<class JPointer_t>
JRootAddressableClass JROOT::JRootAddressableClass< JPointer_t >::operator[] ( const char *  name) const
inline

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

Parameters
namename of base class or data member

Definition at line 503 of file JRootClass.hh.

504  {
505  return this->find(name);
506  }

◆ is_class() [1/3]

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

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)
inlinestaticinherited

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)
inlinestaticinherited

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)
inlinestaticinherited

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)
inlinestaticinherited

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)
inlinestaticinherited

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)
inlinestaticinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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  }

◆ equals()

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

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  }

◆ print() [1/3]

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

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
inlineprotectedinherited

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 
)
inlinestaticprotectedinherited

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
protectedinherited

pointer to ROOT dictionary

Definition at line 310 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protectedinherited

offset with respect to data structure [B]

Definition at line 311 of file JRootClass.hh.

◆ address

template<class JPointer_t>
pointer_type JROOT::JAddress< JPointer_t >::address
inherited

Definition at line 414 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::JAddress::address
pointer_type address
Definition: JRootClass.hh:414
JROOT::JRootAddressableClass::JAddress_t
JAddress< JPointer_t > JAddress_t
Definition: JRootClass.hh:428
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
JROOT::JRootAddressableClass::JRootAddressableClass
JRootAddressableClass(T &object)
Constructor.
Definition: JRootClass.hh:437
std
Definition: jaanetDictionary.h:36
JROOT::JRootAddressableClass::pointer_type
JAddress_t::pointer_type pointer_type
Definition: JRootClass.hh:429
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::JRootAddressableClass::find
JRootAddressableClass find(const char *name) const
Find addressable base class or data member with given name within current class.
Definition: JRootClass.hh:470
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