#include "myvardef.h"
#include "../../modulemanager/moduletype.h"
#include "../../modulemanager/modulemanager.h"

const char* MyVarDef::type="MyVarDef";

const char* MyVarDef::getType() const
{
	return type;
}

void MyVarDef::doSerialize(TiXmlElement& element) const
{
	element.SetAttribute("type",moduleType->getName().c_str());
	element.SetAttribute("name",def->getName());
}

void MyVarDef::doDeserialize(const TiXmlElement& element)
{
	const char* type=element.Attribute("type");
	Ptr<ModuleType> moduleType=ModuleManager::manager->getModuleType(type);

	this->moduleType=(ModuleType*)moduleType.asObject();
	if (this->moduleType==0) return;

	def=moduleType->getVariable(element.Attribute("name"));
}
