0ad/source/graphics/ObjectManager.h
Ykkrosh ec69bccb2c # Tidied up some code.
- Made some classes not be singletons, since there's no reason why they
should be.
 - Made them non-global too (because globals have unclear lifetimes, and
make it harder to test things, etc). They're now owned by CGameView and
CWorld, and mostly accessed via g_Game or arguments (vaguely trying to
avoid the graphics code calling into the game code).
 - Moved CGameView implementation into pimpl, so the header file isn't
so heavy.
 - Changed a few pointers into references, to indicate that they're
never NULL.

This was SVN commit r4756.
2007-01-08 01:56:46 +00:00

65 lines
1.6 KiB
C++

#ifndef _OBJECTMANAGER_H
#define _OBJECTMANAGER_H
#include <vector>
#include <map>
#include "ps/CStr.h"
#include "ObjectBase.h"
class CObjectEntry;
class CEntityTemplate;
class CMatrix3D;
class CMeshManager;
///////////////////////////////////////////////////////////////////////////////////////////
// CObjectManager: manager class for all possible actor types
class CObjectManager
{
public:
struct ObjectKey
{
ObjectKey(const CStr& name, const std::vector<u8>& var)
: ActorName(name), ActorVariation(var) {}
CStr ActorName;
std::vector<u8> ActorVariation;
};
public:
// constructor, destructor
CObjectManager(CMeshManager& meshManager);
~CObjectManager();
CMeshManager& GetMeshManager() const { return m_MeshManager; }
void UnloadObjects();
CObjectEntry* FindObject(const char* objname);
void DeleteObject(CObjectEntry* entry);
CObjectBase* FindObjectBase(const char* objname);
CObjectEntry* FindObjectVariation(const char* objname, const std::vector<std::set<CStr> >& selections);
CObjectEntry* FindObjectVariation(CObjectBase* base, const std::vector<std::set<CStr> >& selections);
// Get all names, quite slowly. (Intended only for Atlas.)
static void GetAllObjectNames(std::vector<CStr>& names);
static void GetPropObjectNames(std::vector<CStr>& names);
private:
CMeshManager& m_MeshManager;
std::map<ObjectKey, CObjectEntry*> m_Objects;
std::map<CStr, CObjectBase*> m_ObjectBases;
NO_COPY_CTOR(CObjectManager);
};
// Global comparison operator
bool operator< (const CObjectManager::ObjectKey& a, const CObjectManager::ObjectKey& b);
#endif