SheafSystem  0.0.0.0
sheaf::factory_2< T, R > Class Template Reference

A factory for instanting descendants of an abstract type T, given the class name of the descendant. Requires: virtual const string& T::class_name() the actual (descendant) class name of the prototype. virtual R T::clone() virtual default constructor virtual R T::clone(S& xarg) virtual constructor. More...

#include <factory_2.h>

Friends

ostream & operator (ostream &xos, const factory_2< T, R > &xf)
 

FACTORY_2 FACET

 factory_2 ()
 Default constructor. More...
 
virtual ~factory_2 ()
 Destructor. More...
 
new_instance (const string &xclient_class_name, const arg_list &xargs)
 Creates an instance of type xclient_class_name with arguments xargs. More...
 
void insert_prototype (T *xprototype)
 Sets xprototype as the prototype for its client class. More...
 
void delete_prototype (const string &xclass_name)
 Removes the prototype for handles of type xclass_name. More...
 
bool contains_prototype (const string &xclass_name) const
 True if the set of prototypes contains a prototype for handles of type xclass_name. More...
 

Detailed Description

template<typename T, typename R = T*>
class sheaf::factory_2< T, R >

A factory for instanting descendants of an abstract type T, given the class name of the descendant. Requires: virtual const string& T::class_name() the actual (descendant) class name of the prototype. virtual R T::clone() virtual default constructor virtual R T::clone(S& xarg) virtual constructor.

Definition at line 52 of file factory_2.h.

Constructor & Destructor Documentation

◆ factory_2()

template<typename T , typename R >
sheaf::factory_2< T, R >::factory_2 ( )

Default constructor.

Definition at line 59 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::~factory_2().

Referenced by sheaf::factory_2< T, R >::contains_prototype().

◆ ~factory_2()

template<typename T , typename R >
sheaf::factory_2< T, R >::~factory_2 ( )
virtual

Destructor.

Postcondition
  • -unexecutable( "All prototypes have been deleted." )

Definition at line 72 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::new_instance().

Referenced by sheaf::factory_2< T, R >::factory_2().

Member Function Documentation

◆ contains_prototype()

template<typename T , typename R >
bool sheaf::factory_2< T, R >::contains_prototype ( const string &  xclass_name) const

True if the set of prototypes contains a prototype for handles of type xclass_name.

Definition at line 214 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::factory_2().

Referenced by sheaf::factory_2< T, R >::delete_prototype().

◆ delete_prototype()

template<typename T , typename R >
void sheaf::factory_2< T, R >::delete_prototype ( const string &  xclass_name)

Removes the prototype for handles of type xclass_name.

Postcondition
  • !contains_prototype(xclass_name)

Definition at line 184 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::contains_prototype().

Referenced by sheaf::factory_2< T, R >::insert_prototype().

◆ insert_prototype()

template<typename T , typename R >
void sheaf::factory_2< T, R >::insert_prototype ( T *  xprototype)

Sets xprototype as the prototype for its client class.

Precondition
  • xprototype != 0
Postcondition
  • contains_prototype(xprototype->class_name())

Definition at line 146 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::delete_prototype().

Referenced by sheaf::factory_2< T, R >::new_instance().

◆ new_instance()

template<typename T , typename R >
R sheaf::factory_2< T, R >::new_instance ( const string &  xclient_class_name,
const arg_list xargs 
)

Creates an instance of type xclient_class_name with arguments xargs.

Precondition
  • contains_prototype(xclient_class_name)
Postcondition
  • result != 0
  • -unexecutable( "result is constructed with args, xargs" )

Definition at line 123 of file factory_2.impl.h.

References sheaf::factory_2< T, R >::insert_prototype().

Referenced by sheaf::factory_2< T, R >::~factory_2().


The documentation for this class was generated from the following files: