|
-
July 21st, 2016, 08:28 AM
#1
Gobally available Service with scoped Lifetime
Hey
I am currently working on a game and ran into a very usual problem in game development.
What I am trying to do, is providing global and scoped access to Services/Subsystems (e.g. Graphics renderer) that are not static.
Basicly 'Provider' is a template for actual providers (e.g. GraphicsProvider), whose hold pointers to services, that then can be accesst through 'Get<T>()' from all over the code.
Get will return nullptr if there is no provider holding the service, or if there is no service registered to the provider.
Please have a look into main.cpp to get an idea of how it is used.
full code:
main.cpp
provider.h
traits.h
Do you have advide or a better solution?
What do you think about this approach?
Thanks lots
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|