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

#include "PhBBlackBodySpectrum.H"
#include "xrmlP.H"

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

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

bool PhBBlackBodySpectrum::assign_temperature(const SFFloat& value)
{
  // TODO: value range check!
  temperature = value;
  status |= temperature_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBBlackBodySpectrum_temperature(SFNode* node, const fieldValue& value)
{
  PhBBlackBodySpectrum* PhBBlackBodySpectrum_node = dynamic_cast<PhBBlackBodySpectrum*>(node);
  if (!PhBBlackBodySpectrum_node)
    Fatal(-1, "assign_PhBBlackBodySpectrum_temperature", "called for a non-PhBBlackBodySpectrum node");
  return PhBBlackBodySpectrum_node->assign_temperature((const SFFloat&)value);
}

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

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

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

PhBBlackBodySpectrum::PhBBlackBodySpectrum()
{
  interfaceMember* the_interface[2] = {
    new exposedField("temperature", fieldValue(&temperature), assign_PhBBlackBodySpectrum_temperature),
    new exposedField("luminance", fieldValue(&luminance), assign_PhBBlackBodySpectrum_luminance),
  };
  SFNode::construct(PhBBlackBodySpectrumTypeId, 2, the_interface);

  temperature = 0;
  luminance = 1;
  
  PhBSpectrum::util_init();
  PhBBlackBodySpectrum::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
