Base class for class factories. More...
#include <itpp/base/factory.h>
Public Member Functions | |
Factory () | |
Default constructor. | |
virtual | ~Factory () |
Destructor. | |
Base class for class factories.
A class factory (or virtual constructor) is a class that can create instances of another class. Factory is a base class for such factories. When declaring an Array, Vec or Mat, a factory can be passed as an (optional) constructor argument:
By default, the factory (DEFAULT_FACTORY
and f
in the above examples) is not used at all! However, by overloading a help function called create_elements we can force Array/Vec/Mat to use the factory for element creation (instead of using the default constructor for the element type).
Here is an example that (partly) defines a user-defined numeric type My_Type, a corresponding factory My_Factory and a corresponding help function create_elements<My_Type> that will be used by Array, Vec and Mat for element creation.
Now,
For a more interesting example, see Fix_Factory.
Generated on Sat Jul 6 2013 10:54:30 for IT++ by Doxygen 1.8.2