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

#include "PhBPhongReflector.H"
#include "xrmlP.H"

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

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

bool PhBPhongReflector::assign_sharpness(const SFFloat& value)
{
  // TODO: value range check!
  sharpness = value;
  status |= sharpness_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBPhongReflector_sharpness(SFNode* node, const fieldValue& value)
{
  PhBPhongReflector* PhBPhongReflector_node = dynamic_cast<PhBPhongReflector*>(node);
  if (!PhBPhongReflector_node)
    Fatal(-1, "assign_PhBPhongReflector_sharpness", "called for a non-PhBPhongReflector node");
  return PhBPhongReflector_node->assign_sharpness((const SFFloat&)value);
}

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

PhBPhongReflector::PhBPhongReflector()
{
  interfaceMember* the_interface[1] = {
    new exposedField("sharpness", fieldValue(&sharpness), assign_PhBPhongReflector_sharpness),
  };
  SFNode::construct(PhBPhongReflectorTypeId, 1, the_interface);

  sharpness = 0;
  
  PhBScatterer::util_init();
  PhBPhongReflector::util_init();
}

void PhBPhongReflector::destruct(void)
{
  PhBPhongReflector::util_destruct();
  PhBScatterer::util_destruct();
  SFNode::destruct();
}

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

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

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

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

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

}  // namespace xrml
