/*
** SellaNMS
** $Id: format_statement_from_variable.h,v 1.6 2005/05/21 23:10:28 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __FORMAT_STATEMENT_FROM_VARIABLE_H__
#define __FORMAT_STATEMENT_FROM_VARIABLE_H__

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "clause.h"
#include "suffix.h"
#include "dependency.h"

#include <stl/slist>
#include <stl/string>
#include <stl/hash_map>

#define	DEFAULT_TYPE		(TYPE_STR)
#define	DEFAULT_FUNCTION	(FUNCTION_EQ)
#define	DEFAULT_REQUIRED	(false)

class FormatStatementFromVariable: public Clause {
	public:
		FormatStatementFromVariable();
		virtual ~FormatStatementFromVariable();
	
		string getName();	
		RESULT setName(string &name);	
		RESULT setVariableType(unsigned long &type, string &variable);
		RESULT setVariableFunction(unsigned long &function, string &variable);
		RESULT setVariableMap(slist<string> &mapStatements, string &variable);
		RESULT compileInherited(ConfigNode *config, bool required, unsigned long type, unsigned long function, slist<string> &mapStatements);

		virtual ACTION evaluate(variable_binding_t &input);		
		virtual RESULT compile(ConfigNode *config);

		virtual RESULT clear();
		virtual RESULT print(unsigned long depth = 0);

		RESULT getAppliedMapStatements(slist<string> &map_names);

	protected:
		RESULT addType(string &type);
		RESULT addFunction(string &function);

		RESULT addValue(string &map_name);
		RESULT addMapStatement(string &map_name);

		RESULT addSuffix(Suffix &suffix);
		RESULT addDependency(Dependency &dependency);

		bool									required;

		unsigned long						type;
		unsigned long						function;

		string								name;

		slist<string>						mapStatements;
		hash_map<string, bool>			values;
		hash_map<string, Suffix>		suffixes;
		hash_map<string, Dependency>	dependencies;
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3 sts=3
*/
