CMS 3D CMS Logo

VisTwigFactroyService.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00004 #include <stdexcept>
00005 
00006 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00007 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00008 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00009 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00010 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00011 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00012 
00013 IG_DEFINE_STATE_ELEMENT (VisTwigFactroyService, "Services/Framework/Twig Factory");
00014 
00015 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00016 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00017 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00018 
00019 VisTwigFactroyService::VisTwigFactroyService (IgState *state)
00020 {    
00021     ASSERT (state);
00022     state->put (s_key, this);
00023 }
00024 
00025 VisTwigFactroyService::~VisTwigFactroyService (void) 
00026 {    
00027     ASSERT (m_state);
00028     m_state->detach (s_key);
00029 }
00030 
00031 bool
00032 VisTwigFactroyService::registerTwig (const std::string &name, CreateTwigCallback createFn) 
00033 {
00034     return m_callback.insert (CallbackMap::value_type (name, createFn)).second;
00035 }
00036 
00037 bool
00038 VisTwigFactroyService::unregisterTwig (const std::string &name) 
00039 {
00040     return m_callback.erase (name) == 1;
00041 }
00042 
00043 VisQueuedTwig *
00044 VisTwigFactroyService::createTwig (const std::string &name, 
00045                                    IgState *state, IgTwig *parent,
00046                                    const std::string &friendlyName,
00047                                    const std::string &moduleLabel,
00048                                    const std::string &instanceName,
00049                                    const std::string &processName) 
00050 {
00051     CallbackMap::const_iterator i = m_callback.find (name);
00052     
00053     if (i == m_callback.end ())
00054     {
00055         throw std::runtime_error ("Unknown Twig name.");
00056     }
00057     std::string twigName = friendlyName
00058                            + std::string (":") + moduleLabel
00059                            + std::string (":") + instanceName 
00060                            + std::string (":") + processName;
00061     
00062     return (i->second)(state, parent, twigName, 
00063                        friendlyName, moduleLabel, instanceName, processName);
00064 }

Generated on Tue Jun 9 17:50:05 2009 for CMSSW by  doxygen 1.5.4