CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
AlignSetup< Type > Class Template Reference

#include <AlignSetup.h>

Public Member Functions

 AlignSetup ()
 Constructor. More...
 
void dump (void) const
 Print the name of all stored data. More...
 
Type & find (const std::string &name="")
 
Type & get (const std::string &name="")
 

Private Types

typedef std::map< std::string,
Type > 
Container
 

Private Attributes

Container theStore
 

Detailed Description

template<class Type>
class AlignSetup< Type >

A helper class to hold objects used by modules in alignment.

AlignSetup has a template parameter to specify the type of objects it holds. Objects are stored in a map<string, Type>. Users put/get an object by passing its name through the static methods put()/get(). It returns 0 if the name is not found on get(). It throws an exception if an object of the same name exists on put().

Date:
2008/02/15 18:11:45
Revision:
1.4
Author
Chung Khim Lae

Definition at line 26 of file AlignSetup.h.

Member Typedef Documentation

template<class Type>
typedef std::map<std::string, Type> AlignSetup< Type >::Container
private

Definition at line 28 of file AlignSetup.h.

Constructor & Destructor Documentation

template<class Type>
AlignSetup< Type >::AlignSetup ( )
inline

Constructor.

Definition at line 33 of file AlignSetup.h.

33 {}

Member Function Documentation

template<class Type >
void AlignSetup< Type >::dump ( void  ) const

Print the name of all stored data.

Definition at line 76 of file AlignSetup.h.

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 }
Container theStore
Definition: AlignSetup.h:47
template<class Type >
Type & AlignSetup< Type >::find ( const std::string &  name = "")

Find and return an object from map using its name. Throw an exception if the name does not exist.

Definition at line 58 of file AlignSetup.h.

References edm::hlt::Exception, and python.connectstrParser::o.

Referenced by BeautifulSoup.Tag::__getattr__(), AlignableBuilder::build(), AlignableTracker::buildBarrel(), AlignableTracker::buildTRK(), BeautifulSoup.Tag::firstText(), AlignableTracker::subStructures(), and AlignableExtras::subStructures().

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 }
Container theStore
Definition: AlignSetup.h:47
template<class Type >
Type & AlignSetup< Type >::get ( const std::string &  name = "")

Member Data Documentation

template<class Type>
Container AlignSetup< Type >::theStore
private

Definition at line 47 of file AlignSetup.h.