SheafSystem  0.0.0.0
sheaf::factory< T > 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 T* T::clone() virtual default constructor virtual bool is_initialized() true if instance is fully initialized. More...

#include <factory.h>

Public Member Functions

 factory ()
 Default constructor. More...
 
virtual ~factory ()
 Destructor. More...
 
T * new_instance (const std::string &xclient_class_name)
 Creates an instance of type xclient_class_name. More...
 
template<typename S >
T * new_instance (const std::string &xclient_class_name, S &xarg)
 Creates an instance of type xclient_class_name and initializes it with xname_space. More...
 
void insert_prototype (T *xprototype)
 Sets xprototype as the prototype for its client class. More...
 
void delete_prototype (const std::string &xclass_name)
 Removes the prototype for handles of type xclass_name. More...
 
bool contains_prototype (const std::string &xclass_name) const
 True if the set of prototypes contains a prototype for handles of type xclass_name. More...
 

Friends

std::ostream & operator (std::ostream &xos, const factory< T > &xf)
 

Detailed Description

template<typename T>
class sheaf::factory< T >

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 T* T::clone() virtual default constructor virtual bool is_initialized() true if instance is fully initialized.

Definition at line 49 of file eval_family.h.

Constructor & Destructor Documentation

◆ factory()

template<typename T >
sheaf::factory< T >::factory ( )

Default constructor.

Definition at line 48 of file factory.impl.h.

References sheaf::factory< T >::~factory().

Referenced by sheaf::factory< T >::contains_prototype().

◆ ~factory()

template<typename T >
sheaf::factory< T >::~factory ( )
virtual

Destructor.

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

Definition at line 61 of file factory.impl.h.

References sheaf::factory< T >::new_instance().

Referenced by sheaf::factory< T >::factory().

Member Function Documentation

◆ contains_prototype()

template<typename T >
bool sheaf::factory< T >::contains_prototype ( const std::string &  xclass_name) const

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

Definition at line 212 of file factory.impl.h.

References sheaf::factory< T >::factory().

Referenced by sheaf::factory< T >::delete_prototype().

◆ delete_prototype()

template<typename T >
void sheaf::factory< T >::delete_prototype ( const std::string &  xclass_name)

Removes the prototype for handles of type xclass_name.

Postcondition
  • !contains_prototype(xclass_name)

Definition at line 182 of file factory.impl.h.

References sheaf::factory< T >::contains_prototype().

Referenced by sheaf::factory< T >::insert_prototype().

◆ insert_prototype()

template<typename T >
void sheaf::factory< T >::insert_prototype ( T *  xprototype)

◆ new_instance() [1/2]

template<typename T >
T * sheaf::factory< T >::new_instance ( const std::string &  xclient_class_name)

Creates an instance of type xclient_class_name.

Precondition
  • contains_prototype(xclient_class_name)
Postcondition
  • result != 0
  • -unexecutable( "result is default constructed" )

Definition at line 91 of file factory.impl.h.

Referenced by sheaf::factory< T >::~factory().

◆ new_instance() [2/2]

template<typename T >
template<typename S >
T * sheaf::factory< T >::new_instance ( const std::string &  xclient_class_name,
S &  xarg 
)

Creates an instance of type xclient_class_name and initializes it with xname_space.

Precondition
  • contains_prototype(xclient_class_name)
Postcondition
  • result != 0
  • result->is_initialized()

Definition at line 117 of file factory.impl.h.

References sheaf::factory< T >::insert_prototype().


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