I have a singleton that is the main engine container for my game.
I have several abstract classes that make the developer implement the different calls to what that specific object needs.
What I want to do is to make my singleton call those methods upon each given object, but avoiding unecessary calls.
Example so you can understand better:
Imagine one object that requires both Render() and Update() methods.
class IRender() : public IBase
{
virtual bool Render() = 0;
};
class IUpdate() : public IBase
{
virtual bool Update( long time_delta ) = 0;
};
class Sprite : public IRender, public IUpdate
{
bool Render(){ render stuff; }
bool Update( long time_delta(){ update stuff; }
};
Now I want to add that Sprite object to my singleton engine but I want the engine to call each loop to ONLY whatever that object inherited (there are other things beside Render and Update, like checking for input, etc):
_engine::getInstance()->Add( _sprite );
Thing is, for this to work I have to inherit all the interfaces from a base interface so I can call Add() with whatever objects were created, so the Add() method receives a base interface object.
Now the problem here is the base interface has to at least abstract all the methods that can be inherited like Render(), Update(), CheckInput(), Etc() and each loop my singleton has to call all the possibilities for every object, even if CheckInput() is empty for the sprite class.
Like so in my singleton:
bool loop(){
for every object saved in my container:
CheckInput(); Update(); Render(); etc(); }
Is my design wrong? Is there a way I can avoid this?
I hope you understand what I mean, my engine is in a pretty advanced state and I'm trying to avoid rewriting it all.
Thanks in advance.