Skip to content

Commit

Permalink
Modified JANA2 JObject::Get() to mimic the behaviour of JANA1 Get wit…
Browse files Browse the repository at this point in the history
…h paramrams
  • Loading branch information
RaiqaRasool committed Dec 16, 2024
1 parent a41c730 commit f073232
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/libraries/JANA/JObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,25 @@ std::vector<const T*> JObject::Get() const {
/// Returns a vector of pointers to all associated objects of type T.

std::vector<const T*> results;
for (auto obj : associated) {
const T* t = dynamic_cast<const T*>(obj);
if (t != nullptr) {
results.push_back(t);
}
}
if (results.empty()) {
// If nothing found, attempt matching by strings.
// Why? Because dl and RTTI aren't playing nicely together;
// each plugin might assign a different typeid to the same class.

std::string classname = JTypeInfo::demangle<T>();
for (auto obj : associated) {
if (obj->className() == classname) {
results.push_back(reinterpret_cast<const T*>(obj));
}
}
}
// for (auto obj : associated) {
// const T* t = dynamic_cast<const T*>(obj);
// if (t != nullptr) {
// results.push_back(t);
// }
// }
// if (results.empty()) {
// // If nothing found, attempt matching by strings.
// // Why? Because dl and RTTI aren't playing nicely together;
// // each plugin might assign a different typeid to the same class.

// std::string classname = JTypeInfo::demangle<T>();
// for (auto obj : associated) {
// if (obj->className() == classname) {
// results.push_back(reinterpret_cast<const T*>(obj));
// }
// }
// }
Get(results);
return results;
}

Expand Down

0 comments on commit f073232

Please sign in to comment.