I'm designing a method for an input handler class. Here is some pseudo code...
void InputHandler::ScanEvents( boost::function1< void, std::string& > &func ) {
// Scan keys, determining string to pass
// If string found, call func with string as its argument on object tied to func
}
I'm not exactly sure how to implement this, or if it is even possible, since the whole point of a function is to separate it from its caller. The idea is that an object has a private member function and a boost::function member that holds it. Whenever it calls ScanEvents on its InputHandler, it passes that function, so the ScanEvents can "activate it" whenever an appropriate event is found.
Efficiency is a concern, as this is in a domain where performance is important, and this function is called frequently.
P.S. I swear I remember reading an example like this in one of Scott Meyer's books, but I can't find it for the life of me. Maybe it was in Modern C++ Design...looking....