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

#include "PhBPhongEmitter.H"
#include "xrmlP.H"

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

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

bool PhBPhongEmitter::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_PhBPhongEmitter_sharpness(SFNode* node, const fieldValue& value)
{
  PhBPhongEmitter* PhBPhongEmitter_node = dynamic_cast<PhBPhongEmitter*>(node);
  if (!PhBPhongEmitter_node)
    Fatal(-1, "assign_PhBPhongEmitter_sharpness", "called for a non-PhBPhongEmitter node");
  return PhBPhongEmitter_node->assign_sharpness((const SFFloat&)value);
}

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

PhBPhongEmitter::PhBPhongEmitter()
{
  interfaceMember* the_interface[1] = {
    new exposedField("sharpness", fieldValue(&sharpness), assign_PhBPhongEmitter_sharpness),
  };
  SFNode::construct(PhBPhongEmitterTypeId, 1, the_interface);

  sharpness = 0;
  
  PhBEmitter::util_init();
  PhBPhongEmitter::util_init();
}

void PhBPhongEmitter::destruct(void)
{
  PhBPhongEmitter::util_destruct();
  PhBEmitter::util_destruct();
  SFNode::destruct();
}

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

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

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

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

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

}  // namespace xrml
