//	ToneFactory.h - Singleton class used to construct new Tones.
//  ----------------------------------------------------------------------------
//	This file is part of 'GameTemplate', template code for a game.
//	Copyright (C) 2011  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program 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 General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#ifndef TONEFACTORY_H_
#define TONEFACTORY_H_

#include "ToneCreator.h"
#include "c0xHeaders.h"
#include "Tone.h"

#include <map>
#include <string>
#include <vector>

class TonesSounder;

///	Singleton class used to construct new Tones.
class ToneFactory
{
  public:
	///	Returns the sole instance of ToneFactory.
	static ToneFactory& getInstance();

	///	Returns all the ToneCreators which may be used in normal play (i.e. fast, med, slow).
	const std::vector<shared_ptr<ToneCreator> >& getNormalToneCreators() const {return normalVector;};
	///	Returns any 'special' ToneCreators (reverse, dropper).
	const std::vector<shared_ptr<ToneCreator> >& getSpecialToneCreators() const {return specialVector;};
	///	Returns an instance of the named Tone type.
	TonePtr getTone(const std::wstring& name,
					int startRail,
					int startNumRails,
					shared_ptr<TonesSounder>& sounder);

	///	Registers a normal ToneCreator with the factory.
	void registerNormalToneCreator(const std::wstring& name,
								   shared_ptr<ToneCreator> creator);
	///	Registers a special ToneCreator with the factory.
	void registerSpecialToneCreator(const std::wstring& name,
									shared_ptr<ToneCreator> creator);
  private:
	///	Constructor.
	ToneFactory();
	///	Destructor.
	~ToneFactory();

	///	The main map of all our ToneCreators.
	std::map<std::wstring, shared_ptr<ToneCreator> > creators;
	///	A vector of all the normal ToneCreators for convenience.
	std::vector<shared_ptr<ToneCreator> > normalVector;
	///	A vector of all the special ToneCreators for convenience.
	std::vector<shared_ptr<ToneCreator> > specialVector;
};

#endif
