/**
 * File: atomicfactorysensor.h
 * Created by: <Joern Reimerdes>
 * Created on: 2004/10/13 18:00
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is a part of The iWear Framework.
 * In particular is this file a part of the Framework context Library
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __ATOMIC_FACTORY_SENSOR_H_ 
#define __ATOMIC_FACTORY_SENSOR_H_

#include <iwear/datetime.h>
#include <iwear-context/atomicfactoryinterface.h>
#include <iwear-context/sensorcontext.h>

using namespace iwear::xml;
using namespace iwear::context;

namespace iwear{ 
namespace context{

/** The Class AtomicFactorySensor handles the creation of
 * SensorContexts.
 */
class AtomicFactorySensor : public AtomicFactoryInterface {
public:

    /** Creates the AtomicFactorySensor.
     *
     * @param ContextManager* context_manager The Manager is needed to
     * add and register ContextObjects.
     * @param ContextXMLHandler* context_xml_handler The
     * ContextXMLHandler is used for some helper medthods.
     */
    AtomicFactorySensor(ContextManager* context_manager, ContextXMLHandler* context_xml_handler)
	: AtomicFactoryInterface (context_manager, context_xml_handler){

	/* Sensor Types */
	sensor_type_enum_map = new map<const string, SensorType>;
	(*sensor_type_enum_map)["temperature"] = TEMPERATURE;
	(*sensor_type_enum_map)["loudness"] = LOUDNESS;
	(*sensor_type_enum_map)["brightness"] = BRIGHTNESS;
	(*sensor_type_enum_map)["time"] = TIME;
	(*sensor_type_enum_map)["sysload"] = SYSLOAD;
    }

    /** Destroys the Factory and objects that where used in the factory.
     * @note Created ContextObjects will not be destroyed by this destructor.
     */
    virtual ~AtomicFactorySensor();

    /** This method created an SensorContext from the DOMElement.
     * 
     * @param string* context_name The name of the context that should
     * be created.
     * @param DOMElement* context_node The subnode of the
     * DOM atomic_node.
     */
    virtual ContextObject* create_atomic_context(string context_name, 
						 DOMElement* context_node);
    
protected:

    /** Gets the comparison of the DOM sensor node.
     * @param DOMElement* sensor_node The sensor node.
     * @return Comparison The enum value of the comparison.
     */
    Comparison get_comparison(DOMElement* sensor_node);

    /** Gets the compare value of the DOM sensor node.
     * @param DOMElement* sensor_node The sensor node.
     * @return double The compare value.
     */
    double get_compare_value(DOMElement* sensor_node);

    /** Gets the unit of the DOM sensor node value.
     * @param DOMElement* sensor_node The sensor_node.
     * @return units The compare unit.
     */
    units get_compare_unit(DOMElement* sensor_node);

    /** Gets the accuracy value of the DOM sensor node.
     * @param DOMElement* sensor_node The sensor node.
     * @return double The accuracy value.
     */
    double get_accuracy_value(DOMElement* sensor_node);

private:

    /** Map for SensorContext Type XML names to enum values. */
    map<const string, SensorType>* sensor_type_enum_map;
    

}; // AtomicFactorySensor
}  // context
}  // iwear

#endif	//__ATOMIC_FACTORY_SENSOR_H_
