// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include namespace Nz { /*! * \class Nz::ObjectRef * \brief Core class that represents a reference to an object */ /*! * \brief Gets the ObjectRef object by name * \return Optional reference * * \param name Name of the object * * \remark Produces a NazaraError if object not found */ template ObjectRef ObjectLibrary::Get(const String& name) { ObjectRef ref = Query(name); if (!ref) NazaraError("Object \"" + name + "\" is not present"); return ref; } /*! * \brief Checks whether the library has the object with that name * \return true if it the case */ template bool ObjectLibrary::Has(const String& name) { return Type::s_library.find(name) != Type::s_library.end(); } /*! * \brief Registers the ObjectRef object with that name * * \param name Name of the object * \param object Object to stock */ template void ObjectLibrary::Register(const String& name, ObjectRef object) { Type::s_library.emplace(name, object); } /*! * \brief Gets the ObjectRef object by name * \return Optional reference * * \param name Name of the object */ template ObjectRef ObjectLibrary::Query(const String& name) { auto it = Type::s_library.find(name); if (it != Type::s_library.end()) return it->second; else return nullptr; } /*! * \brief Unregisters the ObjectRef object with that name * * \param name Name of the object */ template void ObjectLibrary::Unregister(const String& name) { Type::s_library.erase(name); } template bool ObjectLibrary::Initialize() { return true; // Que faire } template void ObjectLibrary::Uninitialize() { Type::s_library.clear(); } } #include