#include #include #include #include #include using namespace Shapes; ShapeRep::~ShapeRep(){} Shape ShapeRep::make (std::string request_code) const { std::list::iterator it = PrototypeList().begin(); for ( ; it != PrototypeList().end(); ++it) { if ( (*it)->isMine ( request_code ) ) return (*it)->make( request_code ); } throw Exception ( std::string("make request failed for unknown shape ") + request_code ); } bool ShapeRep::isMine (std::string request_code) { return false; } namespace { ShapeRep& Prototype() { static ShapeRep t(Registration("Shape")); return t; } } Shape Shapes::God ( Prototype() );