I am currently looking to redesign my "engine" (which is mostly just a wrapper for several graphics APIs). I'm re-thinking the problem of how to have certain pieces of functionality that can be used anywhere in the code. Currently I pass around pointers to the manager classes, to access things like the Graphics API interface that makes draw calls, or the Resource Loader interface that allows for a thread-streamed read of a resource from the hard drive.
What are some other ways of doing this? So far I've thought of / read about the following methods:
- Singleton classes
- A class with all static member functions visible through a global instance.
- Globally visible member functions, C-style
- Passing around pointers to anyone interested.
Are there other ways to do this? Are there any benefits to one over another? Does anyone have any personal experience or insight into which way they think is the best? I generally shy away from globals, I don't particularly like singletons, and passing around the pointers is getting a bit cumbersome...