CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignSetup.h
Go to the documentation of this file.
1 #ifndef Alignment_CommonAlignment_AlignSetup_h
2 #define Alignment_CommonAlignment_AlignSetup_h
3 
19 #include <map>
20 #include <sstream>
21 
24 
25 template <class Type>
27 {
28  typedef typename std::map<std::string, Type> Container;
29 
30 public:
31 
34 
37  Type& get( const std::string& name = "" );
38 
41  Type& find( const std::string& name = "" );
42 
44  void dump( void ) const;
45 
46 private:
48 };
49 
50 
51 template <class Type>
52 Type& AlignSetup<Type>::get(const std::string& name)
53 {
54  return theStore[name];
55 }
56 
57 template <class Type>
58 Type& AlignSetup<Type>::find(const std::string& name)
59 {
60  typename Container::iterator o = theStore.find(name);
61 
62  if (theStore.end() == o) {
63  std::ostringstream knownKeys;
64  for (typename Container::const_iterator it = theStore.begin(); it != theStore.end(); ++it) {
65  knownKeys << (it != theStore.begin() ? ", " : "") << it->first;
66  }
67  throw cms::Exception("AlignSetupError")
68  << "Cannot find an object of name " << name << " in AlignSetup, know only "
69  << knownKeys.str() << ".";
70  }
71 
72  return o->second;
73 }
74 
75 template <class Type>
76 void AlignSetup<Type>::dump( void ) const
77 {
78  edm::LogInfo("AlignSetup") << "Printing out AlignSetup: ";
79  for ( typename Container::const_iterator it = theStore.begin();
80  it != theStore.end(); ++it ) {
81  edm::LogVerbatim("AlignSetup") << it->first << std::endl;
82  }
83 }
84 
85 #endif
AlignSetup()
Constructor.
Definition: AlignSetup.h:33
Type & find(const std::string &name="")
Definition: AlignSetup.h:58
Container theStore
Definition: AlignSetup.h:47
Type & get(const std::string &name="")
Definition: AlignSetup.h:52
void dump(void) const
Print the name of all stored data.
Definition: AlignSetup.h:76
std::map< std::string, Type > Container
Definition: AlignSetup.h:28