// PhBMonitorCalibrationP.C: PhBMonitorCalibration nodes (private source).
// Automatically generated with nodegen 0.5a - do not edit.

#include "PhBMonitorCalibration.H"
#include "xrmlP.H"

namespace xrml {
int PhBMonitorCalibration::major_version(void) { return 0; }
int PhBMonitorCalibration::minor_version(void) { return 5; }
bool PhBMonitorCalibration::is_leaf_class(void) { return true; }

bool IsPhBMonitorCalibration(SFNode* node)
{
  return (dynamic_cast<PhBMonitorCalibration*>(node) != 0);
}

static void process_PhBMonitorCalibration_set_bind(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "process_PhBMonitorCalibration_set_bind", "called for a non-PhBMonitorCalibration node");
  PhBMonitorCalibration_node->set_bind((const SFBool&)value);
}

void PhBMonitorCalibration::post_isBound(void)
{
  interface[1]->post(this, interface[1]->value);
}

void PhBMonitorCalibration::post_isBound(const SFBool& val)
{
  isBound = val;
  status |= isBound_updated;
  post_isBound();
}

void PhBMonitorCalibration::synchronize_red(void)
{
  red = (_red) ? dynamic_cast<PhBSpectrum*>(_red->firstnode()) : 0;
}

bool PhBMonitorCalibration::assign_red(SFNode* value)
{
  SFNode* oldval = _red;
  _red = value;
  if (checkValue(_red, IsPhBSpectrum, "PhBMonitorCalibration.red", "PhBSpectrum")) {
    synchronize_red();
    status |= red_updated;
    timestamp = interface[2]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _red = oldval;
    return false;
  }
}

static bool assign_PhBMonitorCalibration_red(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_red", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_red((SFNode*&)value);
}

