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

#include "PhBSampledSpectrum.H"
#include "xrmlP.H"

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

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

bool PhBSampledSpectrum::assign_samples(const MFFloat& value)
{
  // TODO: value range check!
  samples = value;
  status |= samples_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSampledSpectrum_samples(SFNode* node, const fieldValue& value)
{
  PhBSampledSpectrum* PhBSampledSpectrum_node = dynamic_cast<PhBSampledSpectrum*>(node);
  if (!PhBSampledSpectrum_node)
    Fatal(-1, "assign_PhBSampledSpectrum_samples", "called for a non-PhBSampledSpectrum node");
  return PhBSampledSpectrum_node->assign_samples((const MFFloat&)value);
}

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

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

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

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

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

static bool assign_PhBSampledSpectrum_min(SFNode* node, const fieldValue& value)
{
  PhBSampledSpectrum* PhBSampledSpectrum_node = dynamic_cast<PhBSampledSpectrum*>(node);
  if (!PhBSampledSpectrum_node)
    Fatal(-1, "assign_PhBSampledSpectrum_min", "called for a non-PhBSampledSpectrum node");
  return PhBSampledSpectrum_node->assign_min((const SFFloat&)value);
}

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

bool PhBSampledSpectrum::assign_max(const SFFloat& value)
{
  // TODO: value range check!
  max = value;
  status |= max_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSampledSpectrum_max(SFNode* node, const fieldValue& value)
{
  PhBSampledSpectrum* PhBSampledSpectrum_node = dynamic_cast<PhBSampledSpectrum*>(node);
  if (!PhBSampledSpectrum_node)
    Fatal(-1, "assign_PhBSampledSpectrum_max", "called for a non-PhBSampledSpectrum node");
  return PhBSampledSpectrum_node->assign_max((const SFFloat&)value);
}

void PhBSampledSpectrum::set_max(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

PhBSampledSpectrum::PhBSampledSpectrum()
{
  interfaceMember* the_interface[4] = {
    new exposedField("samples", fieldValue(&samples), assign_PhBSampledSpectrum_samples),
    new exposedField("scale", fieldValue(&scale), assign_PhBSampledSpectrum_scale),
    new exposedField("min", fieldValue(&min), assign_PhBSampledSpectrum_min),
    new exposedField("max", fieldValue(&max), assign_PhBSampledSpectrum_max),
  };
  SFNode::construct(PhBSampledSpectrumTypeId, 4, the_interface);

  samples = MFFloat(0);
  scale = 1;
  min = 380;
  max = 770;
  
  PhBSpectrum::util_init();
  PhBSampledSpectrum::util_init();
}

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

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

void PhBSampledSpectrum::clone_here(const PhBSampledSpectrum& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&samples);
  interface[1]->value = fieldValue(&scale);
  interface[2]->value = fieldValue(&min);
  interface[3]->value = fieldValue(&max);
  
  samples = src.samples;
  scale = src.scale;
  min = src.min;
  max = src.max;
  
  PhBSpectrum::util_clone(src);
  PhBSampledSpectrum::util_clone(src);
}

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

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

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

}  // namespace xrml
