Helper to use the context with singletons
If you use a class that has a specific function (update ...) as a public member via this helper, call that function by assigning that function to an arbitrary timing
- setup(only when calling setup)
- update(timing changeable)
- beforeUpdate(fixed timing)
- afterUpdate(fixed timing)
- beforeDraw(fixed timing)
- afterDraw(fixed timing)
class Data{
...
void setup(){
hogehoge...
}
void update(){
hogehoge...
}
void afterUpdate(){
hogehoge...
}
...
};
void ofApp::setup(){
...
context::setup<Data>(); //call Data::setup()
context::setup<Data>(ofEvents().draw, OF_EVENT_ORDER_AFTER_APP); //want to change the update timing
//If you do not need to call setup and you do not need to change the timing of update, you do not have to write this
...
}
class Scene_A{
Data& data{context::get<Data>()};
};