Jpp
 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 | Friends | 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:
JROOT::JRootAddressableClass< is_const > JROOT::JRootAddressableClass< false > JROOT::JRootAddressableClass< true > JROOT::JRootClassReader JROOT::JRootClassWriter

Public Member Functions

template<class T >
 JRootClass (const JType< T > &type)
 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...
 
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...
 

Friends

bool operator== (const JRootClass &first, const JRootClass &second)
 Test equality of ROOT classes. 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

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

Constructor.

Parameters
typedata type

Definition at line 134 of file JRootClass.hh.

134  :
135  dictionary(TDictionary::GetDictionary(typeid(T))),
136  offset(0)
137  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:299
JROOT::JRootClass::JRootClass ( )
inlineprotected

Default constructor.

Definition at line 305 of file JRootClass.hh.

305  :
306  dictionary(NULL),
307  offset(0)
308  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:299
JROOT::JRootClass::JRootClass ( TDictionary *  dictionary,
int  offset 
)
inlineprotected

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 317 of file JRootClass.hh.

318  :
320  offset (offset)
321  {}
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:299

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

46  {
47  return (class_name != NULL &&
48  strcmp(class_name, TClass ::Class()->GetName()) != 0 &&
49  strcmp(class_name, TObject::Class()->GetName()) != 0 &&
50  strcmp(class_name, "fgIsA") != 0 &&
51  strcmp(class_name, "atomic<TClass*>") != 0);
52  }
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 61 of file JRootClass.hh.

