/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes
ElementMgr< Element > Class Template Reference

#include <ElementMgr.h>

Inheritance diagram for ElementMgr< Element >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const std::string & name ()
virtual bool initialize ()
virtual bool finalize ()

Static Public Member Functions

static Element * get (const std::string &objName, bool create=false)
template<typename ConcreteType >
static ConcreteType * get (const std::string &objName, bool create=false)

Protected Types

typedef Element *(* ElementCreator )(const std::string &)
typedef std::map< std::string,
ElementCreator
Type2CreatorMap

Protected Member Functions

 ElementMgr (const std::string &name)
virtual ~ElementMgr ()

Static Protected Attributes

static std::list< Element * > m_elements
static std::map< std::string,
Element * > 
name2obj
static std::map< std::string,
ElementCreator
elementCreatorMap

Private Member Functions

 ElementMgr ()
 ElementMgr (const ElementMgr &)
ElementMgroperator= (const ElementMgr &)

Private Attributes

std::string m_name

Detailed Description

template<typename Element>
class ElementMgr< Element >

Definition at line 12 of file ElementMgr.h.


Member Typedef Documentation

template<typename Element>
typedef Element*(* ElementMgr< Element >::ElementCreator)(const std::string &) [protected]

Definition at line 41 of file ElementMgr.h.

template<typename Element>
typedef std::map<std::string, ElementCreator> ElementMgr< Element >::Type2CreatorMap [protected]

Definition at line 42 of file ElementMgr.h.


Constructor & Destructor Documentation

template<typename Element >
ElementMgr< Element >::ElementMgr ( const std::string &  name) [protected]

Definition at line 63 of file ElementMgr.h.

    : m_name(name)
{
    std::vector<std::string> vNames;
    OptionParser::setOption(name, "Contents", vNames);

    for(std::vector<std::string>::iterator i=vNames.begin(); i!=vNames.end(); ++i) {
        std::string typName = *i;
        std::string objName = typName;
        std::string::size_type pseg = typName.find('/', 0);
        if ( pseg != std::string::npos ) {
            typName = typName.substr(0, pseg);
            objName = objName.substr(pseg+1, std::string::npos);
        }

        typename Type2CreatorMap::iterator j = elementCreatorMap.find(typName);
        if ( j == elementCreatorMap.end() ) {
            std::string msg = name + ": unknown content type " + typName;
            throw LafException(msg);
        }
        Element* obj = (j->second)(objName);
        m_elements.push_back(obj);
        name2obj[objName] = obj;
    }
}
template<typename Element >
ElementMgr< Element >::~ElementMgr ( ) [protected, virtual]

Definition at line 90 of file ElementMgr.h.

{
    for(typename std::list<Element*>::iterator i=m_elements.begin(); i!=m_elements.end(); ++i) {
        delete (*i);
    }
}
template<typename Element>
ElementMgr< Element >::ElementMgr ( ) [private]
template<typename Element>
ElementMgr< Element >::ElementMgr ( const ElementMgr< Element > &  ) [private]

Member Function Documentation

template<typename Element>
const std::string& ElementMgr< Element >::name ( void  ) [inline]

Definition at line 16 of file ElementMgr.h.

{ return m_name; }
template<typename Element >
ConcreteType * ElementMgr< Element >::get ( const std::string &  objName,
bool  create = false 
) [static]

Definition at line 98 of file ElementMgr.h.

{
    typename std::map<std::string, Element*>::iterator i = name2obj.find(objName);
    if ( i != name2obj.end() ) {
        return (i->second);
    }
    if ( create ) {
        typename Type2CreatorMap::iterator j = elementCreatorMap.find(objName);
        if ( j != elementCreatorMap.end() ) {
            Element* obj = (j->second)(objName);
            m_elements.push_back(obj);
            name2obj[objName] = obj;
            return obj;
        }
    }
    return (Element*)0;
}
template<typename Element>
template<typename ConcreteType >
static ConcreteType* ElementMgr< Element >::get ( const std::string &  objName,
bool  create = false 
) [static]
template<typename Element >
bool ElementMgr< Element >::initialize ( ) [virtual]

Definition at line 123 of file ElementMgr.h.

{
    for(typename std::list<Element*>::iterator i=m_elements.begin(); i!=m_elements.end(); ++i) {
        if ( ! (*i)->initialize() ) return false;
    }
    return true;
}
template<typename Element >
bool ElementMgr< Element >::finalize ( ) [virtual]

Definition at line 132 of file ElementMgr.h.

{
    for(typename std::list<Element*>::iterator i=m_elements.begin(); i!=m_elements.end(); ++i) {
        if ( ! (*i)->finalize() ) return false;
    }
    return true;
}
template<typename Element>
ElementMgr& ElementMgr< Element >::operator= ( const ElementMgr< Element > &  ) [private]

Member Data Documentation

template<typename Element>
std::string ElementMgr< Element >::m_name [private]

Definition at line 29 of file ElementMgr.h.

template<typename Element>
std::list< Element * > ElementMgr< Element >::m_elements [static, protected]

Definition at line 37 of file ElementMgr.h.

template<typename Element>
std::map< std::string, Element * > ElementMgr< Element >::name2obj [static, protected]

Definition at line 39 of file ElementMgr.h.

template<typename Element>
ElementMgr< Element >::Type2CreatorMap ElementMgr< Element >::elementCreatorMap [static, protected]

Definition at line 43 of file ElementMgr.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:18 for LafKernel by doxygen 1.7.4