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

#include "Background.H"
#include "xrmlP.H"

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

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

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

bool Background::assign_groundAngle(const MFFloat& value)
{
  // TODO: value range check!
  groundAngle = value;
  status |= groundAngle_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_groundAngle(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_groundAngle", "called for a non-Background node");
  return Background_node->assign_groundAngle((const MFFloat&)value);
}

void Background::set_groundAngle(const MFFloat& val)
{
  MFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

bool Background::assign_groundColor(const MFColor& value)
{
  // TODO: value range check!
  groundColor = value;
  status |= groundColor_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_groundColor(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_groundColor", "called for a non-Background node");
  return Background_node->assign_groundColor((const MFColor&)value);
}

void Background::set_groundColor(const MFColor& val)
{
  MFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

bool Background::assign_backUrl(const MFString& value)
{
  // TODO: value range check!
  backUrl = value;
  status |= backUrl_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_backUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_backUrl", "called for a non-Background node");
  return Background_node->assign_backUrl((const MFString&)value);
}

void Background::set_backUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

bool Background::assign_bottomUrl(const MFString& value)
{
  // TODO: value range check!
  bottomUrl = value;
  status |= bottomUrl_updated;
  timestamp = interface[4]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_bottomUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_bottomUrl", "called for a non-Background node");
  return Background_node->assign_bottomUrl((const MFString&)value);
}

void Background::set_bottomUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

bool Background::assign_frontUrl(const MFString& value)
{
  // TODO: value range check!
  frontUrl = value;
  status |= frontUrl_updated;
  timestamp = interface[5]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_frontUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_frontUrl", "called for a non-Background node");
  return Background_node->assign_frontUrl((const MFString&)value);
}

void Background::set_frontUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[5]->assign(this, v);
}

bool Background::assign_leftUrl(const MFString& value)
{
  // TODO: value range check!
  leftUrl = value;
  status |= leftUrl_updated;
  timestamp = interface[6]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_leftUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_leftUrl", "called for a non-Background node");
  return Background_node->assign_leftUrl((const MFString&)value);
}

void Background::set_leftUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[6]->assign(this, v);
}

bool Background::assign_rightUrl(const MFString& value)
{
  // TODO: value range check!
  rightUrl = value;
  status |= rightUrl_updated;
  timestamp = interface[7]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_rightUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_rightUrl", "called for a non-Background node");
  return Background_node->assign_rightUrl((const MFString&)value);
}

void Background::set_rightUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[7]->assign(this, v);
}

bool Background::assign_topUrl(const MFString& value)
{
  // TODO: value range check!
  topUrl = value;
  status |= topUrl_updated;
  timestamp = interface[8]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_topUrl(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_topUrl", "called for a non-Background node");
  return Background_node->assign_topUrl((const MFString&)value);
}

void Background::set_topUrl(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[8]->assign(this, v);
}

bool Background::assign_skyAngle(const MFFloat& value)
{
  // TODO: value range check!
  skyAngle = value;
  status |= skyAngle_updated;
  timestamp = interface[9]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_skyAngle(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_skyAngle", "called for a non-Background node");
  return Background_node->assign_skyAngle((const MFFloat&)value);
}

void Background::set_skyAngle(const MFFloat& val)
{
  MFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[9]->assign(this, v);
}

bool Background::assign_skyColor(const MFColor& value)
{
  // TODO: value range check!
  skyColor = value;
  status |= skyColor_updated;
  timestamp = interface[10]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Background_skyColor(SFNode* node, const fieldValue& value)
{
  Background* Background_node = dynamic_cast<Background*>(node);
  if (!Background_node)
    Fatal(-1, "assign_Background_skyColor", "called for a non-Background node");
  return Background_node->assign_skyColor((const MFColor&)value);
}

void Background::set_skyColor(const MFColor& val)
{
  MFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[10]->assign(this, v);
}

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

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

Background::Background()
{
  interfaceMember* the_interface[12] = {
    new eventIn("set_bind", tSFBool, process_Background_set_bind),
    new exposedField("groundAngle", fieldValue(&groundAngle), assign_Background_groundAngle),
    new exposedField("groundColor", fieldValue(&groundColor), assign_Background_groundColor),
    new exposedField("backUrl", fieldValue(&backUrl), assign_Background_backUrl),
    new exposedField("bottomUrl", fieldValue(&bottomUrl), assign_Background_bottomUrl),
    new exposedField("frontUrl", fieldValue(&frontUrl), assign_Background_frontUrl),
    new exposedField("leftUrl", fieldValue(&leftUrl), assign_Background_leftUrl),
    new exposedField("rightUrl", fieldValue(&rightUrl), assign_Background_rightUrl),
    new exposedField("topUrl", fieldValue(&topUrl), assign_Background_topUrl),
    new exposedField("skyAngle", fieldValue(&skyAngle), assign_Background_skyAngle),
    new exposedField("skyColor", fieldValue(&skyColor), assign_Background_skyColor),
    new eventOut("isBound", fieldValue(&isBound)),
  };
  SFNode::construct(BackgroundTypeId, 12, the_interface);

  groundAngle = MFFloat(0);
  groundColor = MFColor(0);
  backUrl = MFString(0);
  bottomUrl = MFString(0);
  frontUrl = MFString(0);
  leftUrl = MFString(0);
  rightUrl = MFString(0);
  topUrl = MFString(0);
  skyAngle = MFFloat(0);
  const SFColor _skyColor[1] = {SFColor(0,0,0)};
  skyColor = MFColor(1,(SFColor *)_skyColor);
  isBound = 0;
  
  Bindable::util_init();
  Children::util_init();
  Background::util_init();
}

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

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

void Background::clone_here(const Background& src)
{
  SFNode::clone(src);
  
  interface[1]->value = fieldValue(&groundAngle);
  interface[2]->value = fieldValue(&groundColor);
  interface[3]->value = fieldValue(&backUrl);
  interface[4]->value = fieldValue(&bottomUrl);
  interface[5]->value = fieldValue(&frontUrl);
  interface[6]->value = fieldValue(&leftUrl);
  interface[7]->value = fieldValue(&rightUrl);
  interface[8]->value = fieldValue(&topUrl);
  interface[9]->value = fieldValue(&skyAngle);
  interface[10]->value = fieldValue(&skyColor);
  interface[11]->value = fieldValue(&isBound);
  
  groundAngle = src.groundAngle;
  groundColor = src.groundColor;
  backUrl = src.backUrl;
  bottomUrl = src.bottomUrl;
  frontUrl = src.frontUrl;
  leftUrl = src.leftUrl;
  rightUrl = src.rightUrl;
  topUrl = src.topUrl;
  skyAngle = src.skyAngle;
  skyColor = src.skyColor;
  isBound = src.isBound;
  
  Bindable::util_clone(src);
  Children::util_clone(src);
  Background::util_clone(src);
}

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

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

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

}  // namespace xrml
