LDMX Software
VisAttributesStore.h
Go to the documentation of this file.
1
7#ifndef SIMCORE_VISATTRIBUTESSTORE_H_
8#define SIMCORE_VISATTRIBUTESSTORE_H_
9
10// Geant4
11#include "G4VisAttributes.hh"
12
13namespace simcore {
14
20 public:
24 typedef std::map<std::string, G4VisAttributes*> VisAttributesMap;
25
31 static VisAttributesStore INSTANCE;
32 return &INSTANCE;
33 }
34
41 for (auto& nameAtt : visAttributesMap_) {
42 delete nameAtt.second;
43 }
44 visAttributesMap_.clear();
45 }
46
52 G4VisAttributes* getVisAttributes(const std::string& name) {
53 try {
54 return visAttributesMap_.at(name);
55 } catch (const std::out_of_range& oor) {
56 G4cout << "[ WARN ] : VisAttribute '" << name
57 << "' not recognized. Ignoring." << G4endl;
58 return nullptr;
59 }
60 }
61
67 void addVisAttributes(const std::string& name,
68 G4VisAttributes* visAttributes) {
69 visAttributesMap_[name] = visAttributes;
70 }
71
72 private:
77};
78
79} // namespace simcore
80
81#endif
Global store of G4VisAttributes created from GDML data.
std::map< std::string, G4VisAttributes * > VisAttributesMap
Map of name to vis attributes.
G4VisAttributes * getVisAttributes(const std::string &name)
Get vis attributes by name.
void addVisAttributes(const std::string &name, G4VisAttributes *visAttributes)
Register a vis attributes by name.
VisAttributesMap visAttributesMap_
The map of names to vis attributes.
static VisAttributesStore * getInstance()
Get the global instance of the store.