Jump to content
  • Advertisement
  • entries
  • comment
  • views

Subsystems and their management.

Sign in to follow this  


I am developing a component based system using the concept of subsystems for my current game. The system is the game (which controls level loading, timiing, etc) and the subsystems as things such as physics, audio, scripting, rendering, etc. Now each subsystem has its own data that it uses to perform its tasks. These subsystems however don't modify their data, but instead the use modifiers to change it. For example a render subsystem instance may contain a texture pointer, the RECT from the texture to use, and the destination RECT. Now we add a modifier for animation for example. This modifier can change the texture pointer or either source or destination RECTs.

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 )
this->subsystems[s]["name"] = s->GetName();

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:

void SysMgr::SetProperty( SubSystem* s, std::string name, std::string value )
this->subsystems[s][name] = value;
void SysMgr::RemoveProperty( SubSystem* s, std::string name )

Simple and effective.

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.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!