// PhBBilinearInterpolationP.C: PhBBilinearInterpolation nodes (private source).
// Automatically generated with nodegen 0.53 - do not edit.

#include "PhBBilinearInterpolation.H"
#include "xrmlP.H"

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

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

void PhBBilinearInterpolation::synchronize_texture(void)
{
  texture = (_texture) ? dynamic_cast<PhBImageTextureBase*>(_texture->firstnode()) : 0;
}

bool PhBBilinearInterpolation::assign_texture(SFNode* value)
{
  SFNode* oldval = _texture;
  _texture = value;
  if (checkValue(_texture, IsPhBImageTextureBase, "PhBBilinearInterpolation.texture", "PhBImageTextureBase")) {
    synchronize_texture();
    status |= texture_updated;
    timestamp = interface[0]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _texture = oldval;
    return false;
  }
}

static bool assign_PhBBilinearInterpolation_texture(SFNode* node, const fieldValue& value)
{
  PhBBilinearInterpolation* PhBBilinearInterpolation_node = dynamic_cast<PhBBilinearInterpolation*>(node);
  if (!PhBBilinearInterpolation_node)
    Fatal(-1, "assign_PhBBilinearInterpolation_texture", "called for a non-PhBBilinearInterpolation node");
  return PhBBilinearInterpolation_node->assign_texture((SFNode*&)value);
}

void PhBBilinearInterpolation::set_texture(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

PhBBilinearInterpolation::PhBBilinearInterpolation()
{
  interfaceMember* the_interface[1] = {
    new exposedField("texture", fieldValue(&_texture), assign_PhBBilinearInterpolation_texture),
  };
  SFNode::construct(PhBBilinearInterpolationTypeId, 1, the_interface);

  texture = (PhBImageTextureBase *)0; 	_texture = (SFNode *)0;
  
  PhBTexture::util_init();
  PhBBilinearInterpolation::util_init();
}

void PhBBilinearInterpolation::destruct(void)
{
  PhBBilinearInterpolation::util_destruct();
  PhBTexture::util_destruct();
  SFNode::destruct();
}

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

void PhBBilinearInterpolation::clone_here(const PhBBilinearInterpolation& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&_texture);
  
  texture = src.texture;	  _texture = src._texture;
  
  PhBTexture::util_clone(src);
  PhBBilinearInterpolation::util_clone(src);
}

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

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

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

}  // namespace xrml
