Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JRootReadableClass Struct Reference

ROOT class for reading into object. More...

#include <JRootClass.hh>

Inheritance diagram for JROOT::JRootReadableClass:
JROOT::JRootAddressableClass< char * > JROOT::JRootClass JLANG::JEquals< JFirst_t, JSecond_t > JROOT::JBranchClass

Public Types

typedef char * pointer_type
 Type definition of address.
 

Public Member Functions

 JRootReadableClass ()
 Default constructor.
 
template<class T >
 JRootReadableClass (T &object)
 Constructor.
 
 JRootReadableClass (const JRootAddressableClass< char * > &rc)
 Copy constructor.
 
 JRootReadableClass (TDictionary *dictionary, pointer_type address)
 Constructor.
 
template<class T >
 operator const T & () const
 Type conversion operator.
 
template<class T >
 operator T& ()
 Type conversion operator.
 
pointer_type getAddress () const
 Get address.
 
bool is_valid () const
 Check validity of this addressable class.
 
JRootAddressableClass find (const char *const name) const
 Find addressable base class or data member with given name within current class.
 
JRootClass find (const char *const name, const bool option=true) const
 Find base class or data member with given name within current class.
 
JRootAddressableClass get (const TDataMember &object) const
 Get addressable class of given data member.
 
JRootAddressableClass get (const TBaseClass &object) const
 Get addressable class of given base class.
 
JRootAddressableClass operator[] (const char *const name) const
 Find addressable base class or data member with given name within current class.
 
TDictionary * getDictionary () const
 Get dictionary.
 
int getOffset () const
 Get offset of this class with respect to parent class.
 
TClass * getClass () const
 Get class.
 
const char * getTypename () const
 Get type name.
 
bool equals (const JRootClass &object) const
 Test equality of ROOT classes.
 
void print (std::ostream &out) const
 Print ROOT class information.
 

Protected Member Functions

void print (std::ostream &out, const std::string &prefix) const
 Print ROOT class information.
 

Static Protected Member Functions

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

Protected Attributes

pointer_type address
 
TDictionary * dictionary
 pointer to ROOT dictionary
 
int offset
 offset with respect to data structure [B]
 

Detailed Description

ROOT class for reading into object.

Definition at line 529 of file JRootClass.hh.

Member Typedef Documentation

◆ pointer_type

char * JROOT::JRootAddressableClass< char * >::pointer_type
inherited

Type definition of address.

Definition at line 389 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootReadableClass() [1/4]

JROOT::JRootReadableClass::JRootReadableClass ( )
inline

Default constructor.

Definition at line 535 of file JRootClass.hh.

535 :
536 JRootAddressableClass<char *>()
537 {}

◆ JRootReadableClass() [2/4]

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

Constructor.

Parameters
objecttemplate object

Definition at line 546 of file JRootClass.hh.

546 :
547 JRootAddressableClass<char *>(object)
548 {}

◆ JRootReadableClass() [3/4]

JROOT::JRootReadableClass::JRootReadableClass ( const JRootAddressableClass< char * > & rc)
inline

Copy constructor.

Parameters
rcROOT addressable class

Definition at line 556 of file JRootClass.hh.

556 :
557 JRootAddressableClass<char *>(rc)
558 {}

◆ JRootReadableClass() [4/4]

JROOT::JRootReadableClass::JRootReadableClass ( TDictionary * dictionary,
pointer_type address )
inline

Constructor.

Parameters
dictionarypointer to dictionary
addressaddress

Definition at line 567 of file JRootClass.hh.

567 :
568 JRootAddressableClass<char *>(JRootClass(dictionary,0), address)
569 {}
TDictionary * dictionary
pointer to ROOT dictionary
JRootClass()
Default constructor.

Member Function Documentation

◆ operator const T &()

template<class T >
JROOT::JRootReadableClass::operator const T & ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 578 of file JRootClass.hh.

579 {
580 if (static_cast<const JRootClass&>(*this) == JRootClass(JType<T>())) {
581 return * (const T*) this->getAddress();
582 } else {
583 THROW(JCastException, "JRootReadableClass::operator const T&");
584 }
585 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ operator T&()

template<class T >
JROOT::JRootReadableClass::operator T& ( )
inline

Type conversion operator.

Returns
value

Definition at line 594 of file JRootClass.hh.

595 {
596 if (static_cast<const JRootClass&>(*this) == JRootClass(JType<T>())) {
597 return * (T*) this->getAddress();
598 } else {
599 THROW(JCastException, "JRootReadableClass::operator T&");
600 }
601 }

◆ getAddress()

pointer_type JROOT::JRootAddressableClass< char * >::getAddress ( ) const
inlineinherited

Get address.

Returns
pointer to object

Definition at line 408 of file JRootClass.hh.

409 {
410 return this->address + getOffset();
411 }
int getOffset() const
Get offset of this class with respect to parent class.
Definition JRootClass.hh:97

◆ is_valid()

bool JROOT::JRootAddressableClass< char * >::is_valid ( ) const
inlineinherited

Check validity of this addressable class.

Returns
true if valid addressable class; else false

Definition at line 419 of file JRootClass.hh.

420 {
421 return (JRootClass::is_valid() && this->address != NULL);
422 }
bool is_valid() const
Check validity of this class.

◆ find() [1/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::find ( const char *const name) const
inlineinherited

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

Parameters
namename of base class or data member
Returns
ROOT addressable class

Definition at line 431 of file JRootClass.hh.

432 {
434 }
JRootClass find(const char *const name, const bool option=true) const
Find base class or data member with given name within current class.

◆ find() [2/2]

JRootClass JROOT::JRootClass::find ( const char *const name,
const bool option = true ) const
inlineinherited

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

Parameters
namename of base class or data member
optioncase insensitive
Returns
ROOT class

Definition at line 160 of file JRootClass.hh.

161 {
162 if (name != NULL && strlen(name) != 0) {
163
164 if (strcmp(getTypename(), name) == 0) {
165 return *this;
166 }
167
168 if (this->getClass() != NULL) {
169
170 // check for data members
171
172 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
173 if (( option && strcmp (p->GetName(), name) == 0) ||
174 (!option && strcasecmp(p->GetName(), name) == 0)) {
175 return this->get(*p);
176 }
177 }
178
179 // check for base classes
180
181 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
182
183 if (JRoot::is_class(*p) && !JRoot::is_STLcontainer(*p)) {
184
185 JRootClass rcs = this->get(*p);
186
187 rcs = rcs.find(name, option);
188
189 if (rcs.is_valid()) {
190 return rcs;
191 }
192 }
193 }
194 }
195 }
196
197 return JRootClass(); // invalid value
198 }
const char * getTypename() const
Get type name.
TClass * getClass() const
Get class.
JRootClass get(const TDataMember &object) const
Get ROOT class of given data member.
static bool is_class(const char *const name)
Check name of class against internal ROOT class names.
Definition JRoot.hh:30
static bool is_STLcontainer(const TBaseClass &object)
Check if base class is STL container.
Definition JRoot.hh:72

