* This class implements a generic factory as a singleton.
* This template class implements a generic factory as a singleton.
*
* > IMPORTANT: This template factory can be used to construct many different objects except:
* > - Objects deriving from SensorBase --> see SensorFactory
* > - Objects deriving from ProcessorBase --> see ProcessorFactory
* >
* > The reason for this is that the two cases above need a more elaborated API than the one in this template class.
*
*
* \param TypeBase base type of all the objects created by the factory
* \param TypeBase base type of all the objects created by the factory
* \param TypeInput type of the input argument. Typical cases are std::string for file names, and YAML::Node for YAML nodes.
* \param TypeInput variadic type for the input arguments.
*
* ### Template specialization
*
*
* - The class is templatized on the class of the produced objects, __TypeBase__.
* - The class is templatized on the class of the produced objects, __TypeBase__.
* The produced objects are always of a class deriving from TypeBase.
* The produced objects are always of a class deriving from TypeBase.
* The returned data is always a pointer to TypeBase.
* The returned data is always a shared pointer to TypeBase.
*
*
* For example, you may use as __TypeBase__ the following types:
* For example, you may use as __TypeBase__ the following types:
* - LandmarkBase: the Factory creates landmarks deriving from LandmarkBase and returns base pointers ````LandmarkBasePtr```` to them
* - LandmarkBase: the Factory creates landmarks deriving from LandmarkBase and returns base pointers ````LandmarkBasePtr```` to them
* - ParamsSensorBase: the Factory creates intrinsic parameters deriving from ParamsSensorBase and returns base pointers ````ParamsSensorBasePtr```` to them
* - ParamsSensorBase: the Factory creates intrinsic parameters deriving from ParamsSensorBase and returns base pointers ````ParamsSensorBasePtr```` to them
* - XxxBase: the Factory creates objects deriving from XxxBase and returns pointers ````XxxBasePtr```` to them.
* - XxxBase: the Factory creates objects deriving from XxxBase and returns pointers ````XxxBasePtr```` to them.
*
*
* - The class in also templatized on the type of the input parameter of the creator, __TypeInput__:
* - The class is variadic-templatized on the types of the input parameter of the creator, __TypeInput__:
* - ````std::string```` is used when the input parameter is a file name from which to read data (typically a YAML file).
* - ````std::string```` is used when the input parameter is a file name from which to read data (typically a YAML file).
* - ````YAML::Node```` is used when the input parameter is a YAML node with structured data.
* - ````std::string, wolf::ParamsServer``` is used when nodes are build from parameters in the ParamsServer
* - ````YAML::Node```` is used when the input parameter is a YAML node with structured data.
* - Any other variadic list of inputs is possible.
*
* - Examples of specific factories existing in Wolf are:
* \code
*
* // SensorFactory
* typedef Factory<SensorBase, // Type of objects to be created: SensorBasePtr
* const std::string&, // Name of the sensor
* const Eigen::VectorXd&, // Sensor extrinsics
* const ParamsSensorBasePtr> // Sensor parameters
* SensorFactory;
*
* // ProcessorFactory
* typedef Factory<ProcessorBase, // Type of object created: ProcessorBasePtr
* const std::string&, // Name of the processor
* const ParamsProcessorBasePtr> // Parameters for creating the processor
* ProcessorFactory;
*
* // AutoConfProcessorFactory
* typedef Factory<ProcessorBase, // Type of object created: ProcessorBasePtr
* const std::string&, // Name of the processor
* const ParamsServer> // Parameters for creating the processor
* AutoConfProcessorFactory;
*
* // Landmarks from YAML
* typedef Factory<LandmarkBase, // Type of node created: LandmarkBasePtr
* const YAML::Node&> // YAML node with the lmk params
* LandmarkFactory;
* \endcode
*
*
* ### Operation of the factory
* ### Operation of the factory
*
*
* #### Rationale
* #### Rationale
*
*
* This factory can create objects of classes deriving from TypeBase.
* Once specialized, this factory can create objects of classes deriving from TypeBase.
*
*
* > For example, if you want to make a Landmark factory, set TypeBase = LandmarkBase.\n
* > For example, if you want to make a Landmark factory, set TypeBase = LandmarkBase.\n
* > Then, the factory will create specific landmarks deriving from LandmarkBase.\n
* > Then, the factory will create specific landmarks deriving from LandmarkBase.\n
...
@@ -75,18 +101,18 @@ namespace wolf
...
@@ -75,18 +101,18 @@ namespace wolf
* - Examples: Write and register a landmark creator for LandmarkPolyline2d.
* - Examples: Write and register a landmark creator for LandmarkPolyline2d.
*
*
* #### Define correct TYPE names
* #### Define correct TYPE names
* The rule to make new TYPE strings unique is that you skip the generic 'Type' prefix from your class name,
* We use a std::string with literally the same text as the derived class name, e.g.:
* and you build a string in CAPITALS with space separators, e.g.: