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

#include "PhBTabulatedSpectrum.H"
#include "xrmlP.H"

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

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

bool PhBTabulatedSpectrum::assign_wavelengths(const MFFloat& value)
{
  // TODO: value range check!
  wavelengths = value;
  status |= wavelengths_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBTabulatedSpectrum_wavelengths(SFNode* node, const fieldValue& value)
{
  PhBTabulatedSpectrum* PhBTabulatedSpectrum_node = dynamic_cast<PhBTabulatedSpectrum*>(node);
  if (!PhBTabulatedSpectrum_node)
    Fatal(-1, "assign_PhBTabulatedSpectrum_wavelengths", "called for a non-PhBTabulatedSpectrum node");
  return PhBTabulatedSpectrum_node->assign_wavelengths((const MFFloat&)value);
}

void PhBTabulatedSpectrum::set_wavelengths(const MFFloat& val)
{
  MFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PhBTabulatedSpectrum::assign_values(const MFFloat& value)
{
  // TODO: value range check!
  values = value;
  status |= values_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBTabulatedSpectrum_values(SFNode* node, const fieldValue& value)
{
  PhBTabulatedSpectrum* PhBTabulatedSpectrum_node = dynamic_cast<PhBTabulatedSpectrum*>(node);
  if (!PhBTabulatedSpectrum_node)
    Fatal(-1, "assign_PhBTabulatedSpectrum_values", "called for a non-PhBTabulatedSpectrum node");
  return PhBTabulatedSpectrum_node->assign_values((const MFFloat&)value);
}

void PhBTabulatedSpectrum::set_values(const MFFloat& val)
{
  MFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

bool PhBTabulatedSpectrum::assign_scale(const SFFloat& value)
{
  // TODO: value range check!
  scale = value;
  status |= scale_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBTabulatedSpectrum_scale(SFNode* node, const fieldValue& value)
{
  PhBTabulatedSpectrum* PhBTabulatedSpectrum_node = dynamic_cast<PhBTabulatedSpectrum*>(node);
  if (!PhBTabulatedSpectrum_node)
    Fatal(-1, "assign_PhBTabulatedSpectrum_scale", "called for a non-PhBTabulatedSpectrum node");
  return PhBTabulatedSpectrum_node->assign_scale((const SFFloat&)value);
}

void PhBTabulatedSpectrum::set_scale(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

PhBTabulatedSpectrum::PhBTabulatedSpectrum()
{
  interfaceMember* the_interface[3] = {
    new exposedField("wavelengths", fieldValue(&wavelengths), assign_PhBTabulatedSpectrum_wavelengths),
    new exposedField("values", fieldValue(&values), assign_PhBTabulatedSpectrum_values),
    new exposedField("scale", fieldValue(&scale), assign_PhBTabulatedSpectrum_scale),
  };
  SFNode::construct(PhBTabulatedSpectrumTypeId, 3, the_interface);

  wavelengths = MFFloat(0);
  values = MFFloat(0);
  scale = 1;
  
  PhBSpectrum::util_init();
  PhBTabulatedSpectrum::util_init();
}

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

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

void PhBTabulatedSpectrum::clone_here(const PhBTabulatedSpectrum& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&wavelengths);
  interface[1]->value = fieldValue(&values);
  interface[2]->value = fieldValue(&scale);
  
  wavelengths = src.wavelengths;
  values = src.values;
  scale = src.scale;
  
  PhBSpectrum::util_clone(src);
  PhBTabulatedSpectrum::util_clone(src);
}

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

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

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

}  // namespace xrml
