Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Decoration.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "Acts/Utilities/HashedString.hpp"
5 #include "ActsEvent/Decoration.h"
6 
7 
8 namespace ActsTrk::detail {
9 
10 template<typename T>
11 bool build (const std::type_info* typeInfo, const std::string& name, std::vector<Decoration>& decorations){
12  if (*typeInfo == typeid(T)) {
13  decorations.emplace_back(
14  decoration<T>(name, ActsTrk::detail::constDecorationGetter<T>,
15  ActsTrk::detail::decorationCopier<T>));
16  return true;
17  }
18  return false;
19 }
20 
21 std::vector<Decoration> restoreDecorations(
22  const SG::IConstAuxStore* container,
23  const std::set<std::string>& staticVariables) {
24  std::vector<Decoration> decorations;
25  for (auto id : container->getAuxIDs()) {
26  const std::string name = SG::AuxTypeRegistry::instance().getName(id);
27  const std::type_info* typeInfo =
29  if (staticVariables.count(name) == 1) {
30  continue;
31  }
32 
33  // try making decoration accessor of matching type
34  // there is a fixed set of supported types (as there is a fixed set
35  // available in MutableMTJ) setters are not needed so replaced by a
36  if ( build<float>(typeInfo, name, decorations) ||
37  build<double>(typeInfo, name, decorations) ||
38  build<short>(typeInfo, name, decorations) ||
39  build<int>(typeInfo, name, decorations) ||
40  build<uint8_t>(typeInfo, name, decorations) ||
41  build<uint16_t>(typeInfo, name, decorations) ||
42  build<uint32_t>(typeInfo, name, decorations) ||
43  build<uint64_t>(typeInfo, name, decorations) ||
44  build<int8_t>(typeInfo, name, decorations) ||
45  build<int16_t>(typeInfo, name, decorations) ||
46  build<int32_t>(typeInfo, name, decorations) ||
47  build<int64_t>(typeInfo, name, decorations)
48  ) {
49  continue;
50  }
51  throw std::runtime_error("Can't restore decoration of " + name +
52  " because it is of an unsupported type");
53  }
54  return decorations;
55 }
56 } // namespace ActsTrk::detail
ActsTrk::detail::build
bool build(const std::type_info *typeInfo, const std::string &name, std::vector< Decoration > &decorations)
Definition: Decoration.cxx:11
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
SG::AuxTypeRegistry::getType
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Definition: AuxTypeRegistry.cxx:908
ActsTrk::detail::restoreDecorations
std::vector< Decoration > restoreDecorations(const SG::IConstAuxStore *container, const std::set< std::string > &staticVariables)
Definition: Decoration.cxx:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Decoration.h
ActsTrk::detail
Definition: Decoration.h:15
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SG::IConstAuxStore::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const =0
Return a set of identifiers for existing data items in this store.