CMS 3D CMS Logo

AlignSetup< Type > Class Template Reference

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

#include <Alignment/CommonAlignment/interface/AlignSetup.h>

List of all members.

Public Member Functions

 AlignSetup ()
 Constructor.
void dump (void) const
 Print the name of all stored data.
Type & find (const std::string &name="")
 Find and return an object from map using its name.
Type & get (const std::string &name="")
 Get an object from map using its 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.

00033 {}


Member Function Documentation

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

Print the name of all stored data.

Definition at line 76 of file AlignSetup.h.

References lat::endl(), it, and AlignSetup< Type >::theStore.

00077 {
00078   edm::LogInfo("AlignSetup") << "Printing out AlignSetup: ";
00079   for ( typename Container::const_iterator it = theStore.begin();
00080         it != theStore.end(); ++it ) {
00081     edm::LogVerbatim("AlignSetup") << it->first << std::endl;
00082   }
00083 }

template<class Type>
Type & AlignSetup< Type >::find ( const std::string &  name = ""  )  [inline]

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 Exception, it, and AlignSetup< Type >::theStore.

Referenced by AlignableBuilder::build().

00059 {
00060   typename Container::iterator o = theStore.find(name);
00061 
00062   if (theStore.end() == o) {
00063       std::ostringstream knownKeys;
00064       for (typename Container::const_iterator it = theStore.begin(); it != theStore.end(); ++it) {
00065         knownKeys << (it != theStore.begin() ? ", " : "") << it->first;
00066       }
00067       throw cms::Exception("AlignSetupError")
00068         << "Cannot find an object of name " << name << " in AlignSetup, know only "
00069         << knownKeys.str() << ".";
00070     }
00071   
00072   return o->second;
00073 }

template<class Type>
Type & AlignSetup< Type >::get ( const std::string &  name = ""  )  [inline]

Get an object from map using its name.

A new object is default-constructed if the name does not exist.

Definition at line 52 of file AlignSetup.h.

References AlignSetup< Type >::theStore.

Referenced by AlignableBuilder::build().

00053 {
00054   return theStore[name];
00055 }


Member Data Documentation

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

Definition at line 47 of file AlignSetup.h.

Referenced by AlignSetup< Type >::dump(), AlignSetup< Type >::find(), and AlignSetup< Type >::get().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:14:38 2009 for CMSSW by  doxygen 1.5.4