Skip to content

Commit

Permalink
Modified JANA2 Get() to mimic the behaviour of JANA1 Get with params
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiqaRasool committed Nov 6, 2024
1 parent e82f930 commit 99ce0a9
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 99ce0a9

Please sign in to comment.