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

#include "AudioClip.H"
#include "xrmlP.H"

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

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

bool AudioClip::assign_description(const SFString& value)
{
  // TODO: value range check!
  description = value;
  status |= description_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_AudioClip_description(SFNode* node, const fieldValue& value)
{
  AudioClip* AudioClip_node = dynamic_cast<AudioClip*>(node);
  if (!AudioClip_node)
    Fatal(-1, "assign_AudioClip_description", "called for a non-AudioClip node");
  return AudioClip_node->assign_description((const SFString&)value);
}

void AudioClip::set_description(const SFString& val)
{
  SFString tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

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

static bool assign_AudioClip_loop(SFNode* node, const fieldValue& value)
{
  AudioClip* AudioClip_node = dynamic_cast<AudioClip*>(node);
  if (!AudioClip_node)
    Fatal(-1, "assign_AudioClip_loop", "called for a non-AudioClip node");
  return AudioClip_node->assign_loop((const SFBool&)value);
}

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

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

static bool assign_AudioClip_pitch(SFNode* node, const fieldValue& value)
{
  AudioClip* AudioClip_node = dynamic_cast<AudioClip*>(node);
  if (!AudioClip_node)
    Fatal(-1, "assign_AudioClip_pitch", "called for a non-AudioClip node");
  return AudioClip_node->assign_pitch((const SFFloat&)value);
}

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

bool AudioClip::assign_startTime(const SFTime& value)
{
  // TODO: value range check!
  startTime = value;
  status |= startTime_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_AudioClip_startTime(SFNode* node, const fieldValue& value)
{
  AudioClip* AudioClip_node = dynamic_cast<AudioClip*>(node);
  if (!AudioClip_node)
    Fatal(-1, "assign_AudioClip_startTime", "called for a non-AudioClip node");
  return AudioClip_node->assign_startTime((const SFTime&)value);
}

void AudioClip::set_startTime(const SFTime& val)
{
  SFTime tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

bool AudioClip::assign_stopTime(const SFTime& value)
{
  // TODO: value range check!
  stopTime = value;
  status |= stopTime_updated;
  timestamp = interface[4]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_AudioClip_stopTime(SFNode* node, const fieldValue& value)
{
  AudioClip* AudioClip_node = dynamic_cast<AudioClip*>(node);
  if (!AudioClip_node)
    Fatal(-1, "assign_AudioClip_stopTime", "called for a non-AudioClip node");
  return AudioClip_node->assign_stopTime((const SFTime&)value);
}

void AudioClip::set_stopTime(const SFTime& val)
{
  SFTime tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

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

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

void AudioClip::set_url(const MFString& val)
{
  MFString tmpval(val);
  fieldValue v(&tmpval);
  interface[5]->assign(this, v);
}

void AudioClip::post_duration_changed(void)
{
  interface[6]->post(this, interface[6]->value);
}

void AudioClip::post_duration_changed(const SFTime& val)
{
  duration_changed = val;
  status |= duration_changed_updated;
  post_duration_changed();
}

void AudioClip::post_isActive(void)
{
  interface[7]->post(this, interface[7]->value);
}

void AudioClip::post_isActive(const SFBool& val)
{
  isActive = val;
  status |= isActive_updated;
  post_isActive();
}

AudioClip::AudioClip()
{
  interfaceMember* the_interface[8] = {
    new exposedField("description", fieldValue(&description), assign_AudioClip_description),
    new exposedField("loop", fieldValue(&loop), assign_AudioClip_loop),
    new exposedField("pitch", fieldValue(&pitch), assign_AudioClip_pitch),
    new exposedField("startTime", fieldValue(&startTime), assign_AudioClip_startTime),
    new exposedField("stopTime", fieldValue(&stopTime), assign_AudioClip_stopTime),
    new exposedField("url", fieldValue(&url), assign_AudioClip_url),
    new eventOut("duration_changed", fieldValue(&duration_changed)),
    new eventOut("isActive", fieldValue(&isActive)),
  };
  SFNode::construct(AudioClipTypeId, 8, the_interface);

  description = "";
  loop = 0;
  pitch = 1;
  startTime = 0;
  stopTime = 0;
  url = MFString(0);
  duration_changed = 0;
  isActive = 0;
  
  TimeDependent::util_init();
  SoundSource::util_init();
  AudioClip::util_init();
}

void AudioClip::destruct(void)
{
  AudioClip::util_destruct();
  TimeDependent::util_destruct();
  SoundSource::util_destruct();
  SFNode::destruct();
}

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

void AudioClip::clone_here(const AudioClip& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&description);
  interface[1]->value = fieldValue(&loop);
  interface[2]->value = fieldValue(&pitch);
  interface[3]->value = fieldValue(&startTime);
  interface[4]->value = fieldValue(&stopTime);
  interface[5]->value = fieldValue(&url);
  interface[6]->value = fieldValue(&duration_changed);
  interface[7]->value = fieldValue(&isActive);
  
  description = src.description;
  loop = src.loop;
  pitch = src.pitch;
  startTime = src.startTime;
  stopTime = src.stopTime;
  url = src.url;
  duration_changed = src.duration_changed;
  isActive = src.isActive;
  
  TimeDependent::util_clone(src);
  SoundSource::util_clone(src);
  AudioClip::util_clone(src);
}

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

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

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

}  // namespace xrml
