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

#include "PhBLxySpectrum.H"
#include "xrmlP.H"

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

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

bool PhBLxySpectrum::assign_xy(const SFVec2f& value)
{
  // TODO: value range check!
  xy = value;
  status |= xy_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBLxySpectrum_xy(SFNode* node, const fieldValue& value)
{
  PhBLxySpectrum* PhBLxySpectrum_node = dynamic_cast<PhBLxySpectrum*>(node);
  if (!PhBLxySpectrum_node)
    Fatal(-1, "assign_PhBLxySpectrum_xy", "called for a non-PhBLxySpectrum node");
  return PhBLxySpectrum_node->assign_xy((const SFVec2f&)value);
}

void PhBLxySpectrum::set_xy(const SFVec2f& val)
{
  SFVec2f tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PhBLxySpectrum::assign_luminance(const SFFloat& value)
{
  // TODO: value range check!
  luminance = value;
  status |= luminance_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBLxySpectrum_luminance(SFNode* node, const fieldValue& value)
{
  PhBLxySpectrum* PhBLxySpectrum_node = dynamic_cast<PhBLxySpectrum*>(node);
  if (!PhBLxySpectrum_node)
    Fatal(-1, "assign_PhBLxySpectrum_luminance", "called for a non-PhBLxySpectrum node");
  return PhBLxySpectrum_node->assign_luminance((const SFFloat&)value);
}

void PhBLxySpectrum::set_luminance(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

PhBLxySpectrum::PhBLxySpectrum()
{
  interfaceMember* the_interface[2] = {
    new exposedField("xy", fieldValue(&xy), assign_PhBLxySpectrum_xy),
    new exposedField("luminance", fieldValue(&luminance), assign_PhBLxySpectrum_luminance),
  };
  SFNode::construct(PhBLxySpectrumTypeId, 2, the_interface);

  xy = SFVec2f(0.333333,0.333333);
  luminance = 1;
  
  PhBSpectrum::util_init();
  PhBLxySpectrum::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
