/**
 * File: contextxmlhandler.h
 * Created by: <Joern Reimerdes>
 * @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 __CONTEXT_XML_HANDLER_H_
#define __CONTEXT_XML_HANDLER_H_

#include <iwear_utils_xml/xmlhandler.h>

using namespace iwear::xml;

namespace iwear{ 
namespace context{

    /* XML nodes names */
    extern const  XMLCh* NODE_CONTEXTS ;
    extern const  XMLCh* NODE_CONTEXT ;

    extern const  XMLCh* NODE_ATOMIC ;
    extern const  XMLCh* NODE_SENSOR ;
    extern const  XMLCh* NODE_COMPOSITE ;
    extern const  XMLCh* NODE_LOGIC ;
    extern const  XMLCh* NODE_CONTEXT_REF ;
    
    extern const  XMLCh* NODE_DEFINITIONS ;
    extern const  XMLCh* NODE_COMPARISON ;
    extern const  XMLCh* NODE_LOGIC_RELATION ;
    extern const  XMLCh* NODE_VALUE_TYPE ;

    /* XML attribute names */

    extern const  XMLCh* ATTRIBUTE_NAME ;
    extern const  XMLCh* ATTRIBUTE_TYPE ;
    extern const  XMLCh* ATTRIBUTE_COMPARE_VALUE ;
    extern const  XMLCh* ATTRIBUTE_COMPARISON ;
    extern const  XMLCh* ATTRIBUTE_UNIT ;
    extern const  XMLCh* ATTRIBUTE_ACCURACY ;
    extern const  XMLCh* ATTRIBUTE_VALUE_TYPE ;
    extern const  XMLCh* ATTRIBUTE_LOGIC_RELATION ;
    extern const  XMLCh* ATTRIBUTE_OPERATOR ;

    /* values */
    extern const  XMLCh* VALUE_AND ;
    extern const  XMLCh* VALUE_OR ;

    extern const  XMLCh* VALUE_EQUALS ;
    extern const  XMLCh* VALUE_NOT_EQUALS ;
    extern const  XMLCh* VALUE_GREATER ;
    extern const  XMLCh* VALUE_LOWER ;
    extern const  XMLCh* VALUE_GREATER_EQUALS ;
    extern const  XMLCh* VALUE_LOWER_EQUALS ;

    extern const  XMLCh* VALUE_BOOLEAN ;
    extern const  XMLCh* VALUE_DATE ;
    extern const  XMLCh* VALUE_NOMINAL ;
    extern const  XMLCh* VALUE_ORDINAL ;
    extern const  XMLCh* VALUE_DISCRETE ;
    extern const  XMLCh* VALUE_CONTINOUS ;
    extern const  XMLCh* VALUE_ACCURACY ;


class ContextXMLHandler
{
public:

    ContextXMLHandler(XMLHandler* xml_handler);

    ~ContextXMLHandler();

    /** 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;
    }

    /** Gets the XML handler.
     * @return The XML handler the ContextXMLParser works with.
     */
    inline XMLHandler* get_xml_handler(){
	return this->xml_handler;
    }
    
protected:

private:

    /** The ContextXMLHandler 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.
     */
    XMLHandler* xml_handler;

    /** Initialises the node name and attribute name constants if they
     * were net initialised before.
     */
    void init_constants(void);

}; // ContextXMLHandler
}  // context
}  // iwear

#endif	//__CONTEXT_XML_HANDLER_H_
