Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JRootComparator Class Reference

ROOT comparator. More...

#include <JRootComparator.hh>

Inheritance diagram for JROOT::JRootComparator:
std::map< std::string, std::shared_ptr< JAbstractComparator > >

Public Member Functions

 JRootComparator ()
 Default constructor.
 
template<class T >
bool operator() (const T &first, const T &second) const
 Compare objects.
 
template<class T >
void operator() (const char *const name, const JType< T > &type)
 Addition of class.
 

Public Attributes

int debug = 0
 debug level
 

Protected Member Functions

bool compare (const JRootWritableClass &first, const JRootWritableClass &second) const
 Compare objects.
 

Detailed Description

ROOT comparator.

Definition at line 78 of file JRootComparator.hh.

Constructor & Destructor Documentation

◆ JRootComparator()

JROOT::JRootComparator::JRootComparator ( )
inline

Default constructor.

Definition at line 85 of file JRootComparator.hh.

86 {
87 handler(*this);
88 }
void handler(JType_t &object)
Apply ROOT types handler to given object.

Member Function Documentation

◆ operator()() [1/2]

template<class T >
bool JROOT::JRootComparator::operator() ( const T & first,
const T & second ) const
inline

Compare objects.

Parameters
firstfirst object
secondsecond object
Returns
true if objects are equal; else false

Definition at line 99 of file JRootComparator.hh.

100 {
101 using namespace std;
102
103 DEBUG("compare: " << JRootWritableClass(first).getTypename() << ' ' << JRootWritableClass(second).getTypename() << endl << endl);
104
105 return this->compare(JRootWritableClass(first), JRootWritableClass(second));
106 }
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
bool compare(const JRootWritableClass &first, const JRootWritableClass &second) const
Compare objects.

◆ operator()() [2/2]

template<class T >
void JROOT::JRootComparator::operator() ( const char *const name,
const JType< T > & type )
inline

Addition of class.

Parameters
namedata name
typedata type

Definition at line 116 of file JRootComparator.hh.

117 {
118 this->insert(value_type(name, new JObjectComparator<T>()));
119 }

◆ compare()

bool JROOT::JRootComparator::compare ( const JRootWritableClass & first,
const JRootWritableClass & second ) const
inlineprotected

Compare objects.

Parameters
firstfirst object
secondsecond object
Returns
true if objects are equal; else false

Definition at line 132 of file JRootComparator.hh.

133 {
134 using namespace std;
135
136 if (first .is_valid() &&
137 second.is_valid()) {
138
139 const_iterator i1 = this->find(first .getTypename());
140 const_iterator i2 = this->find(second.getTypename());
141
142 if (i1 != this->end() &&
143 i2 != this->end() &&
144 i1 == i2) {
145
146 if (!i1->second->equals(first.getAddress(), second.getAddress())) {
147 return false;
148 }
149
150 } else if (first .getClass() != NULL &&
151 second.getClass() != NULL) {
152
153 if (first .getClass()->GetCollectionType() != ROOT::ESTLType::kNotSTL && first .getClass()->GetCollectionProxy() != NULL &&
154 second.getClass()->GetCollectionType() != ROOT::ESTLType::kNotSTL && second.getClass()->GetCollectionProxy() != NULL) {
155
156 std::unique_ptr<TVirtualCollectionProxy> p1(first .getClass()->GetCollectionProxy()->Generate());
157 std::unique_ptr<TVirtualCollectionProxy> p2(second.getClass()->GetCollectionProxy()->Generate());
158
159 p1->PushProxy(const_cast<char*>(first .getAddress()));
160 p2->PushProxy(const_cast<char*>(second.getAddress()));
161
162 TDictionary* d1 = TDictionary::GetDictionary(p1->GetType() == EDataType::kNoType_t ? p1->GetValueClass()->GetName() : TDataType::GetTypeName(p1->GetType()));
163 TDictionary* d2 = TDictionary::GetDictionary(p2->GetType() == EDataType::kNoType_t ? p2->GetValueClass()->GetName() : TDataType::GetTypeName(p2->GetType()));
164
165 DEBUG("proxy: " << p1->GetCollectionClass()->GetName() << " " << d1->GetName() << "(" << p1->Size() << ");" << endl);
166 DEBUG("proxy: " << p2->GetCollectionClass()->GetName() << " " << d2->GetName() << "(" << p2->Size() << ");" << endl);
167
168 if (p1->Size() != p2->Size()) {
169 return false;
170 }
171
172 for (UInt_t i = 0; (i != p1->Size() &&
173 i != p2->Size()); ++i) {
174
175 DEBUG("index: " << d1->GetName() << "[" << i << "] " << endl);
176 //DEBUG("index: " << d2->GetName() << "[" << i << "] " << endl);
177
178 const JRootWritableClass w1(d1, (char*) p1->At(i));
179 const JRootWritableClass w2(d2, (char*) p2->At(i));
180
181 if (!this->compare(w1, w2)) {
182 return false;
183 }
184 }
185
186 } else {
187
188 if (first .getClass()->GetListOfBases() != NULL &&
189 second.getClass()->GetListOfBases() != NULL) {
190
191 std::unique_ptr<TIterator> i1(first .getClass()->GetListOfBases()->MakeIterator());
192 std::unique_ptr<TIterator> i2(second.getClass()->GetListOfBases()->MakeIterator());
193
194 for (const TBaseClass *p1, *p2; ((p1 = (const TBaseClass*) i1->Next()) != NULL &&
195 (p2 = (const TBaseClass*) i2->Next()) != NULL); ) {
196
197 if (JRoot::is_class(p1->GetName()) &&
198 JRoot::is_class(p2->GetName())) {
199
200 DEBUG("base: " << p1->GetName() << endl);
201 //DEBUG("base: " << p2->GetName() << endl);
202
203 if (!this->compare(first.get(*p1), second.get(*p2))) {
204 return false;
205 }
206 }
207 }
208 }
209
210 if (first .getClass()->GetListOfDataMembers() != NULL &&
211 second.getClass()->GetListOfDataMembers() != NULL) {
212
213 std::unique_ptr<TIterator> i1(first .getClass()->GetListOfDataMembers()->MakeIterator());
214 std::unique_ptr<TIterator> i2(second.getClass()->GetListOfDataMembers()->MakeIterator());
215
216 for (const TDataMember *p1, *p2; ((p1 = (const TDataMember*) i1->Next()) != NULL &&
217 (p2 = (const TDataMember*) i2->Next()) != NULL); ) {
218
219
220 if (JRoot::is_class(p1->GetName()) &&
221 JRoot::is_class(p2->GetName())) {
222
223 DEBUG("member: " << p1->GetTrueTypeName() << " " << p1->GetName() << ";" << endl);
224 //DEBUG("member: " << p2->GetTrueTypeName() << " " << p2->GetName() << ";" << endl);
225
226 if (!this->compare(first.get(*p1), second.get(*p2))) {
227 return false;
228 }
229 }
230 }
231 }
232 }
233 }
234 }
235
236 return true;
237 }
TPaveText * p1
bool is_valid(const json &js)
Check validity of JSon data.
static bool is_class(const char *const name)
Check name of class against internal ROOT class names.
Definition JRoot.hh:30

Member Data Documentation

◆ debug

int JROOT::JRootComparator::debug = 0

debug level

Definition at line 122 of file JRootComparator.hh.


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