Each subsystem is meant to be encapsulated and abstracted to the point that it can be used in any system (Direct X or OpenGL, PhysX or Havok, etc) with little modification. To achieve this we need to store instances of each subsystem inside a manager for that particular subsystem.
std::map< SubSystem*, std::map< std::string, std::string > > subsystems;
This does the trick. We use the map to store a pointer to the instance, and map that pointer to a properties name/value map. This allows use to store and retrieve information about the particular instance, such as an id, name, size, etc.
To register a particular instance we can use this simple function:
void SysMgr::RegisterSubSystem( SubSystem* s )
{
s->Register(this);
this->subsystems["name"] = s->GetName();<br />}<br /></code><br />SubSystem::GetName() returns a std::string with the instance or subsystem name. We also pass along a pointer to the manager so the instance can set or remove propeties or callbacks. To accomplish that task we use:<br /><code><br />void SysMgr::SetProperty( SubSystem* s, std::string name, std::string value )<br />{<br /> this->subsystems[name] = value;<br />}<br />void SysMgr::RemoveProperty( SubSystem* s, std::string name )<br />{<br /> this->subsystems.erase(name);<br />}<br /></code><br />Simple and effective.<br /><br />I have attached the manager and subsystem code below. These are virtual classes and will need to be subclasses to your own needs. I will try and post an example subsystem later today or tomorrow to give a feel for how to use the system. Modifiers are not included as that aspect isn't passed the idea stage quite yet.<div>
</div>