/**
 * File: atomicfactoryinterface.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_INTERFACE_H_
#define __ATOMIC_FACTORY_INTERFACE_H_

#include <string>
#include <list>
#include <iwear_utils_xml/xmlhandler.h>
#include <iwear-context/atomiccontext.h>
#include <iwear-context/contextxmlhandler.h>
#include <iwear-context/contextmanager.h>

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

namespace iwear{ 
namespace context{

/** The AtomicFactoryInterface is implemented by all AtomicFactories
 * and supports them with functions that help creating AtomicContexts.
 *
 * @note See AtomicFactorySensor and AtomicFactoryLocation for examples.
 */
class AtomicFactoryInterface
{
public:

    /** Creates the AtomicFactoryInterface.
     *
     * @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.
     */
    AtomicFactoryInterface(ContextManager* context_manager, 
			   ContextXMLHandler* context_xml_handler);	

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

    /** This method created an AtomicContext from the DOMElement.
     * This method should be implemented by the inherriting class.
     * @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) = 0;
    
protected:

    /** Maps strings to units. */
    map<string, units>* unit_map;

    /** Map for Comparison enum values to XML names. */
    map<Comparison, const XMLCh*>* comparison_map;

    /** Map for Sensor Type XML names to enum values. */
    map<const string, Comparison>* comparison_enum_map;    

    /** The contextmanager to wich the parsed contexts should be
     * registered to.
     */
    ContextManager* context_manager;

    /** The XMLHandler is used for dealing with xml files and DOM
     * trees. It has some helper methods to support the traversing of
     * the tree.
     * @note The instance will be deleted within the destructer of the
     *  ContextXMLParser.
     */
    ContextXMLHandler* context_xml_handler;

    /** Returns the value of the type attribute of a DOMElement.
     * @param DOMElement* node The node the type value should be
     *  retreaved from.
     * @return const string The type value
     */
    inline const string get_type_from_node(DOMElement* node){
	const char * str = XMLString::transcode(node->getAttribute(ATTRIBUTE_TYPE));
	string z = str;
	delete[] str;
	return z;
    }

private:    



}; // AtomicFactoryInterface
}  // context
}  // iwear

#endif	//__ATOMIC_FACTORY_INTERFACE_H_

