Frobby  0.9.5
Classes | Functions
NameFactory.h File Reference
#include "error.h"
#include <vector>
#include <string>
#include <algorithm>

Go to the source code of this file.

Classes

class  NameFactory< AbstractProduct >
 A NameFactory takes a name and then creates an instance of a class that has been previously registered under that name. More...
 

Functions

template<class ConcreteProduct , class AbstractProduct >
void nameFactoryRegister (NameFactory< AbstractProduct > &factory)
 Registers the string returned by ConcreteProduct::getStaticName() to a function that default-constructs a ConcreteProduct. More...
 
template<class AbstractProduct >
auto_ptr< AbstractProduct > createWithPrefix (const NameFactory< AbstractProduct > &factory, const string &prefix)
 Creates the unique product that has the indicated prefix, or create the actual product that has name equal to the indicated prefix. More...
 
template<class AbstractProduct >
string getUniqueNameWithPrefix (const NameFactory< AbstractProduct > &factory, const string &prefix)
 Returns the unique product name that has the indicated prefix, or return prefix itself if it is the actual name of a product. More...
 

Function Documentation

◆ createWithPrefix()

template<class AbstractProduct >
auto_ptr< AbstractProduct > createWithPrefix ( const NameFactory< AbstractProduct > &  factory,
const string &  prefix 
)

Creates the unique product that has the indicated prefix, or create the actual product that has name equal to the indicated prefix.

Exceptions thrown are as for getUniqueNamesWithPrefix().

Definition at line 153 of file NameFactory.h.

◆ getUniqueNameWithPrefix()

template<class AbstractProduct >
string getUniqueNameWithPrefix ( const NameFactory< AbstractProduct > &  factory,
const string &  prefix 
)

Returns the unique product name that has the indicated prefix, or return prefix itself if it is the actual name of a product.

Exceptions
UnknownNameExceptionIf no product has the indicated prefix.
AmbiguousNameExceptionIf more than one product has the indicated prefix and the prefix is not the actual name of any product.

Definition at line 159 of file NameFactory.h.

◆ nameFactoryRegister()

template<class ConcreteProduct , class AbstractProduct >
void nameFactoryRegister ( NameFactory< AbstractProduct > &  factory)

Registers the string returned by ConcreteProduct::getStaticName() to a function that default-constructs a ConcreteProduct.

Definition at line 142 of file NameFactory.h.