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

#include "Fog.H"
#include "xrmlP.H"

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

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

bool Fog::assign_color(const SFColor& value)
{
  // TODO: value range check!
  color = value;
  status |= color_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Fog_color(SFNode* node, const fieldValue& value)
{
  Fog* Fog_node = dynamic_cast<Fog*>(node);
  if (!Fog_node)
    Fatal(-1, "assign_Fog_color", "called for a non-Fog node");
  return Fog_node->assign_color((const SFColor&)value);
}

void Fog::set_color(const SFColor& val)
{
  SFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool Fog::assign_fogType(const SFString& value)
{
  // TODO: value range check!
  fogType = value;
  status |= fogType_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Fog_fogType(SFNode* node, const fieldValue& value)
{
  Fog* Fog_node = dynamic_cast<Fog*>(node);
  if (!Fog_node)
    Fatal(-1, "assign_Fog_fogType", "called for a non-Fog node");
  return Fog_node->assign_fogType((const SFString&)value);
}

void Fog::set_fogType(const SFString& val)
{
  SFString tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

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

static bool assign_Fog_visibilityRange(SFNode* node, const fieldValue& value)
{
  Fog* Fog_node = dynamic_cast<Fog*>(node);
  if (!Fog_node)
    Fatal(-1, "assign_Fog_visibilityRange", "called for a non-Fog node");
  return Fog_node->assign_visibilityRange((const SFFloat&)value);
}

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

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

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

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

Fog::Fog()
{
  interfaceMember* the_interface[5] = {
    new exposedField("color", fieldValue(&color), assign_Fog_color),
    new exposedField("fogType", fieldValue(&fogType), assign_Fog_fogType),
    new exposedField("visibilityRange", fieldValue(&visibilityRange), assign_Fog_visibilityRange),
    new eventIn("set_bind", tSFBool, process_Fog_set_bind),
    new eventOut("isBound", fieldValue(&isBound)),
  };
  SFNode::construct(FogTypeId, 5, the_interface);

  color = SFColor(1,1,1);
  fogType = "LINEAR";
  visibilityRange = 0;
  isBound = 0;
  
  Bindable::util_init();
  Children::util_init();
  Fog::util_init();
}

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

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

void Fog::clone_here(const Fog& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&color);
  interface[1]->value = fieldValue(&fogType);
  interface[2]->value = fieldValue(&visibilityRange);
  interface[4]->value = fieldValue(&isBound);
  
  color = src.color;
  fogType = src.fogType;
  visibilityRange = src.visibilityRange;
  isBound = src.isBound;
  
  Bindable::util_clone(src);
  Children::util_clone(src);
  Fog::util_clone(src);
}

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

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

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

}  // namespace xrml
