43 #include <boost/bind.hpp> 46 #include <lifev/core/LifeV.hpp> 48 #include <lifev/core/util/LifeDebug.hpp> 49 #include <lifev/core/util/FactoryTypeInfo.hpp> 58 template <
class AbstractProduct>
69 std::ostringstream ex_str;
70 ex_str <<
"[factory] Unknown Type : " + id;
71 M_exception = ex_str.str();
82 const char*
what()
const throw ()
84 return M_exception.c_str();
109 template <
class AbstractProduct,
typename IdentifierType,
112 class Factory :
public FactoryErrorPolicy<AbstractProduct>
154 #ifdef HAVE_LIFEV_DEBUG 155 debugStream ( 2200 ) <<
"Registered type with id : " << id <<
"\n";
157 return M_associations.insert (
typename productId_Type::value_type ( id, creator ) ).second;
169 #ifdef HAVE_LIFEV_DEBUG 170 debugStream ( 2200 ) <<
"Unregistered type with id : " << id <<
"\n";
172 return M_associations.erase ( id ) == 1;
185 typename productId_Type::const_iterator i = M_associations.find ( id );
186 if (i != M_associations.end() )
188 #ifdef HAVE_LIFEV_DEBUG 189 debugStream ( 2200 ) <<
"Creating type with id : " << id <<
"\n";
191 return (i->second) ();
193 #ifdef HAVE_LIFEV_DEBUG 194 debugStream ( 2200 ) <<
"Unknown type with id : " << id <<
"\n";
196 return super::onUnknownType ( id );
207 template<
typename map_Type >
210 typename productId_Type::const_iterator i = M_associations.find ( id );
211 if ( i != M_associations.end() )
213 #ifdef HAVE_LIFEV_DEBUG 214 debugStream ( 2200 ) <<
"Creating type with id : " << enum2String ( id, map ) <<
"\n";
216 return (i->second) ();
218 #ifdef HAVE_LIFEV_DEBUG 219 debugStream ( 2200 ) <<
"Unknown type with id : " << enum2String ( id, map ) <<
"\n";
221 return super::onUnknownType ( enum2String ( id, map ) );
AbstractProduct product_Type
product_Type * createObject(const identifier_Type &id)
Create an object from a product registered in the factory using identifier id.
product_Type * createObject(const identifier_Type &id, const map_Type &map)
Create an object from a product registered in the factory using identifier id (of type enum) and a ma...
ProductCreator creator_Type
const char * what() const
void updateInverseJacobian(const UInt &iQuadPt)
productId_Type M_associations
static AbstractProduct * onUnknownType(const std::string &id)
FactoryErrorPolicy< product_Type > super
bool unregisterProduct(const identifier_Type &id)
Unregister a product.
std::map< identifier_Type, creator_Type > productId_Type
Exception(const std::string &id)
bool registerProduct(const identifier_Type &id, creator_Type creator)
Register a product.
IdentifierType identifier_Type