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

#include "PhBVolumeDistortion.H"
#include "xrmlP.H"

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

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

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

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

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

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

void PhBVolumeDistortion::synchronize_transform(void)
{
  transform = (_transform) ? dynamic_cast<Transform*>(_transform->firstnode()) : 0;
}

bool PhBVolumeDistortion::assign_transform(SFNode* value)
{
  SFNode* oldval = _transform;
  _transform = value;
  if (checkValue(_transform, IsTransform, "PhBVolumeDistortion.transform", "Transform")) {
    synchronize_transform();
    status |= transform_updated;
    timestamp = interface[1]->timestamp = world ? world->time : 0;
    return true;
  } else {
    _transform = oldval;
    return false;
  }
}

static bool assign_PhBVolumeDistortion_transform(SFNode* node, const fieldValue& value)
{
  PhBVolumeDistortion* PhBVolumeDistortion_node = dynamic_cast<PhBVolumeDistortion*>(node);
  if (!PhBVolumeDistortion_node)
    Fatal(-1, "assign_PhBVolumeDistortion_transform", "called for a non-PhBVolumeDistortion node");
  return PhBVolumeDistortion_node->assign_transform((SFNode*&)value);
}

void PhBVolumeDistortion::set_transform(SFNode* val)
{
  SFNode* tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

PhBVolumeDistortion::PhBVolumeDistortion()
{
  interfaceMember* the_interface[2] = {
    new exposedField("texture", fieldValue(&_texture), assign_PhBVolumeDistortion_texture),
    new exposedField("transform", fieldValue(&_transform), assign_PhBVolumeDistortion_transform),
  };
  SFNode::construct(PhBVolumeDistortionTypeId, 2, the_interface);

  texture = (PhB3DTexture *)0; 	_texture = (SFNode *)0;
  transform = (Transform *)0; 	_transform = (SFNode *)0;
  
  PhBDistortion::util_init();
  PhBVolumeDistortion::util_init();
}

void PhBVolumeDistortion::destruct(void)
{
  PhBVolumeDistortion::util_destruct();
  PhBDistortion::util_destruct();
  SFNode::destruct();
}

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

void PhBVolumeDistortion::clone_here(const PhBVolumeDistortion& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&_texture);
  interface[1]->value = fieldValue(&_transform);
  
  texture = src.texture;	  _texture = src._texture;
  transform = src.transform;	  _transform = src._transform;
  
  PhBDistortion::util_clone(src);
  PhBVolumeDistortion::util_clone(src);
}

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

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

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

}  // namespace xrml
