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

#include "PhBProceduralBackground.H"
#include "xrmlP.H"

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

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

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

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

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

bool PhBProceduralBackground::assign_url(const MFString& value)
{
  // TODO: value range check!
  url = value;
  status |= url_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBProceduralBackground_url(SFNode* node, const fieldValue& value)
{
  PhBProceduralBackground* PhBProceduralBackground_node = dynamic_cast<PhBProceduralBackground*>(node);
  if (!PhBProceduralBackground_node)
    Fatal(-1, "assign_PhBProceduralBackground_url", "called for a non-PhBProceduralBackground node");
  return PhBProceduralBackground_node->assign_url((const MFString&)value);
}

PhBProceduralBackground::PhBProceduralBackground()
{
  interfaceMember* the_interface[3] = {
    new eventIn("set_bind", tSFBool, process_PhBProceduralBackground_set_bind),
    new eventOut("isBound", fieldValue(&isBound)),
    new field("url", fieldValue(&url), assign_PhBProceduralBackground_url),
  };
  SFNode::construct(PhBProceduralBackgroundTypeId, 3, the_interface);

  isBound = 0;
  url = MFString(0);
  
  Bindable::util_init();
  PhBBackground::util_init();
  Children::util_init();
  PhBProceduralBackground::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
