19#ifndef LM_FACTORY_TEMPLATE__ 
   20#define LM_FACTORY_TEMPLATE__ 
   30namespace learningmachine {
 
   40template<
class K, 
class T>
 
   64        for(
typename std::map<K, T* >::iterator it = this->map.begin(); it != this->map.end(); it++) {
 
  102        assert(prototype != (
T*) 0);
 
  104        if(prototype->getName() == 
"") {
 
  105            throw std::runtime_error(
"Cannot register prototype with empty key; please specify a unique key.");
 
  108        if(this->map.count(prototype->getName()) > 0) {
 
  109            std::ostringstream buffer;
 
  110            buffer << 
"Prototype '" << prototype->getName()
 
  111                   << 
"' has already been registered; please specify a unique key.";
 
  112            throw std::runtime_error(buffer.str());
 
  115        this->map[prototype->getName()] = prototype;
 
 
  128        if(this->map.count(key) == 0) {
 
  129            std::ostringstream buffer;
 
  130            buffer << 
"Could not find prototype '" << key
 
  131                   << 
"'; please specify a valid key.";
 
  132            throw std::runtime_error(buffer.str());
 
  135        return this->map.find(key)->second->clone();
 
 
  145        for(
typename std::map<K,T*>::iterator it = this->map.begin(); it != this->map.end(); ++it) {
 
  146            v.push_back(it->first);
 
 
 
A template class for the factory pattern.
 
static FactoryT< K, T > & instance()
An instance retrieval method that follows the Singleton pattern.
 
void registerPrototype(T *prototype)
Registers a prototype object that can be used to create clones.
 
T * create(const K &key)
Creates a new object given a specific type of key.
 
std::vector< K > getKeys()
Returns a vector of the registered keys.
 
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.