Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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< JFirst_t, JSecond_t > 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 39 of file JRootClass.hh.

Constructor & Destructor Documentation

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

Constructor.

Parameters
typedata type

Definition at line 138 of file JRootClass.hh.

138  :
139  dictionary(TDictionary::GetDictionary(typeid(JType_t))),
140  offset(0)
141  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:313
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 150 of file JRootClass.hh.

150  :
151  dictionary(TDictionary::GetDictionary(typeid(JType_t))),
152  offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
153  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:313
JROOT::JRootClass::JRootClass ( )
inlineprotected

Default constructor.

Definition at line 319 of file JRootClass.hh.

319  :
320  dictionary(NULL),
321  offset(0)
322  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:313
JROOT::JRootClass::JRootClass ( TDictionary *  dictionary,
int  offset 
)
inlineprotected

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 331 of file JRootClass.hh.

332  :
334  offset (offset)
335  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:313

Member Function Documentation

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 48 of file JRootClass.hh.

49  {
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);
56  }
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 65 of file JRootClass.hh.

66  {
67  return is_class(base_class.GetName());
68  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:48
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 77 of file JRootClass.hh.

78  {
79  return is_class(data_member.GetTypeName());
80  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:48
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 89 of file JRootClass.hh.

90  {
91  return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
92  }
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 101 of file JRootClass.hh.

102  {
103  return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
104  }
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 113 of file JRootClass.hh.

114  {
115  return (strcmp(data_member.GetFullTypeName(), "string") == 0 ||
116  strcmp(data_member.GetFullTypeName(), "const string") == 0);
117  }
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 126 of file JRootClass.hh.

127  {
128  return (data_member.Property() & kIsStatic);
129  }
TDictionary* JROOT::JRootClass::getDictionary ( ) const
inline

Get dictionary.

Returns
pointer to dictionary

Definition at line 161 of file JRootClass.hh.

162  {
163  return dictionary;
164  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
int JROOT::JRootClass::getOffset ( ) const
inline

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 172 of file JRootClass.hh.

173  {
174  return offset;
175  }
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:313
TClass* JROOT::JRootClass::getClass ( ) const
inline

Get class.

Returns
pointer to class

Definition at line 183 of file JRootClass.hh.

184  {
185  return dynamic_cast<TClass*>(dictionary);
186  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
const char* JROOT::JRootClass::getTypename ( ) const
inline

Get type name.

Returns
type name

Definition at line 194 of file JRootClass.hh.

195  {
196  if (dictionary != NULL)
197  return dictionary->GetName();
198  else
199  return NULL;
200  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:312
bool JROOT::JRootClass::is_valid ( ) const
inline

Check validity of this class.

Returns
true if valid class; else false

Definition at line 208 of file JRootClass.hh.

209  {
210  return (this->getDictionary() != NULL && is_class(this->getTypename()));
211  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:48
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:194
TDictionary * getDictionary() const
Get dictionary.
Definition: JRootClass.hh:161
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 220 of file JRootClass.hh.

221  {
222  return (this-> getTypename() != NULL &&
223  object.getTypename() != NULL &&
224  strcmp(this->getTypename(), object.getTypename()) == 0);
225  }
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:194
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 233 of file JRootClass.hh.

234  {
235  if (name != NULL && strlen(name) != 0) {
236 
237  if (strcmp(getTypename(), name) == 0) {
238  return *this;
239  }
240 
241  if (this->getClass() != NULL) {
242 
243  // check for data member
244 
245  const TDataMember* p = this->getClass()->GetDataMember(name);
246 
247  if (p != NULL) {
248  return this->get(*p);
249  }
250 
251  // check for base classes
252 
253  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
254 
255  for (TBaseClass* p; (p = (TBaseClass*) i->Next()) != NULL; ) {
256 
257  if (is_class(*p) && !is_STLcontainer(*p)) {
258 
259  JRootClass rcs = this->get(*p);
260 
261  rcs = rcs.find(name);
262 
263  if (rcs.is_valid()) {
264  return rcs;
265  }
266  }
267  }
268  }
269  }
270 
271  return JRootClass(); // invalid value
272  }
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition: JRootClass.hh:89
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:48
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:194
JRootClass()
Default constructor.
Definition: JRootClass.hh:319
bool is_valid() const
Check validity of this class.
Definition: JRootClass.hh:208
then echo n User name
Definition: JCookie.sh:45
TClass * getClass() const
Get class.
Definition: JRootClass.hh:183
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:39
JRootClass find(const char *name) const
Find base class or data member with given name within current class.
Definition: JRootClass.hh:233
JRootClass JROOT::JRootClass::get ( const TDataMember &  data_member) const
inline

Get ROOT class of given data member.

Parameters
data_memberdata member

Definition at line 280 of file JRootClass.hh.

281  {
282  return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
283  this->getOffset() + data_member.GetOffset());
284  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:172
JRootClass()
Default constructor.
Definition: JRootClass.hh:319
JRootClass JROOT::JRootClass::get ( const TBaseClass &  base_class) const
inline

Get ROOT class of given base class.

Parameters
base_classbase class

Definition at line 292 of file JRootClass.hh.

293  {
294  return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
295  this->getOffset() + const_cast<TBaseClass&>(base_class).GetDelta());
296  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:172
JRootClass()
Default constructor.
Definition: JRootClass.hh:319
void JROOT::JRootClass::print ( std::ostream &  out) const
inline

Print ROOT class information.

Parameters
outoutput stream

Definition at line 304 of file JRootClass.hh.

305  {
306  print(out, getTypename());
307  }
void print(std::ostream &out) const
Print ROOT class information.
Definition: JRootClass.hh:304
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:194
void JROOT::JRootClass::print ( std::ostream &  out,
const std::string &  prefix 
) const
inlineprotected

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 344 of file JRootClass.hh.

345  {
346  if (this->is_valid()) {
347 
348  print(out, prefix, this->getTypename());
349 
350  if (this->getClass() != NULL) {
351 
352  if (this->getClass()->GetListOfBases() != NULL) {
353 
354  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
355 
356  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
357  if (!is_STLcontainer(*p))
358  this->get(*p).print(out, prefix + "::" + p->GetName());
359  else
360  print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
361  }
362  }
363 
364  if (this->getClass()->GetListOfDataMembers() != NULL) {
365 
366  TIterator* i = this->getClass()->GetListOfDataMembers()->MakeIterator();
367 
368  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
369  if (!is_STLstring(*p) && !is_STLcontainer(*p))
370  this->get(*p).print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName());
371  else
372  print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
373  }
374  }
375  }
376  }
377  }
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition: JRootClass.hh:89
void print(std::ostream &out) const
Print ROOT class information.
Definition: JRootClass.hh:304
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:194
static bool is_STLstring(const TDataMember &data_member)
Check if data member is STL string.
Definition: JRootClass.hh:113
bool is_valid() const
Check validity of this class.
Definition: JRootClass.hh:208
TClass * getClass() const
Get class.
Definition: JRootClass.hh:183
static bool is_static(const TDataMember &data_member)
Check if data member is static.
Definition: JRootClass.hh:126
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 387 of file JRootClass.hh.

388  {
389  using namespace std;
390 
391  out << name << " " << '(' << type << ')' << endl;
392  }
then echo n User name
Definition: JCookie.sh:45

Member Data Documentation

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 312 of file JRootClass.hh.

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 313 of file JRootClass.hh.


The documentation for this struct was generated from the following file: