/*!\file BoolInput.c
 * \brief: implementation of the BoolInput object
 */

#ifdef HAVE_CONFIG_H
	#include <config.h>
#else
#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
#endif

#include <stdio.h>
#include <string.h>
#include "../objects.h"
#include "../../EnumDefinitions/EnumDefinitions.h"
#include "../../shared/shared.h"
#include "../../Container/Container.h"
#include "../../include/include.h"

/*BoolInput constructors and destructor*/
/*FUNCTION BoolInput::BoolInput(){{{1*/
BoolInput::BoolInput(){
	return;
}
/*}}}*/
/*FUNCTION BoolInput::BoolInput(double* values){{{1*/
BoolInput::BoolInput(int in_enum_type,IssmBool in_value){

	enum_type=in_enum_type;
	value=in_value;
}
/*}}}*/
/*FUNCTION BoolInput::~BoolInput(){{{1*/
BoolInput::~BoolInput(){
	return;
}
/*}}}*/

/*Object virtual functions definitions:*/
/*FUNCTION BoolInput::Echo {{{1*/
void BoolInput::Echo(void){
	this->DeepEcho();
}
/*}}}*/
/*FUNCTION BoolInput::DeepEcho{{{1*/
void BoolInput::DeepEcho(void){

	printf("BoolInput:\n");
	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
	printf("   value: %s\n",value?"true":"false");
}
/*}}}*/
/*FUNCTION BoolInput::Id{{{1*/
int    BoolInput::Id(void){ return -1; }
/*}}}*/
/*FUNCTION BoolInput::MyRank{{{1*/
int    BoolInput::MyRank(void){ 
	extern int my_rank;
	return my_rank; 
}
/*}}}*/
/*FUNCTION BoolInput::ObjectEnum{{{1*/
int BoolInput::ObjectEnum(void){

	return BoolInputEnum;

}
/*}}}*/
/*FUNCTION BoolInput::copy{{{1*/
Object* BoolInput::copy() {
	
	return new BoolInput(this->enum_type,this->value);

}
/*}}}*/
	
/*BoolInput management*/
/*FUNCTION BoolInput::InstanceEnum{{{1*/
int BoolInput::InstanceEnum(void){

	return this->enum_type;

}
/*}}}*/
/*FUNCTION BoolInput::SpawnTriaInput{{{1*/
Input* BoolInput::SpawnTriaInput(int* indices){

		/*output*/
		BoolInput* outinput=new BoolInput();

		/*only copy current value*/
		outinput->enum_type=this->enum_type;
		outinput->value=this->value;

		/*Assign output*/
		return outinput;

}
/*}}}*/
/*FUNCTION BoolInput::SpawnResult{{{1*/
ElementResult* BoolInput::SpawnResult(int step, double time){
	
	return new BoolElementResult(this->enum_type,this->value,step,time);

}
/*}}}*/

/*Object functions*/
/*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{1*/
void BoolInput::GetInputValue(bool* pvalue){
	*pvalue=value;
}
/*}}}*/
/*FUNCTION BoolInput::GetInputValue(int* pvalue){{{1*/
void BoolInput::GetInputValue(int* pvalue){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::GetInputValue(double* pvalue){{{1*/
void BoolInput::GetInputValue(double* pvalue){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
void BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
void BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
/*}}}*/
/*FUNCTION BoolInput::ChangeEnum{{{1*/
void BoolInput::ChangeEnum(int newenumtype){
	this->enum_type=newenumtype;
}
/*}}}*/
/*FUNCTION BoolInput::SquareMin{{{1*/
void BoolInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
	/*square of a bool is the bool itself: */
	*psquaremin=value;
}
/*}}}*/
/*FUNCTION BoolInput::Scale{{{1*/
void BoolInput::Scale(double scale_factor){
	/*a bool cannot be scaled: */
}
/*}}}*/
/*FUNCTION BoolInput::AXPY{{{1*/
void BoolInput::AXPY(Input* xinput,double scalar){

	BoolInput*  xboolinput=NULL;

	/*xinput is of the same type, so cast it: */
	xboolinput=(BoolInput*)xinput;

	/*Carry out the AXPY operation depending on type:*/
	switch(xinput->ObjectEnum()){

		case BoolInputEnum:
			this->value=(bool)(this->value+scalar*xboolinput->value);
			return;

		default:
			_error_("not implemented yet");
	}

}
/*}}}*/
/*FUNCTION BoolInput::Constrain{{{1*/
void BoolInput::Constrain(double cm_min, double cm_max, double cm_thresh){

	if(!isnan(cm_min)) if (this->value<cm_min)this->value=cm_min;
	if(!isnan(cm_max)) if (this->value>cm_max)this->value=cm_max;
	if(!isnan(cm_thresh)) if (this->value<cm_thresh)this->value=cm_min;

}
/*}}}*/
/*FUNCTION BoolInput::Extrude{{{1*/
void BoolInput::Extrude(void){

	/*do nothing*/
	return;
}
/*}}}*/
/*FUNCTION BoolInput::GetVectorFromInputs{{{1*/
void BoolInput::GetVectorFromInputs(Vector* vector,int* doflist){

	_error_(" not supporte yet!");

}
/*}}}*/
/*FUNCTION BoolInput::GetValuesPtr{{{1*/
void BoolInput::GetValuesPtr(double** pvalues,int* pnum_values){

	_error_(" not supported yet!");

}
/*}}}*/
/*FUNCTION BoolInput::Configure{{{1*/
void BoolInput::Configure(Parameters* parameters){
	/*do nothing: */
}
/*}}}*/
