/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NSCRIPTEDOBJECT__
#define	__NSCRIPTEDOBJECT__


		#include "script/script_vm.h"
		#include "container/nlist.h"


namespace GS {
	namespace NML { class Tag; }
	namespace Script {
		class Unit;

/*
	@short	Scripted object base class.
	@author	Emmanuel Julien (ejulien@gsworks.fr)
*/
class	ScriptedObject
{
		List <Unit *> unit_list;

protected:

		sVM			vm;

public:

		/// Unit factory.
virtual	Unit		*NewUnit() const = 0;

		IVM			*GetVM() const { return vm; }

		Unit		*AddUnit(Unit *);
		bool		RemoveUnit(Unit *);
		void		RemoveAllUnit();

		Unit		*GetUnit(const char *script_path, const char *script_class) const;
		const List <Unit *> &GetUnitList() const { return unit_list; }

/*!
	@name	Serialization.
	@{
*/
		bool		FromMetaTag(NML::Tag &);
		NML::Tag	*AsMetaTag() const;
/// @}

		ScriptedObject(IVM *v) : vm(v) {}
virtual	~ScriptedObject();
};

	} // Script
} // GS


#endif	// __NSCRIPTEDOBJECT__
