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

#include "PhBXYZSpectrum.H"
#include "xrmlP.H"

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

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

bool PhBXYZSpectrum::assign_xyz(const SFVec3f& value)
{
  // TODO: value range check!
  xyz = value;
  status |= xyz_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBXYZSpectrum_xyz(SFNode* node, const fieldValue& value)
{
  PhBXYZSpectrum* PhBXYZSpectrum_node = dynamic_cast<PhBXYZSpectrum*>(node);
  if (!PhBXYZSpectrum_node)
    Fatal(-1, "assign_PhBXYZSpectrum_xyz", "called for a non-PhBXYZSpectrum node");
  return PhBXYZSpectrum_node->assign_xyz((const SFVec3f&)value);
}

void PhBXYZSpectrum::set_xyz(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

PhBXYZSpectrum::PhBXYZSpectrum()
{
  interfaceMember* the_interface[1] = {
    new exposedField("xyz", fieldValue(&xyz), assign_PhBXYZSpectrum_xyz),
  };
  SFNode::construct(PhBXYZSpectrumTypeId, 1, the_interface);

  xyz = SFVec3f(1,1,1);
  
  PhBSpectrum::util_init();
  PhBXYZSpectrum::util_init();
}

void PhBXYZSpectrum::destruct(void)
{
  PhBXYZSpectrum::util_destruct();
  PhBSpectrum::util_destruct();
  SFNode::destruct();
}

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

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

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

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

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

}  // namespace xrml
