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

#include "PhBMonochromaticSpectrum.H"
#include "xrmlP.H"

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

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

bool PhBMonochromaticSpectrum::assign_wavelength(const SFFloat& value)
{
  // TODO: value range check!
  wavelength = value;
  status |= wavelength_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBMonochromaticSpectrum_wavelength(SFNode* node, const fieldValue& value)
{
  PhBMonochromaticSpectrum* PhBMonochromaticSpectrum_node = dynamic_cast<PhBMonochromaticSpectrum*>(node);
  if (!PhBMonochromaticSpectrum_node)
    Fatal(-1, "assign_PhBMonochromaticSpectrum_wavelength", "called for a non-PhBMonochromaticSpectrum node");
  return PhBMonochromaticSpectrum_node->assign_wavelength((const SFFloat&)value);
}

void PhBMonochromaticSpectrum::set_wavelength(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PhBMonochromaticSpectrum::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_PhBMonochromaticSpectrum_luminance(SFNode* node, const fieldValue& value)
{
  PhBMonochromaticSpectrum* PhBMonochromaticSpectrum_node = dynamic_cast<PhBMonochromaticSpectrum*>(node);
  if (!PhBMonochromaticSpectrum_node)
    Fatal(-1, "assign_PhBMonochromaticSpectrum_luminance", "called for a non-PhBMonochromaticSpectrum node");
  return PhBMonochromaticSpectrum_node->assign_luminance((const SFFloat&)value);
}

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

PhBMonochromaticSpectrum::PhBMonochromaticSpectrum()
{
  interfaceMember* the_interface[2] = {
    new exposedField("wavelength", fieldValue(&wavelength), assign_PhBMonochromaticSpectrum_wavelength),
    new exposedField("luminance", fieldValue(&luminance), assign_PhBMonochromaticSpectrum_luminance),
  };
  SFNode::construct(PhBMonochromaticSpectrumTypeId, 2, the_interface);

  wavelength = 550;
  luminance = 1;
  
  PhBSpectrum::util_init();
  PhBMonochromaticSpectrum::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
