/*  $Id: resource_manager.cpp,v 1.21 2004/02/01 01:54:16 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library 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 2.1 of the License, or (at your option) any later version.
**
**  This library 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 along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/

#include "Core/precomp.h"
#include "API/Core/Resources/resource_manager.h"
#include "resource_manager_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_ResourceManager construction:

CL_ResourceManager::CL_ResourceManager(
	const std::string &config_file,
	CL_InputSourceProvider *provider,
	bool delete_inputsource_provider)
: impl(new CL_ResourceManager_Generic)
{
	impl->self = impl;
	impl->load(config_file, provider, delete_inputsource_provider);
}

CL_ResourceManager::CL_ResourceManager(const CL_ResourceManager &copy)
: impl(copy.impl)
{
}

CL_ResourceManager::CL_ResourceManager()
: impl(new CL_ResourceManager_Generic)
{
	impl->self = impl;
}

CL_ResourceManager::~CL_ResourceManager()
{
}

CL_ResourceManager::CL_ResourceManager(const CL_SharedPtr<CL_ResourceManager_Generic> &impl)
: impl(impl)
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_ResourceManager attributes:

bool CL_ResourceManager::exists(const std::string &res_id)
{
	return impl->exists(res_id);
}

CL_Resource &CL_ResourceManager::get_resource(const std::string &res_id)
{
	return impl->get_resource(res_id);
}

std::list<std::string> CL_ResourceManager::get_all_resources()
{
	return impl->get_all_resources();
}

std::list<std::string> CL_ResourceManager::get_all_resources(const std::string &section_name)
{
	return impl->get_all_resources(section_name);
}

std::list<std::string> CL_ResourceManager::get_all_sections()
{
	return impl->get_all_sections();
}

std::list<std::string> CL_ResourceManager::get_resources_of_type(const std::string &type_id)
{
	return impl->get_resources_of_type(type_id);
}

std::list<std::string> CL_ResourceManager::get_resources_of_type(const std::string &type_id, const std::string &section_name)
{
	return impl->get_resources_of_type(type_id, section_name);
}

CL_InputSourceProvider *CL_ResourceManager::get_resource_provider() const
{
	return impl->get_resource_provider();
}

/////////////////////////////////////////////////////////////////////////////
// CL_ResourceManager signals:

CL_Signal_v1<CL_Resource &> &CL_ResourceManager::sig_resource_added()
{
	return CL_ResourceManager_Generic::sig_resource_added;
}

/////////////////////////////////////////////////////////////////////////////
// CL_ResourceManager operations:

bool CL_ResourceManager::operator == (const CL_ResourceManager &other) const
{
	return impl == other.impl;
}

void CL_ResourceManager::add_resources(const CL_ResourceManager &additional_resources)
{
	impl->add_resources(additional_resources);
}

void CL_ResourceManager::remove_resources(const CL_ResourceManager &additional_resources)
{
	impl->remove_resources(additional_resources);
}

void CL_ResourceManager::load_all()
{
	impl->load_all();
}

void CL_ResourceManager::unload_all()
{
	impl->unload_all();
}

void CL_ResourceManager::load_section(const std::string &section_name)
{
	impl->load_section(section_name);
}

void CL_ResourceManager::unload_section(const std::string &section_name)
{
	impl->unload_section(section_name);
}
