Jpp  16.0.0-rc.1
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 40 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 139 of file JRootClass.hh.

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

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

Default constructor.

Definition at line 320 of file JRootClass.hh.

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

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 332 of file JRootClass.hh.

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

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

50  {
51  return (class_name != NULL &&
52  strcmp(class_name, TClass ::Class()->GetName()) != 0 &&
53  strcmp(class_name, TObject::Class()->GetName()) != 0 &&
54  strcmp(class_name, "_Rb_tree_node_base") != 0 &&
55  strcmp(class_name, "fgIsA") != 0 &&
56  strcmp(class_name, "atomic<TClass*>") != 0);
57  }
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 66 of file JRootClass.hh.

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

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

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

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

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

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

Get dictionary.

Returns
pointer to dictionary

Definition at line 162 of file JRootClass.hh.

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

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 173 of file JRootClass.hh.

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

Get class.

Returns
pointer to class

Definition at line 184 of file JRootClass.hh.

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

Get type name.

Returns
type name

Definition at line 195 of file JRootClass.hh.

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

Check validity of this class.

Returns
true if valid class; else false

Definition at line 209 of file JRootClass.hh.

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

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

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

Get ROOT class of given data member.

Parameters
data_memberdata member

Definition at line 281 of file JRootClass.hh.

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

Get ROOT class of given base class.

Parameters
base_classbase class

Definition at line 293 of file JRootClass.hh.

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

Print ROOT class information.

Parameters
outoutput stream

Definition at line 305 of file JRootClass.hh.

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

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 345 of file JRootClass.hh.

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

389  {
390  using namespace std;
391 
392  out << name << " " << '(' << type << ')' << endl;
393  }
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42

Member Data Documentation

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 313 of file JRootClass.hh.

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 314 of file JRootClass.hh.


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