/*
** SellaNMS
** $Id: format_statement_term.cxx,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
*/

static char rcsid[] = "$Id: format_statement_term.cxx,v 1.6 2005/05/21 23:10:28 sella Exp $";

#include "format_statement_term.h"
#include "format_statement_from.h"
#include "format_statement_then.h"

FormatStatementTerm::FormatStatementTerm() {

}

FormatStatementTerm::FormatStatementTerm(Term const &src) {
	*this = src;
}

FormatStatementTerm::FormatStatementTerm(FormatStatementTerm const &src) {
	*this = src;
}

FormatStatementTerm::~FormatStatementTerm() {
}

Term const& FormatStatementTerm::operator=(Term const &src) {
	FormatStatementTerm *real_src = (FormatStatementTerm*) &src;

	return operator=(*real_src);
}

FormatStatementTerm const& FormatStatementTerm::operator=(FormatStatementTerm const &src) {
	/* Wipe object. */
	this->clear();

	/* Parent first. */
	Term::operator=(src);

	/* Do object specifics. */
	return *this;
}

From *FormatStatementTerm::getNewFromClause() const {
	return new FormatStatementFrom();
}

Then *FormatStatementTerm::getNewThenClause() const {
	return new FormatStatementThen();
}

RESULT FormatStatementTerm::getAppliedMapStatements(slist<string> &map_names) {
	RESULT result = SUCCESS;

	if (this->from != NULL) {
		if (((FormatStatementFrom *)(this->from))->getAppliedMapStatements(map_names) != SUCCESS) {
			result = FAILURE;
		}
	}
	return result;
}

RESULT FormatStatementTerm::setVariableType(unsigned long &type, string &variable) {
	/* If there is no from section, there is no rule to violate. */
	if (this->from == NULL) {
		return SUCCESS;
	}

	return ((FormatStatementFrom *)this->from)->setVariableType(type, variable);
}

RESULT FormatStatementTerm::setVariableFunction(unsigned long &function, string &variable) {
	/* If there is no from section, there is no rule to violate. */
	if (this->from == NULL) {
		return SUCCESS;
	}

	return ((FormatStatementFrom *)this->from)->setVariableFunction(function, variable);
}

/* ADDED */
RESULT FormatStatementTerm::setVariableMap(slist<string> &mapStatements, string &variable) {
	/* If there is no from section, there is no rule to violate. */
	if (this->from == NULL) {
		return SUCCESS;
	}

	return ((FormatStatementFrom *)this->from)->setVariableMap(mapStatements, variable);
}

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