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

#include "WorldInfo.H"
#include "xrmlP.H"

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

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

bool WorldInfo::assign_info(const MFString& value)
{
  // TODO: value range check!
  info = value;
  status |= info_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_WorldInfo_info(SFNode* node, const fieldValue& value)
{
  WorldInfo* WorldInfo_node = dynamic_cast<WorldInfo*>(node);
  if (!WorldInfo_node)
    Fatal(-1, "assign_WorldInfo_info", "called for a non-WorldInfo node");
  return WorldInfo_node->assign_info((const MFString&)value);
}

bool WorldInfo::assign_title(const SFString& value)
{
  // TODO: value range check!
  title = value;
  status |= title_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_WorldInfo_title(SFNode* node, const fieldValue& value)
{
  WorldInfo* WorldInfo_node = dynamic_cast<WorldInfo*>(node);
  if (!WorldInfo_node)
    Fatal(-1, "assign_WorldInfo_title", "called for a non-WorldInfo node");
  return WorldInfo_node->assign_title((const SFString&)value);
}

WorldInfo::WorldInfo()
{
  interfaceMember* the_interface[2] = {
    new field("info", fieldValue(&info), assign_WorldInfo_info),
    new field("title", fieldValue(&title), assign_WorldInfo_title),
  };
  SFNode::construct(WorldInfoTypeId, 2, the_interface);

  info = MFString(0);
  title = "";
  
  Children::util_init();
  WorldInfo::util_init();
}

void WorldInfo::destruct(void)
{
  WorldInfo::util_destruct();
  Children::util_destruct();
  SFNode::destruct();
}

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

void WorldInfo::clone_here(const WorldInfo& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&info);
  interface[1]->value = fieldValue(&title);
  
  info = src.info;
  title = src.title;
  
  Children::util_clone(src);
  WorldInfo::util_clone(src);
}

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

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

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

}  // namespace xrml
