1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/lib/spells/effects/Registry.cpp
Andrey Filipenkov ff635edc0b wrap all library code into namespace if VCMI_LIB_NAMESPACE is defined
preparation for having client and server in a single process
2022-09-24 15:55:21 +03:00

63 lines
1.0 KiB
C++

/*
* Registry.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "Registry.h"
VCMI_LIB_NAMESPACE_BEGIN
namespace spells
{
namespace effects
{
namespace detail
{
class RegistryImpl : public Registry
{
public:
RegistryImpl() = default;
~RegistryImpl() = default;
const IEffectFactory * find(const std::string & name) const override
{
auto iter = data.find(name);
if(iter == data.end())
return nullptr;
else
return iter->second.get();
}
void add(const std::string & name, FactoryPtr item) override
{
data[name] = item;
}
private:
std::map<std::string, FactoryPtr> data;
};
}
Registry::Registry() = default;
Registry::~Registry() = default;
Registry * GlobalRegistry::get()
{
static std::unique_ptr<Registry> Instance = make_unique<detail::RegistryImpl>();
return Instance.get();
}
}
}
VCMI_LIB_NAMESPACE_END