#ifndef CLUSTER_DEVICE_CLASSIFIER_HH
# define CLUSTER_DEVICE_CLASSIFIER_HH

# include <utility>

# include "utils/Random.hh" 
# include "devices/DevicesManager.hh"
# include "StateVector.hh"
# include "AbstractClassifier.hh"

/** @brief Classifiers for devices outputs
 *
 * This abstract class provide a generic interfacze used to implement
 * a classifier that will take its data from one or more devices. The
 * data extraction is managed dynamically from this class and the
 * concrete classifier will have directly the data into a StateVector
 *
 * @author Frederic Py <fpy@mbari.org>
 */
class DeviceClassifier :public AbstractClassifier {
protected:
  /** @brief Constructor
   *
   * @param args Parameters extracted from a configuartion file
   *
   * This constructor extract trhe vector descirption from @e args
   * and connect to the used devices and get the devices data entry
   * points corresponding to its needs.
   */
  DeviceClassifier(ArgList const &args);
  /** @brief Destructor
   */
  virtual ~DeviceClassifier() {}
  
  /** @brief Dimension of the data space
   *
   * @return the dimension of vectors used for classification
   */
  size_t dimension() const;
  
  virtual void classify(StateVector &v, std::vector<cluster_type> &winners,
			dist_type &dist) =0;

private:
  SingletonUse<DevicesManager> m_devices;
  std::vector< std::pair<AbstractDevice *, dbEntry *> > m_fields;
  StateVector m_current;

  bool classify(cluster_type &winner, dist_type &distance);

  static SingletonUse<Random> s_rand_gen;
}; // DeviceClassifier

#endif // CLUSTER_DEVICE_CLASSIFIER_HH
