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

#include "PhBImageTexture.H"
#include "xrmlP.H"

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

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

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

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

bool PhBImageTexture::assign_clamping(const SFBool& value)
{
  // TODO: value range check!
  clamping = value;
  status |= clamping_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBImageTexture_clamping(SFNode* node, const fieldValue& value)
{
  PhBImageTexture* PhBImageTexture_node = dynamic_cast<PhBImageTexture*>(node);
  if (!PhBImageTexture_node)
    Fatal(-1, "assign_PhBImageTexture_clamping", "called for a non-PhBImageTexture node");
  return PhBImageTexture_node->assign_clamping((const SFBool&)value);
}

void PhBImageTexture::set_clamping(const SFBool& val)
{
  SFBool tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

bool PhBImageTexture::assign_repeating(const SFBool& value)
{
  // TODO: value range check!
  repeating = value;
  status |= repeating_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBImageTexture_repeating(SFNode* node, const fieldValue& value)
{
  PhBImageTexture* PhBImageTexture_node = dynamic_cast<PhBImageTexture*>(node);
  if (!PhBImageTexture_node)
    Fatal(-1, "assign_PhBImageTexture_repeating", "called for a non-PhBImageTexture node");
  return PhBImageTexture_node->assign_repeating((const SFBool&)value);
}

void PhBImageTexture::set_repeating(const SFBool& val)
{
  SFBool tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

PhBImageTexture::PhBImageTexture()
{
  interfaceMember* the_interface[3] = {
    new field("url", fieldValue(&url), assign_PhBImageTexture_url),
    new exposedField("clamping", fieldValue(&clamping), assign_PhBImageTexture_clamping),
    new exposedField("repeating", fieldValue(&repeating), assign_PhBImageTexture_repeating),
  };
  SFNode::construct(PhBImageTextureTypeId, 3, the_interface);

  url = MFString(0);
  clamping = 0;
  repeating = 1;
  
  PhBTexture::util_init();
  PhBImageTextureBase::util_init();
  PhBImageTexture::util_init();
}

void PhBImageTexture::destruct(void)
{
  PhBImageTexture::util_destruct();
  PhBImageTextureBase::util_destruct();
  PhBTexture::util_destruct();
  SFNode::destruct();
}

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

void PhBImageTexture::clone_here(const PhBImageTexture& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&url);
  interface[1]->value = fieldValue(&clamping);
  interface[2]->value = fieldValue(&repeating);
  
  url = src.url;
  clamping = src.clamping;
  repeating = src.repeating;
  
  PhBTexture::util_clone(src);
  PhBImageTextureBase::util_clone(src);
  PhBImageTexture::util_clone(src);
}

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

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

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

}  // namespace xrml
