CMS 3D CMS Logo

IgModelManager Class Reference

#include <Iguana/Studio/interface/IgModelManager.h>

Inheritance diagram for IgModelManager:

IgStateElement

List of all members.

Public Types

typedef std::map< std::string,
std::vector< IgModel * > > 
ModelList

Public Member Functions

void add (IgState *state, IgModel *model, std::string name="")
 IgModelManager (IgState *m_state)
template<class T>
IgStatelookup (IgState *state, T **model, std::string name="")
template<class T>
bool lookup (T **model, std::string name="")
 Searches for model of type T within the list of all models, , create it if id does not exist and change the passed pointer so that it point to the object of the kind requested.
std::vector< std::string > roots (void)
template<class T>
std::vector< std::string > roots (T *)
IgStatestate (void)
 ~IgModelManager (void)

Private Member Functions

 IG_DECLARE_STATE_ELEMENT (IgModelManager)

Private Attributes

ModelList m_models
IgStatem_state


Detailed Description

Definition at line 24 of file IgModelManager.h.


Member Typedef Documentation

typedef std::map<std::string, std::vector<IgModel *> > IgModelManager::ModelList

Definition at line 35 of file IgModelManager.h.


Constructor & Destructor Documentation

IgModelManager::IgModelManager ( IgState m_state  ) 

Definition at line 18 of file IgModelManager.cc.

References ASSERT, m_state, and IgState::put().

00019     : m_state (state)
00020 { ASSERT (m_state); m_state->put (s_key, this); }

IgModelManager::~IgModelManager ( void   ) 

Definition at line 22 of file IgModelManager.cc.

References IgState::detach(), i, j, m_models, and m_state.

00023 {
00024     m_state->detach (s_key);
00025     for (ModelList::iterator i = m_models.begin ();
00026          i != m_models.end ();
00027          i++)
00028         for (std::vector<IgModel *>::iterator j = i->second.begin ();
00029              j != i->second.end (); j++)
00030             delete (*j);
00031 }


Member Function Documentation

void IgModelManager::add ( IgState state,
IgModel model,
std::string  name = "" 
)

Definition at line 50 of file IgModelManager.cc.

References ASSERT, DBSPlugin::get(), IgDocumentDataRoot::getCurrentRoot(), lookup(), m_models, and m_state.

Referenced by Ig2DWindow::Ig2DWindow(), IgLegoWindow::IgLegoWindow(), IgRPhiWindow::IgRPhiWindow(), IgRZWindow::IgRZWindow(), and IgSpareWindow::IgSpareWindow().

00051 {
00052     ASSERT (model);
00053     
00054     if (name.size () == 0)
00055         name = IgDocumentDataRoot::getCurrentRoot ();
00056     
00057     IgDocumentDataManager::get (state ? state : m_state)->
00058         lookup(state, name);
00059     
00060     m_models[name].push_back (model);
00061 }

IgModelManager::IG_DECLARE_STATE_ELEMENT ( IgModelManager   )  [private]

template<class T>
IgState* IgModelManager::lookup ( IgState state,
T **  model,
std::string  name = "" 
) [inline]

Definition at line 63 of file IgModelManager.h.

References DBSPlugin::get(), IgDocumentDataRoot::getCurrentRoot(), lookup(), and name.

00064     {
00065         if (name.size () == 0)
00066             name = IgDocumentDataRoot::getCurrentRoot ();
00067         lookup (model, name);
00068             
00069         state = IgDocumentDataManager::get (state ? state : m_state)->
00070                    lookup(state, name);
00071         
00072         if (!*model)
00073         {
00074             *model = new T (state);
00075             m_models[name].push_back (*model);
00076         }
00077         return state;
00078     }

template<class T>
bool IgModelManager::lookup ( T **  model,
std::string  name = "" 
) [inline]

Searches for model of type T within the list of all models, , create it if id does not exist and change the passed pointer so that it point to the object of the kind requested.

Definition at line 41 of file IgModelManager.h.

References IgDocumentDataRoot::getCurrentRoot(), i, j, and name.

Referenced by add(), Ig2DWindow::Ig2DWindow(), IgLegoWindow::IgLegoWindow(), IgRPhiWindow::IgRPhiWindow(), IgRZWindow::IgRZWindow(), and IgSpareWindow::IgSpareWindow().

00042     {
00043         *model = 0;
00044         if (name.size () == 0)
00045             name = IgDocumentDataRoot::getCurrentRoot ();
00046             
00047         ModelList::iterator i =  m_models.find (name);
00048         
00049         if (i != m_models.end ())
00050         {
00051             for (std::vector<IgModel *>::iterator j = i->second.begin ();
00052                  j != i->second.end (); j++)
00053             {
00054                 *model = dynamic_cast<T*> (*j);
00055                 if (*model)
00056                     return true;
00057             }
00058         }
00059         return false;
00060     }

std::vector< std::string > IgModelManager::roots ( void   ) 

Definition at line 38 of file IgModelManager.cc.

References i, m_models, and names.

00039 {
00040     std::vector<std::string> names;
00041             
00042     for (ModelList::iterator i = m_models.begin ();
00043          i != m_models.end (); i++)
00044         names.push_back (i->first);
00045             
00046     return names;
00047 }

template<class T>
std::vector<std::string> IgModelManager::roots ( T *   )  [inline]

Definition at line 81 of file IgModelManager.h.

References i, j, and names.

00082     {
00083         std::vector<std::string> names;
00084             
00085         for (ModelList::iterator i = m_models.begin ();
00086              i != m_models.end (); i++)
00087         {
00088             for (std::vector<IgModel *>::iterator j = i->second.begin ();
00089                  j != i->second.end (); j++)
00090             {
00091                 if (dynamic_cast<T*> (*j))
00092                 {
00093                     names.push_back (i->first);
00094                     break;
00095                 }
00096             }
00097        }
00098             
00099        return names;
00100     }

IgState * IgModelManager::state ( void   ) 

Definition at line 34 of file IgModelManager.cc.

References m_state.

00035 { return m_state; }


Member Data Documentation

ModelList IgModelManager::m_models [private]

Definition at line 108 of file IgModelManager.h.

Referenced by add(), roots(), and ~IgModelManager().

IgState* IgModelManager::m_state [private]

Definition at line 107 of file IgModelManager.h.

Referenced by add(), IgModelManager(), state(), and ~IgModelManager().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:13 2009 for CMSSW by  doxygen 1.5.4