Original Post
I'm working on a project, and I'm seriously questioning my design. This is going to be used by people other than myself, so I'd really like input on what most people seem to like. I want to somewhat abstract away any underlying APIs I use so that it isn't difficult for me to switch them, or if someone needs a custom implementation of a particular portion, they can write it themselves. I don't plan on using DLL/shared objects because I am keeping this cross platform, and it really isn't needed, a recompilation is fine. Strategy 1 was to have a variety of "Cores" which is similar to a system I used before. For example I'd have a VideoCore/AudioCore/InputCore/TimerCore/etc. The issue here is that some of these systems rely on the same APIs, for example, at the moment I am leaning towards GLFW, which can handle the window creation, timer, and input. If I were to switch to SDL, it too would handle all of those. I then considered the following Strategy 2: An Application class, which defines the interface for an application (window creation/input/timer would exist within the application class). A switch from SDL to GLFW would then be possible by writing two versions of the Application class. Applications using my system would define a class :
class MyGame : public Application
{
public:
int main(ArgList args);
}
and everything could work. This works nicely because the Application constructor/destructor can handle init/shutdown code. The issue here is that certain classes are going to depend upon some of the core subsystems. For example, the Timer class would obviously depend on the TimerCore. For this reason something resembling a singleton seems to be needed. Does anyone know of a pattern that is more suited to my problem than a singleton, I prefer to avoid them, and it just doesn't seem optimal.