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

#include "PhBWardReflector.H"
#include "xrmlP.H"

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

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

bool PhBWardReflector::assign_standardDeviationX(const SFFloat& value)
{
  // TODO: value range check!
  standardDeviationX = value;
  status |= standardDeviationX_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBWardReflector_standardDeviationX(SFNode* node, const fieldValue& value)
{
  PhBWardReflector* PhBWardReflector_node = dynamic_cast<PhBWardReflector*>(node);
  if (!PhBWardReflector_node)
    Fatal(-1, "assign_PhBWardReflector_standardDeviationX", "called for a non-PhBWardReflector node");
  return PhBWardReflector_node->assign_standardDeviationX((const SFFloat&)value);
}

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

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

static bool assign_PhBWardReflector_standardDeviationY(SFNode* node, const fieldValue& value)
{
  PhBWardReflector* PhBWardReflector_node = dynamic_cast<PhBWardReflector*>(node);
  if (!PhBWardReflector_node)
    Fatal(-1, "assign_PhBWardReflector_standardDeviationY", "called for a non-PhBWardReflector node");
  return PhBWardReflector_node->assign_standardDeviationY((const SFFloat&)value);
}

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

PhBWardReflector::PhBWardReflector()
{
  interfaceMember* the_interface[2] = {
    new exposedField("standardDeviationX", fieldValue(&standardDeviationX), assign_PhBWardReflector_standardDeviationX),
    new exposedField("standardDeviationY", fieldValue(&standardDeviationY), assign_PhBWardReflector_standardDeviationY),
  };
  SFNode::construct(PhBWardReflectorTypeId, 2, the_interface);

  standardDeviationX = 1;
  standardDeviationY = 1;
  
  PhBScatterer::util_init();
  PhBWardReflector::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
