Streamer::Streamer(const MyDb& realtimeDb) {
}
Streamer::~Streamer(void) {
}
void Streamer::callback_1(T_UPDATE pUpdate) {
// I need to do something with pUpdate and realtimeDb here, like this:
// Getting a cursor from db (works fine in main.cpp, but not in callback)
Dbc *cursorp;
realtimeDb.getDb().cursor(NULL, &cursorp, 0);
}
void Streamer::callback_2(Q_UPDATE pUpdate) {
// I need to do something with pUpdate and realtimeDb here, like this:
// Getting a cursor from db (works fine in main.cpp, but not in callback)
Dbc *cursorp;
realtimeDb.getDb().cursor(NULL, &cursorp, 0);
}
Streamer has two methods that are callbacks from an API. I can't change these parameters. I do, however, need to access the database instance MyDb that I am passing to the constructor (am I even doing that right?). This is how I am passing it, from main.cpp:
The callbacks are being called 300,000 times per second. I don't want to open a new database connection each time. I want to use the same database instance.
I think I need some kind of class property in Streamer that holds the instance, and allows it to be accessed from the callback methods.