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

#include "Color.H"
#include "xrmlP.H"

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

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

bool Color::assign_color(const MFColor& value)
{
  // TODO: value range check!
  color = value;
  status |= color_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Color_color(SFNode* node, const fieldValue& value)
{
  Color* Color_node = dynamic_cast<Color*>(node);
  if (!Color_node)
    Fatal(-1, "assign_Color_color", "called for a non-Color node");
  return Color_node->assign_color((const MFColor&)value);
}

void Color::set_color(const MFColor& val)
{
  MFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

Color::Color()
{
  interfaceMember* the_interface[1] = {
    new exposedField("color", fieldValue(&color), assign_Color_color),
  };
  SFNode::construct(ColorTypeId, 1, the_interface);

  color = MFColor(0);
  
  Color::util_init();
}

void Color::destruct(void)
{
  Color::util_destruct();
  SFNode::destruct();
}

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

void Color::clone_here(const Color& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&color);
  
  color = src.color;
  
  Color::util_clone(src);
}

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

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

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

}  // namespace xrml