void PhBMonitorCalibration::set_red(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

void PhBMonitorCalibration::synchronize_green(void)
{
  green = (_green) ? dynamic_cast<PhBSpectrum*>(_green->firstnode()) : 0;
}

bool PhBMonitorCalibration::assign_green(SFNode* value)
{
  SFNode* oldval = _green;
  _green = value;
  if (checkValue(_green, IsPhBSpectrum, "PhBMonitorCalibration.green", "PhBSpectrum")) {
    synchronize_green();
    status |= green_updated;
    timestamp = interface[3]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _green = oldval;
    return false;
  }
}

static bool assign_PhBMonitorCalibration_green(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_green", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_green((SFNode*&)value);
}

void PhBMonitorCalibration::set_green(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

void PhBMonitorCalibration::synchronize_blue(void)
{
  blue = (_blue) ? dynamic_cast<PhBSpectrum*>(_blue->firstnode()) : 0;
}

bool PhBMonitorCalibration::assign_blue(SFNode* value)
{
  SFNode* oldval = _blue;
  _blue = value;
  if (checkValue(_blue, IsPhBSpectrum, "PhBMonitorCalibration.blue", "PhBSpectrum")) {
    synchronize_blue();
    status |= blue_updated;
    timestamp = interface[4]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _blue = oldval;
    return false;
  }
}

static bool assign_PhBMonitorCalibration_blue(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_blue", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_blue((SFNode*&)value);
}

void PhBMonitorCalibration::set_blue(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

void PhBMonitorCalibration::synchronize_white(void)
{
  white = (_white) ? dynamic_cast<PhBSpectrum*>(_white->firstnode()) : 0;
}

bool PhBMonitorCalibration::assign_white(SFNode* value)
{
  SFNode* oldval = _white;
  _white = value;
  if (checkValue(_white, IsPhBSpectrum, "PhBMonitorCalibration.white", "PhBSpectrum")) {
    synchronize_white();
    status |= white_updated;
    timestamp = interface[5]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _white = oldval;
    return false;
  }
}

static bool assign_PhBMonitorCalibration_white(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_white", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_white((SFNode*&)value);
}

void PhBMonitorCalibration::set_white(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[5]->assign(this, v);
}

bool PhBMonitorCalibration::assign_gamma(const SFColor& value)
{
  // TODO: value range check!
  gamma = value;
  status |= gamma_updated;
  timestamp = interface[6]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBMonitorCalibration_gamma(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_gamma", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_gamma((const SFColor&)value);
}

void PhBMonitorCalibration::set_gamma(const SFColor& val)
{
  SFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[6]->assign(this, v);
}

bool PhBMonitorCalibration::assign_maxLuminance(const SFFloat& value)
{
  // TODO: value range check!
  maxLuminance = value;
  status |= maxLuminance_updated;
  timestamp = interface[7]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBMonitorCalibration_maxLuminance(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_maxLuminance", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_maxLuminance((const SFFloat&)value);
}

void PhBMonitorCalibration::set_maxLuminance(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[7]->assign(this, v);
}

bool PhBMonitorCalibration::assign_maxContrast(const SFFloat& value)
{
  // TODO: value range check!
  maxContrast = value;
  status |= maxContrast_updated;
  timestamp = interface[8]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBMonitorCalibration_maxContrast(SFNode* node, const fieldValue& value)
{
  PhBMonitorCalibration* PhBMonitorCalibration_node = dynamic_cast<PhBMonitorCalibration*>(node);
  if (!PhBMonitorCalibration_node)
    Fatal(-1, "assign_PhBMonitorCalibration_maxContrast", "called for a non-PhBMonitorCalibration node");
  return PhBMonitorCalibration_node->assign_maxContrast((const SFFloat&)value);
}

void PhBMonitorCalibration::set_maxContrast(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[8]->assign(this, v);
}

PhBMonitorCalibration::PhBMonitorCalibration()
{
  interfaceMember* the_interface[9] = {
    new eventIn("set_bind", tSFBool, process_PhBMonitorCalibration_set_bind),
    new eventOut("isBound", fieldValue(&isBound)),
    new exposedField("red", fieldValue(&_red), assign_PhBMonitorCalibration_red),
    new exposedField("green", fieldValue(&_green), assign_PhBMonitorCalibration_green),
    new exposedField("blue", fieldValue(&_blue), assign_PhBMonitorCalibration_blue),
    new exposedField("white", fieldValue(&_white), assign_PhBMonitorCalibration_white),
    new exposedField("gamma", fieldValue(&gamma), assign_PhBMonitorCalibration_gamma),
    new exposedField("maxLuminance", fieldValue(&maxLuminance), assign_PhBMonitorCalibration_maxLuminance),
    new exposedField("maxContrast", fieldValue(&maxContrast), assign_PhBMonitorCalibration_maxContrast),
  };
  SFNode::construct(PhBMonitorCalibrationTypeId, 9, the_interface);

  isBound = 0;
  red = (PhBSpectrum *)0; 	_red = (SFNode *)0;
  green = (PhBSpectrum *)0; 	_green = (SFNode *)0;
  blue = (PhBSpectrum *)0; 	_blue = (SFNode *)0;
  white = (PhBSpectrum *)0; 	_white = (SFNode *)0;
  gamma = SFColor(1,1,1);
  maxLuminance = 100;
  maxContrast = 50;
  
  Bindable::util_init();
  Children::util_init();
  PhBMonitorCalibration::util_init();
}

void PhBMonitorCalibration::destruct(void)
{
  PhBMonitorCalibration::util_destruct();
  Bindable::util_destruct();
  Children::util_destruct();
  SFNode::destruct();
}

PhBMonitorCalibration::~PhBMonitorCalibration()
{
  destruct();
}

void PhBMonitorCalibration::clone_here(const PhBMonitorCalibration& src)
{
  SFNode::clone(src);
  
  interface[1]->value = fieldValue(&isBound);
  interface[2]->value = fieldValue(&_red);
  interface[3]->value = fieldValue(&_green);
  interface[4]->value = fieldValue(&_blue);
  interface[5]->value = fieldValue(&_white);
  interface[6]->value = fieldValue(&gamma);
  interface[7]->value = fieldValue(&maxLuminance);
  interface[8]->value = fieldValue(&maxContrast);
  
  isBound = src.isBound;
  red = src.red;	  _red = src._red;
  green = src.green;	  _green = src._green;
  blue = src.blue;	  _blue = src._blue;
  white = src.white;	  _white = src._white;
  gamma = src.gamma;
  maxLuminance = src.maxLuminance;
  maxContrast = src.maxContrast;
  
  Bindable::util_clone(src);
  Children::util_clone(src);
  PhBMonitorCalibration::util_clone(src);
}

PhBMonitorCalibration::PhBMonitorCalibration(const PhBMonitorCalibration& src)
{
  clone_here(src);
}

PhBMonitorCalibration& PhBMonitorCalibration::operator=(const PhBMonitorCalibration& src)
{
  if (this != &src) {
    destruct();
    clone_here(src);
  }
  return *this;
}

SFNode* PhBMonitorCalibration::instantiate(Proto *enclosing_proto)
{
  if (nameIndex>=0)
    // named node: return pointer to pre-made instance
    return enclosing_proto ? enclosing_proto->namedNodes[nameIndex] : this;
  
  PhBMonitorCalibration* instance = new PhBMonitorCalibration(*this);
  instance->instantiate_interface(enclosing_proto);
  instance->synchronize_red();
  instance->synchronize_green();
  instance->synchronize_blue();
  instance->synchronize_white();
  return instance;
}

}  // namespace xrml
