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

#include "PhBPixelTexture.H"
#include "xrmlP.H"

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

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

bool PhBPixelTexture::assign_channels(const SFInt32& value)
{
  // TODO: value range check!
  channels = value;
  status |= channels_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBPixelTexture_channels(SFNode* node, const fieldValue& value)
{
  PhBPixelTexture* PhBPixelTexture_node = dynamic_cast<PhBPixelTexture*>(node);
  if (!PhBPixelTexture_node)
    Fatal(-1, "assign_PhBPixelTexture_channels", "called for a non-PhBPixelTexture node");
  return PhBPixelTexture_node->assign_channels((const SFInt32&)value);
}

bool PhBPixelTexture::assign_width(const SFInt32& value)
{
  // TODO: value range check!
  width = value;
  status |= width_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBPixelTexture_width(SFNode* node, const fieldValue& value)
{
  PhBPixelTexture* PhBPixelTexture_node = dynamic_cast<PhBPixelTexture*>(node);
  if (!PhBPixelTexture_node)
    Fatal(-1, "assign_PhBPixelTexture_width", "called for a non-PhBPixelTexture node");
  return PhBPixelTexture_node->assign_width((const SFInt32&)value);
}

bool PhBPixelTexture::assign_height(const SFInt32& value)
{
  // TODO: value range check!
  height = value;
  status |= height_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBPixelTexture_height(SFNode* node, const fieldValue& value)
{
  PhBPixelTexture* PhBPixelTexture_node = dynamic_cast<PhBPixelTexture*>(node);
  if (!PhBPixelTexture_node)
    Fatal(-1, "assign_PhBPixelTexture_height", "called for a non-PhBPixelTexture node");
  return PhBPixelTexture_node->assign_height((const SFInt32&)value);
}

bool PhBPixelTexture::assign_pixels(const MFFloat& value)
{
  // TODO: value range check!
  pixels = value;
  status |= pixels_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBPixelTexture_pixels(SFNode* node, const fieldValue& value)
{
  PhBPixelTexture* PhBPixelTexture_node = dynamic_cast<PhBPixelTexture*>(node);
  if (!PhBPixelTexture_node)
    Fatal(-1, "assign_PhBPixelTexture_pixels", "called for a non-PhBPixelTexture node");
  return PhBPixelTexture_node->assign_pixels((const MFFloat&)value);
}

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

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

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

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

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

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

PhBPixelTexture::PhBPixelTexture()
{
  interfaceMember* the_interface[6] = {
    new field("channels", fieldValue(&channels), assign_PhBPixelTexture_channels),
    new field("width", fieldValue(&width), assign_PhBPixelTexture_width),
    new field("height", fieldValue(&height), assign_PhBPixelTexture_height),
    new field("pixels", fieldValue(&pixels), assign_PhBPixelTexture_pixels),
    new exposedField("clamping", fieldValue(&clamping), assign_PhBPixelTexture_clamping),
    new exposedField("repeating", fieldValue(&repeating), assign_PhBPixelTexture_repeating),
  };
  SFNode::construct(PhBPixelTextureTypeId, 6, the_interface);

  channels = 1;
  width = 0;
  height = 0;
  pixels = MFFloat(0);
  clamping = 0;
  repeating = 1;
  
  PhBTexture::util_init();
  PhBImageTextureBase::util_init();
  PhBPixelTexture::util_init();
}

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

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

void PhBPixelTexture::clone_here(const PhBPixelTexture& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&channels);
  interface[1]->value = fieldValue(&width);
  interface[2]->value = fieldValue(&height);
  interface[3]->value = fieldValue(&pixels);
  interface[4]->value = fieldValue(&clamping);
  interface[5]->value = fieldValue(&repeating);
  
  channels = src.channels;
  width = src.width;
  height = src.height;
  pixels = src.pixels;
  clamping = src.clamping;
  repeating = src.repeating;
  
  PhBTexture::util_clone(src);
  PhBImageTextureBase::util_clone(src);
  PhBPixelTexture::util_clone(src);
}

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

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

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

}  // namespace xrml