◆ get() [1/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::get ( const TDataMember & object) const
inlineinherited

Get addressable class of given data member.

Parameters
objectdata member
Returns
ROOT addressable class

Definition at line 443 of file JRootClass.hh.

444 {
445 using namespace std;
446
447 if (object.IsaPointer()) {
448
449 char* po = NULL;
450
451 memcpy(&po, this->getAddress() + object.GetOffset(), sizeof(char*));
452
453 return JRootAddressableClass(JRootClass(TDictionary::GetDictionary(object.GetTypeName())), po);
454
455 } else if (strstr(object.GetTypeName(), "unique_ptr") != NULL) {
456
457 char* po = NULL;
458
459 memcpy(&po, this->getAddress() + object.GetOffset(), sizeof(char*));
460
461 string buffer(object.GetTypeName());
462
463 const string::size_type il = buffer.find_first_of("<");
464 const string::size_type ir = buffer.find_first_of(">,");
465
466 buffer = buffer.substr(il + 1, ir - il - 1);
467
468 return JRootAddressableClass(JRootClass(TDictionary::GetDictionary(buffer.c_str())), po);
469
470 } else {
471
472 return JRootAddressableClass(JRootClass::get(object), this->address);
473 }
474 }

◆ get() [2/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::get ( const TBaseClass & object) const
inlineinherited

Get addressable class of given base class.

Parameters
objectbase class
Returns
ROOT addressable class

Definition at line 483 of file JRootClass.hh.

484 {
485 return JRootAddressableClass(JRootClass::get(object), this->address);
486 }

◆ operator[]()

JRootAddressableClass JROOT::JRootAddressableClass< char * >::operator[] ( const char *const name) const
inlineinherited

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

Parameters
namename of base class or data member
Returns
ROOT addressable class

Definition at line 495 of file JRootClass.hh.

496 {
497 return this->find(name);
498 }
JRootAddressableClass find(const char *const name) const

◆ getDictionary()

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

Get dictionary.

Returns
pointer to dictionary

Definition at line 86 of file JRootClass.hh.

87 {
88 return dictionary;
89 }

◆ getOffset()

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

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 97 of file JRootClass.hh.

98 {
99 return offset;
100 }
int offset
offset with respect to data structure [B]

◆ getClass()

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

Get class.

Returns
pointer to class

Definition at line 108 of file JRootClass.hh.

109 {
110 return dynamic_cast<TClass*>(dictionary);
111 }

◆ getTypename()

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

Get type name.

Returns
type name

Definition at line 119 of file JRootClass.hh.

120 {
121 if (dictionary != NULL)
122 return dictionary->GetName();
123 else
124 return NULL;
125 }

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

146 {
147 return (this-> getTypename() != NULL &&
148 object.getTypename() != NULL &&
149 strcmp(this->getTypename(), object.getTypename()) == 0);
150 }

◆ print() [1/3]

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

Print ROOT class information.

Parameters
outoutput stream

Definition at line 232 of file JRootClass.hh.

233 {
234 print(out, getTypename());
235 }
void print(std::ostream &out) const
Print ROOT class information.

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

260 {
261 if (this->is_valid()) {
262
263 print(out, prefix, this->getTypename());
264
265 if (this->getClass() != NULL) {
266
267 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
268 if (!JRoot::is_STLcontainer(*p))
269 this->get(*p).print(out, prefix + "::" + p->GetName());
270 else
271 print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
272 }
273
274 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
276 this->get(*p).print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName());
277 else
278 print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
279 }
280 }
281 }
282 }
static bool is_static(const TDataMember &object)
Check if data member is static.
Definition JRoot.hh:109
static bool is_STLstring(const TDataMember &object)
Check if data member is STL string.
Definition JRoot.hh:96

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

293 {
294 using namespace std;
295
296 out << name << " " << '(' << type << ')' << endl;
297 }

Member Data Documentation

◆ address

pointer_type JROOT::JRootAddressableClass< char * >::address
protectedinherited

Definition at line 522 of file JRootClass.hh.

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protectedinherited

pointer to ROOT dictionary

Definition at line 240 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protectedinherited

offset with respect to data structure [B]

Definition at line 241 of file JRootClass.hh.


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