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

#include "Normal.H"
#include "xrmlP.H"

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

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

bool Normal::assign_vector(const MFVec3f& value)
{
  // TODO: value range check!
  vector = value;
  status |= vector_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Normal_vector(SFNode* node, const fieldValue& value)
{
  Normal* Normal_node = dynamic_cast<Normal*>(node);
  if (!Normal_node)
    Fatal(-1, "assign_Normal_vector", "called for a non-Normal node");
  return Normal_node->assign_vector((const MFVec3f&)value);
}

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

Normal::Normal()
{
  interfaceMember* the_interface[1] = {
    new exposedField("vector", fieldValue(&vector), assign_Normal_vector),
  };
  SFNode::construct(NormalTypeId, 1, the_interface);

  vector = MFVec3f(0);
  
  Normal::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
