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

#include "PhBAtmosphere.H"
#include "xrmlP.H"

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

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

static void process_PhBAtmosphere_set_bind(SFNode* node, const fieldValue& value)
{
  PhBAtmosphere* PhBAtmosphere_node = dynamic_cast<PhBAtmosphere*>(node);
  if (!PhBAtmosphere_node)
    Fatal(-1, "process_PhBAtmosphere_set_bind", "called for a non-PhBAtmosphere node");
  PhBAtmosphere_node->set_bind((const SFBool&)value);
}

void PhBAtmosphere::post_isBound(void)
{
  interface[1]->post(this, interface[1]->value);
}

void PhBAtmosphere::post_isBound(const SFBool& val)
{
  isBound = val;
  status |= isBound_updated;
  post_isBound();
}

void PhBAtmosphere::synchronize_medium(void)
{
  medium = (_medium) ? dynamic_cast<PhBMedium*>(_medium->firstnode()) : 0;
}

bool PhBAtmosphere::assign_medium(SFNode* value)
{
  SFNode* oldval = _medium;
  _medium = value;
  if (checkValue(_medium, IsPhBMedium, "PhBAtmosphere.medium", "PhBMedium")) {
    synchronize_medium();
    status |= medium_updated;
    timestamp = interface[2]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _medium = oldval;
    return false;
  }
}

static bool assign_PhBAtmosphere_medium(SFNode* node, const fieldValue& value)
{
  PhBAtmosphere* PhBAtmosphere_node = dynamic_cast<PhBAtmosphere*>(node);
  if (!PhBAtmosphere_node)
    Fatal(-1, "assign_PhBAtmosphere_medium", "called for a non-PhBAtmosphere node");
  return PhBAtmosphere_node->assign_medium((SFNode*&)value);
}

void PhBAtmosphere::set_medium(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

PhBAtmosphere::PhBAtmosphere()
{
  interfaceMember* the_interface[3] = {
    new eventIn("set_bind", tSFBool, process_PhBAtmosphere_set_bind),
    new eventOut("isBound", fieldValue(&isBound)),
    new exposedField("medium", fieldValue(&_medium), assign_PhBAtmosphere_medium),
  };
  SFNode::construct(PhBAtmosphereTypeId, 3, the_interface);

  isBound = 0;
  medium = (PhBMedium *)0; 	_medium = (SFNode *)0;
  
  Bindable::util_init();
  Children::util_init();
  PhBAtmosphere::util_init();
}

void PhBAtmosphere::destruct(void)
{
  PhBAtmosphere::util_destruct();
  Bindable::util_destruct();
  Children::util_destruct();
  SFNode::destruct();
}

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

void PhBAtmosphere::clone_here(const PhBAtmosphere& src)
{
  SFNode::clone(src);
  
  interface[1]->value = fieldValue(&isBound);
  interface[2]->value = fieldValue(&_medium);
  
  isBound = src.isBound;
  medium = src.medium;	  _medium = src._medium;
  
  Bindable::util_clone(src);
  Children::util_clone(src);
  PhBAtmosphere::util_clone(src);
}

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

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

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

}  // namespace xrml
