Scrapped the ResMgr class, refactored the MgrBase class and here is the final managers that come as a result of the changes.
Code:
typedef x3d_core::MgrBase< std::string, Object > MgrType;
typedef x3d_core::MgrBase< std::string, MgrType > GameObjMgrType;
GameObjMgrType m_GameObjMgr;
typedef x3d_core::MgrBase< std::string, Resource > ResType;
typedef x3d_core::MgrBase< std::string, ResType > ResMgrType;
ResMgrType m_ResMgr;
Now I have a resource manager and a game object manager that both take advantage of the template class.
Here is an example of how simple this makes managing objects.
Code:
#pragma once
#include "MgrBase.h"
#include "GameObject.h"
#include <string>
class GameSectorMgr:public x3d_core::MgrBase<std::string,GameObject *>
{
public:
GameSectorMgr(void);
virtual ~GameSectorMgr(void);
virtual void Update(float timeDelta);
};
Code:
#include "GameSectorMgr.h"
GameSectorMgr::GameSectorMgr(void)
{
}
GameSectorMgr::~GameSectorMgr(void)
{
}
void GameSectorMgr::Update(float timeDelta)
{
std::map<std::string,GameObject *>::iterator iter(m_Objects.begin());
std::map<std::string,GameObject *>::iterator end(m_Objects.end());
while (iter != end)
{
iter->second->Update(timeDelta);
++iter;
}
}