Making a Resource Handle Accessible in the Controller

18 Views Asked by At

I have a resource (like a DB connection) which I need to instantiate when Oat++ initially loads. I do this in App.cpp in the main function. The resource can provide me with one or more handles which I generate in main. I would like to have one of these handles available globally in MyController as it is needed for several endpoints.

My problem is that I don't know how to pass the handle(s). The function run() in main passes no variables and even if I modified it, I'm not sure what I'd do next.

/* Create MyController and add all of its endpoints to router */ router->addController(std::make_shared());

Perhaps when I add the controller?

This is more of a C++ framework question as opposed to Oat++ (which is running nicely save this needed improvement)

I've looked around for similar situations like opening a DB at startup and generating multiple connectors, but I haven't found anything.

0

There are 0 best solutions below