CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

AlignSetup< Type > Class Template Reference

#include <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="")
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.

{}

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.

{
  edm::LogInfo("AlignSetup") << "Printing out AlignSetup: ";
  for ( typename Container::const_iterator it = theStore.begin();
        it != theStore.end(); ++it ) {
    edm::LogVerbatim("AlignSetup") << it->first << std::endl;
  }
}
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 Exception, and connectstrParser::o.

Referenced by AlignableBuilder::build(), AlignableTracker::buildBarrel(), AlignableTracker::buildTRK(), AlignableTracker::subStructures(), and AlignableExtras::subStructures().

{
  typename Container::iterator o = theStore.find(name);

  if (theStore.end() == o) {
      std::ostringstream knownKeys;
      for (typename Container::const_iterator it = theStore.begin(); it != theStore.end(); ++it) {
        knownKeys << (it != theStore.begin() ? ", " : "") << it->first;
      }
      throw cms::Exception("AlignSetupError")
        << "Cannot find an object of name " << name << " in AlignSetup, know only "
        << knownKeys.str() << ".";
    }
  
  return o->second;
}
template<class Type >
Type & AlignSetup< Type >::get ( const std::string &  name = "")

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 AlCaRecoCosmics_cfg::name.

Referenced by AlignableExtras::AlignableExtras(), AlignableBuilder::build(), AlignableTracker::buildBarrel(), AlignableTracker::buildTRK(), and AlignableTracker::detsToAlignables().

{
  return theStore[name];
}

Member Data Documentation

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

Definition at line 47 of file AlignSetup.h.