Jpp test-rotations-old
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 530 of file JRootClass.hh.

Member Typedef Documentation

◆ pointer_type

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

Type definition of address.

Definition at line 390 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootReadableClass() [1/4]

JROOT::JRootReadableClass::JRootReadableClass ( )
inline

Default constructor.

Definition at line 536 of file JRootClass.hh.

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

◆ JRootReadableClass() [2/4]

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

Constructor.

Parameters
objecttemplate object

Definition at line 547 of file JRootClass.hh.

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

◆ JRootReadableClass() [3/4]

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

Copy constructor.

Parameters
rcROOT addressable class

Definition at line 557 of file JRootClass.hh.

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

◆ JRootReadableClass() [4/4]

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

Constructor.

Parameters
dictionarypointer to dictionary
addressaddress

Definition at line 568 of file JRootClass.hh.

568 :
569 JRootAddressableClass<char *>(JRootClass(dictionary,0), address)
570 {}
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 579 of file JRootClass.hh.

580 {
581 if (static_cast<const JRootClass&>(*this) == JRootClass(JType<T>())) {
582 return * (const T*) this->getAddress();
583 } else {
584 THROW(JCastException, "JRootReadableClass::operator const T&");
585 }
586 }
#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 595 of file JRootClass.hh.

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

◆ getAddress()

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

Get address.

Returns
pointer to object

Definition at line 409 of file JRootClass.hh.

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

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

421 {
422 return (JRootClass::is_valid() && this->address != NULL);
423 }
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 432 of file JRootClass.hh.

433 {
435 }
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 161 of file JRootClass.hh.

162 {
163 if (name != NULL && strlen(name) != 0) {
164
165 if (strcmp(getTypename(), name) == 0) {
166 return *this;
167 }
168
169 if (this->getClass() != NULL) {
170
171 // check for data members
172
173 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
174 if (( option && strcmp (p->GetName(), name) == 0) ||
175 (!option && strcasecmp(p->GetName(), name) == 0)) {
176 return this->get(*p);
177 }
178 }
179
180 // check for base classes
181
182 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
183
184 if (JRoot::is_class(*p) && !JRoot::is_STLcontainer(*p)) {
185
186 JRootClass rcs = this->get(*p);
187
188 rcs = rcs.find(name, option);
189
190 if (rcs.is_valid()) {
191 return rcs;
192 }
193 }
194 }
195 }
196 }
197
198 return JRootClass(); // invalid value
199 }
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 444 of file JRootClass.hh.

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

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

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

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

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

◆ getDictionary()

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

Get dictionary.

Returns
pointer to dictionary

Definition at line 87 of file JRootClass.hh.

88 {
89 return dictionary;
90 }

◆ getOffset()

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

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 98 of file JRootClass.hh.

99 {
100 return offset;
101 }
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 109 of file JRootClass.hh.

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

◆ getTypename()

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

Get type name.

Returns
type name

Definition at line 120 of file JRootClass.hh.

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

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

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

◆ print() [1/3]

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

Print ROOT class information.

Parameters
outoutput stream

Definition at line 233 of file JRootClass.hh.

234 {
235 print(out, getTypename());
236 }
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 260 of file JRootClass.hh.

261 {
262 if (this->is_valid()) {
263
264 print(out, prefix, this->getTypename());
265
266 if (this->getClass() != NULL) {
267
268 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
269 if (!JRoot::is_STLcontainer(*p))
270 this->get(*p).print(out, prefix + "::" + p->GetName());
271 else
272 print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
273 }
274
275 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
277 this->get(*p).print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName());
278 else
279 print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
280 }
281 }
282 }
283 }
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 293 of file JRootClass.hh.

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

Member Data Documentation

◆ address

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

Definition at line 523 of file JRootClass.hh.

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protectedinherited

pointer to ROOT dictionary

Definition at line 241 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protectedinherited

offset with respect to data structure [B]

Definition at line 242 of file JRootClass.hh.


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