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

#include "PhBRGBSpectrum.H"
#include "xrmlP.H"

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

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

bool PhBRGBSpectrum::assign_rgb(const SFColor& value)
{
  // TODO: value range check!
  rgb = value;
  status |= rgb_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBRGBSpectrum_rgb(SFNode* node, const fieldValue& value)
{
  PhBRGBSpectrum* PhBRGBSpectrum_node = dynamic_cast<PhBRGBSpectrum*>(node);
  if (!PhBRGBSpectrum_node)
    Fatal(-1, "assign_PhBRGBSpectrum_rgb", "called for a non-PhBRGBSpectrum node");
  return PhBRGBSpectrum_node->assign_rgb((const SFColor&)value);
}

void PhBRGBSpectrum::set_rgb(const SFColor& val)
{
  SFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

PhBRGBSpectrum::PhBRGBSpectrum()
{
  interfaceMember* the_interface[1] = {
    new exposedField("rgb", fieldValue(&rgb), assign_PhBRGBSpectrum_rgb),
  };
  SFNode::construct(PhBRGBSpectrumTypeId, 1, the_interface);

  rgb = SFColor(0,0,0);
  
  PhBSpectrum::util_init();
  PhBRGBSpectrum::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
