/*
WARNING: This header should never be directly included. Include factory.h instead.

Author:		Chris Kaynor (chris@kaynor.net)
Edited By:		

Description:		Provides a standardized interface for the factory class to use. All
			itemClasses require, as a minimum, a constructor which takes a
			nameType refrence and a paramType and a getName function which
			returns a refrence to nameType.
			
Usage:		Derive this abstract base class for any classes which are inteneded to
			be loaded by Factory to verify that all such classes meet the minimum
			requirements. Be sure to pass the name on to this class's constructor,
			or to call the setName function.
			
Requirements:	string as defined in the standard template libary.
			NoCopy as defined in kLibrary's common section.
			
Last Edited:	May 20th, 2008
*/
/*
Copyright 2008 Chris Kaynor

This file is part of kLibrary.

kLibrary is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or(at your option) any later version.

kLibrary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License.
*/

#ifndef KLIBRARY_FACTORY_ITEM_H
#define KLIBRARY_FACTORY_ITEM_H

#include <string>

namespace kLibrary
{
	namespace factory
	{
		template<class paramType, class nameType = std::string>
		class Item : NoCopy
		{
		public:
			/*
			The constructor is presumed to take a name and a paramType, and to load a proper instance of the object.
			As such, the constructor should call the load function.
			*/
			inline Item(const nameType& name = "", paramType param = paramType());
			
			/*
			Load should load the object. If the derived class should not be loaded outside of initialization, the derived class
			may redefine this function as private, as it is never directly called.
			*/
			virtual Item& load(const nameType& name, paramType param) = 0;
			
			/*
			getName is called by the unload, getUsage, and deleteItem functions of the factory, if an instance of the object
			is passed in instead of a name.
			*/
			inline const nameType& getName(void) const;

		protected:
			/*
			WARNING: Changing the name after construction will not change the name by which the factory
			knows about the item. The renameItem function of the factory must also be called.
			
			setName should be called if the name needs to be changed.
			*/
			inline Item& setName(const nameType& name);
			
		private:
			nameType _name;
		};
	}
}

#include "factory_item_code.h"

#endif //KLIBRARY_FACTORY_ITEM_H