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

#include "PhBSampledIsotropicEmitter.H"
#include "xrmlP.H"

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

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

bool PhBSampledIsotropicEmitter::assign_samples(const MFFloat& value)
{
  // TODO: value range check!
  samples = value;
  status |= samples_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSampledIsotropicEmitter_samples(SFNode* node, const fieldValue& value)
{
  PhBSampledIsotropicEmitter* PhBSampledIsotropicEmitter_node = dynamic_cast<PhBSampledIsotropicEmitter*>(node);
  if (!PhBSampledIsotropicEmitter_node)
    Fatal(-1, "assign_PhBSampledIsotropicEmitter_samples", "called for a non-PhBSampledIsotropicEmitter node");
  return PhBSampledIsotropicEmitter_node->assign_samples((const MFFloat&)value);
}

void PhBSampledIsotropicEmitter::set_samples(const MFFloat& val)
{
  MFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PhBSampledIsotropicEmitter::assign_minAngle(const SFFloat& value)
{
  // TODO: value range check!
  minAngle = value;
  status |= minAngle_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSampledIsotropicEmitter_minAngle(SFNode* node, const fieldValue& value)
{
  PhBSampledIsotropicEmitter* PhBSampledIsotropicEmitter_node = dynamic_cast<PhBSampledIsotropicEmitter*>(node);
  if (!PhBSampledIsotropicEmitter_node)
    Fatal(-1, "assign_PhBSampledIsotropicEmitter_minAngle", "called for a non-PhBSampledIsotropicEmitter node");
  return PhBSampledIsotropicEmitter_node->assign_minAngle((const SFFloat&)value);
}

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

bool PhBSampledIsotropicEmitter::assign_maxAngle(const SFFloat& value)
{
  // TODO: value range check!
  maxAngle = value;
  status |= maxAngle_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSampledIsotropicEmitter_maxAngle(SFNode* node, const fieldValue& value)
{
  PhBSampledIsotropicEmitter* PhBSampledIsotropicEmitter_node = dynamic_cast<PhBSampledIsotropicEmitter*>(node);
  if (!PhBSampledIsotropicEmitter_node)
    Fatal(-1, "assign_PhBSampledIsotropicEmitter_maxAngle", "called for a non-PhBSampledIsotropicEmitter node");
  return PhBSampledIsotropicEmitter_node->assign_maxAngle((const SFFloat&)value);
}

void PhBSampledIsotropicEmitter::set_maxAngle(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

PhBSampledIsotropicEmitter::PhBSampledIsotropicEmitter()
{
  interfaceMember* the_interface[3] = {
    new exposedField("samples", fieldValue(&samples), assign_PhBSampledIsotropicEmitter_samples),
    new exposedField("minAngle", fieldValue(&minAngle), assign_PhBSampledIsotropicEmitter_minAngle),
    new exposedField("maxAngle", fieldValue(&maxAngle), assign_PhBSampledIsotropicEmitter_maxAngle),
  };
  SFNode::construct(PhBSampledIsotropicEmitterTypeId, 3, the_interface);

  samples = MFFloat(0);
  minAngle = 0;
  maxAngle = 3.14159;
  
  PhBEmitter::util_init();
  PhBSampledIsotropicEmitter::util_init();
}

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

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

void PhBSampledIsotropicEmitter::clone_here(const PhBSampledIsotropicEmitter& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&samples);
  interface[1]->value = fieldValue(&minAngle);
  interface[2]->value = fieldValue(&maxAngle);
  
  samples = src.samples;
  minAngle = src.minAngle;
  maxAngle = src.maxAngle;
  
  PhBEmitter::util_clone(src);
  PhBSampledIsotropicEmitter::util_clone(src);
}

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

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

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

}  // namespace xrml
