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

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

Description:		Provides the code for the template class factory::_Storage.
		
Usage:		See factory_storage.h for usage information and function and class comments.

Requirements:	See factory_storage.h for requirements.
		
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_STORAGE_CODE_H
#define KLIBRARY_FACTORY_STORAGE_CODE_H

#include "factory_storage.h"

namespace kLibrary
{
	namespace factory
	{
		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>::_Storage(const nameType& name, paramType param) : _item(name, param)
		{
			_usage = 0;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>& _Storage<itemType, paramType, nameType>::operator++()
		{
			_usage++;
			return *this;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>& _Storage<itemType, paramType, nameType>::operator--()
		{
			_usage--;
			return *this;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>& _Storage<itemType, paramType, nameType>::operator++(int)
		{
			_usage++;
			return *this;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>& _Storage<itemType, paramType, nameType>::operator--(int)
		{
			_usage--;
			return *this;			
		}

		template<class itemType, class paramType, class nameType>
		inline itemType& _Storage<itemType, paramType, nameType>::operator*(void)
		{
			return _item;
		}

		template<class itemType, class paramType, class nameType>
		inline itemType* _Storage<itemType, paramType, nameType>::operator->(void)
		{
			return (&_item);
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>::~_Storage()
		{
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>::operator int()
		{
			return _usage;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>::operator itemType&()
		{
			return _item;
		}

		template<class itemType, class paramType, class nameType>
		inline _Storage<itemType, paramType, nameType>::operator itemType*()
		{
			return &_item;
		}
	}
}

#endif //KLIBRARY_FACTORY_STORAGE_CODE_H