/**
 * File: atomicfactoryinterface.cpp
 * Created by: <Joern Reimerdes>
 * Created on: 2004/11/03 20:30 
 * @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
 */

#include <iwear-context/atomicfactoryinterface.h>


namespace iwear {
namespace context {

    /** Creates the AtomicFactoryInterface.
     *
     */
    AtomicFactoryInterface::AtomicFactoryInterface(ContextManager* context_manager,
					    ContextXMLHandler* context_xml_handler)
	: context_manager(context_manager), 
	  context_xml_handler(context_xml_handler){
	
	d_dbg << ANSI_RED << __FFL__ << ANSI_NORMAL << endl;

	this->context_manager = context_manager;
	this->context_xml_handler = context_xml_handler;

	/* Comparisons types */
	comparison_enum_map = new map<const string, Comparison>;
	(*comparison_enum_map)["equals"] = EQUALS;
	(*comparison_enum_map)["not equals"] = NOT_EQUALS;
	(*comparison_enum_map)["lower"] = LOWER;
	(*comparison_enum_map)["greater"] = GREATER;
	(*comparison_enum_map)["lower than"] = LOWER_EQUALS;
	(*comparison_enum_map)["greater"] = GREATER_EQUALS;

	comparison_map = new map<Comparison, const XMLCh*>;
	(*comparison_map)[EQUALS] = VALUE_EQUALS;
	(*comparison_map)[NOT_EQUALS] = VALUE_NOT_EQUALS;
	(*comparison_map)[LOWER] = VALUE_LOWER;
	(*comparison_map)[GREATER] = VALUE_GREATER;
	(*comparison_map)[LOWER_EQUALS] = VALUE_LOWER_EQUALS;
	(*comparison_map)[GREATER_EQUALS] = VALUE_GREATER_EQUALS;

	/* create unit map */
	unit_map = new map<string, units>;



	for (uint32_t unit_counter = 0; unit_counter < num_units; unit_counter++){
	    d_nons << __FFL__  << ": " << unit_counter << " of " 
		   << num_units << " " << unit_strings[unit_counter] 
		   << endl;
 	    unit_map->insert(pair<string, units>(unit_strings[unit_counter], 
 						 static_cast<units>(unit_counter)));
	}
    }

    /** Destroys the Factory and objects that where used in the factory.
     *
     */
    AtomicFactoryInterface::~AtomicFactoryInterface(){
	delete comparison_enum_map;
	delete comparison_map;
	delete unit_map;
    }

} // context
} // iwear

