#ifndef CLUSTER_FACTORY_DECLARE_HH
# define CLUSTER_FACTORY_DECLARE_HH

# include "GlobalFactory.hh"

/** @brief GlobalFactory declaration class
 *
 * This class allows to declare a new producer to a GlobalFactory. 
 * The corresponding producer will be available as long as this
 * class instance exist.
 *
 * @param Product Real product of the producer
 * @param AbstractProduct Product as seen  by the GlobalFactory
 * @param ConsArg Construction argument to be provided to create a new @e Product
 *
 * The declaration is made into GlobalFactory<AbstractProduct, ConsArg>
 *
 * @pre @e Product must be derived from @e AbstractProduct
 * @pre @e Product must have a constructor that takes @e ConsArg as argument
 *
 * @author Frederic Py <fpy@mbari.org>
 */
template<class Product, class AbstractProduct, class ConsArg>
class FactoryDeclare 
  :public GlobalFactory<AbstractProduct, ConsArg>::dummyDecl {
public:
  /** @brief Constructor
   *
   * @param type An identifier
   * 
   * Declare a new producer identified by @e type.
   *
   * @pre @e type must be an identifier wghich is not already used by a
   * producer on GlobalFactory<AbstractProduct, ConsArg>
   *
   * @sa void GlobalFactory::declare(GlobalFactory::dummyDecl *)
   */
  FactoryDeclare(Symbol const &type)
    :GlobalFactory<AbstractProduct, ConsArg>::dummyDecl(type) {
    declareMe();
  }
  /** @brief Destructor
   *
   * Undeclare the producer to the GlobalFactory
   */
  virtual ~FactoryDeclare() {}

private:
  AbstractProduct *produce(ConsArg const &arg) const {
    return new Product(arg);
  }
      
}; // FactoryDeclare<>

#endif // CLUSTER_FACTORY_DECLARE_HH
