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

#include "Coordinate.H"
#include "xrmlP.H"

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

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

bool Coordinate::assign_point(const MFVec3f& value)
{
  // TODO: value range check!
  point = value;
  status |= point_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Coordinate_point(SFNode* node, const fieldValue& value)
{
  Coordinate* Coordinate_node = dynamic_cast<Coordinate*>(node);
  if (!Coordinate_node)
    Fatal(-1, "assign_Coordinate_point", "called for a non-Coordinate node");
  return Coordinate_node->assign_point((const MFVec3f&)value);
}

void Coordinate::set_point(const MFVec3f& val)
{
  MFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

Coordinate::Coordinate()
{
  interfaceMember* the_interface[1] = {
    new exposedField("point", fieldValue(&point), assign_Coordinate_point),
  };
  SFNode::construct(CoordinateTypeId, 1, the_interface);

  point = MFVec3f(0);
  
  Coordinate::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