62  {
63  return is_class(base_class.GetName());
64  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:45
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 73 of file JRootClass.hh.

74  {
75  return is_class(data_member.GetTypeName());
76  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:45
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 85 of file JRootClass.hh.

86  {
87  return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
88  }
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 97 of file JRootClass.hh.

98  {
99  return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
100  }
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 109 of file JRootClass.hh.

110  {
111  return (strcmp(data_member.GetFullTypeName(), "string") == 0 ||
112  strcmp(data_member.GetFullTypeName(), "const string") == 0);
113  }
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 122 of file JRootClass.hh.

123  {
124  return (data_member.Property() & kIsStatic);
125  }
TDictionary* JROOT::JRootClass::getDictionary ( ) const
inline

Get dictionary.

Returns
pointer to dictionary

Definition at line 145 of file JRootClass.hh.

146  {
147  return dictionary;
148  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
int JROOT::JRootClass::getOffset ( ) const
inline

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 156 of file JRootClass.hh.

157  {
158  return offset;
159  }
int offset
offset with respect to data structure [B]
Definition: JRootClass.hh:299
TClass* JROOT::JRootClass::getClass ( ) const
inline

Get class.

Returns
pointer to class

Definition at line 167 of file JRootClass.hh.

168  {
169  return dynamic_cast<TClass*>(dictionary);
170  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
const char* JROOT::JRootClass::getTypename ( ) const
inline

Get type name.

Returns
type name

Definition at line 178 of file JRootClass.hh.

179  {
180  if (dictionary != NULL)
181  return dictionary->GetName();
182  else
183  return NULL;
184  }
TDictionary * dictionary
pointer to ROOT dictionary
Definition: JRootClass.hh:298
bool JROOT::JRootClass::is_valid ( ) const
inline

Check validity of this class.

Returns
true if valid class; else false

Definition at line 192 of file JRootClass.hh.

193  {
194  return (this->getDictionary() != NULL && is_class(this->getTypename()));
195  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:45
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:178
TDictionary * getDictionary() const
Get dictionary.
Definition: JRootClass.hh:145
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 219 of file JRootClass.hh.

220  {
221  if (name != NULL && strlen(name) != 0) {
222 
223  if (strcmp(getTypename(), name) == 0) {
224  return *this;
225  }
226 
227  if (this->getClass() != NULL) {
228 
229  // check for data member
230 
231  const TDataMember* p = this->getClass()->GetDataMember(name);
232 
233  if (p != NULL) {
234  return this->get(*p);
235  }
236 
237  // check for base classes
238 
239  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
240 
241  for (TBaseClass* p; (p = (TBaseClass*) i->Next()) != NULL; ) {
242 
243  if (is_class(*p) && !is_STLcontainer(*p)) {
244 
245  JRootClass cls = this->get(*p);
246 
247  cls = cls.find(name);
248 
249  if (cls.is_valid()) {
250  return cls;
251  }
252  }
253  }
254  }
255  }
256 
257  return JRootClass(); // invalid value
258  }
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition: JRootClass.hh:85
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:45
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:178
JRootClass()
Default constructor.
Definition: JRootClass.hh:305
bool is_valid() const
Check validity of this class.
Definition: JRootClass.hh:192
TClass * getClass() const
Get class.
Definition: JRootClass.hh:167
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition: JRootClass.hh:38
JRootClass find(const char *name) const
Find base class or data member with given name within current class.
Definition: JRootClass.hh:219
JRootClass JROOT::JRootClass::get ( const TDataMember &  data_member) const
inline

Get ROOT class of given data member.

Parameters
data_memberdata member

Definition at line 266 of file JRootClass.hh.

267  {
268  return JRootClass(TDictionary::GetDictionary(data_member.GetTypeName()),
269  this->getOffset() + data_member.GetOffset());
270  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:156
JRootClass()
Default constructor.
Definition: JRootClass.hh:305
JRootClass JROOT::JRootClass::get ( const TBaseClass &  base_class) const
inline

Get ROOT class of given base class.

Parameters
base_classbase class

Definition at line 278 of file JRootClass.hh.

279  {
280  return JRootClass(TDictionary::GetDictionary(base_class.GetName()),
281  this->getOffset() + const_cast<TBaseClass&>(base_class).GetDelta());
282  }
int getOffset() const
Get offset of this class with respect to parent class.
Definition: JRootClass.hh:156
JRootClass()
Default constructor.
Definition: JRootClass.hh:305
void JROOT::JRootClass::print ( std::ostream &  out) const
inline

Print ROOT class information.

Parameters
outoutput stream

Definition at line 290 of file JRootClass.hh.

291  {
292  print(out, getTypename());
293  }
void print(std::ostream &out) const
Print ROOT class information.
Definition: JRootClass.hh:290
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:178
void JROOT::JRootClass::print ( std::ostream &  out,
const std::string &  prefix 
) const
inlineprotected

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 330 of file JRootClass.hh.

331  {
332  if (this->is_valid()) {
333 
334  print(out, prefix, this->getTypename());
335 
336  if (this->getClass() != NULL) {
337 
338  if (this->getClass()->GetListOfBases() != NULL) {
339 
340  TIterator* i = this->getClass()->GetListOfBases()->MakeIterator();
341 
342  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
343  if (!is_STLcontainer(*p))
344  this->get(*p).print(out, prefix + "::" + p->GetName());
345  else
346  print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
347  }
348  }
349 
350  if (this->getClass()->GetListOfDataMembers() != NULL) {
351 
352  TIterator* i = this->getClass()->GetListOfDataMembers()->MakeIterator();
353 
354  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
355  if (!is_STLstring(*p) && !is_STLcontainer(*p))
356  this->get(*p).print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName());
357  else
358  print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
359  }
360  }
361  }
362  }
363  }
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition: JRootClass.hh:85
void print(std::ostream &out) const
Print ROOT class information.
Definition: JRootClass.hh:290
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:178
static bool is_STLstring(const TDataMember &data_member)
Check if data member is STL string.
Definition: JRootClass.hh:109
bool is_valid() const
Check validity of this class.
Definition: JRootClass.hh:192
TClass * getClass() const
Get class.
Definition: JRootClass.hh:167
static bool is_static(const TDataMember &data_member)
Check if data member is static.
Definition: JRootClass.hh:122
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 373 of file JRootClass.hh.

374  {
375  using namespace std;
376 
377  out << name << " " << '(' << type << ')' << endl;
378  }

Friends And Related Function Documentation

bool operator== ( const JRootClass first,
const JRootClass second 
)
friend

Test equality of ROOT classes.

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

Definition at line 205 of file JRootClass.hh.

207  {
208  return (first .getTypename() != NULL &&
209  second.getTypename() != NULL &&
210  strcmp(first.getTypename(), second.getTypename()) == 0);
211  }
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:178

Member Data Documentation

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 298 of file JRootClass.hh.

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 299 of file JRootClass.hh.


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