I'd like to obtain the pointer to the object and an indication of which method the functor will call from a functor constructed using boost::function and boost::bind. This will allow me to automatically determine the order in a which bunch of functors must be executed.
The following (pseudo) code (see POINTER_OF & METHOD_OF) shows what I'm trying to do:
class myClassA
{
public:
DoIt(int i) { return i+i; }
};
class myClassB
{
public:
DoItToo(double d) { return d*d; }
};
typedef boost::function0<int> Functor;
myClassA classA;
myClassB classB;
Functor funcA = boost::bind( &myClassA::DoIt, &classA, 10 );
Functor funcB = boost::bind( &myClassB::DoItToo, &classB, 12.34 );
// Create a vector containing some functors and try to determine the objects
// they are called upon and the methods they invoke
std::vector<Functor> vec;
vec.push_back( funcA );
vec.push_back( funcB );
for (int i = 0; i < vec.size();i++)
{
if (POINTER_OF(vec[i]) == &classA)
{
// This functor acts on classA
if (METHOD_OF(vec[i]) == &myClassA::DoIt)
{
// This functor calls the 'DoIt' method.
}
else if (METHOD_OF(vec[i]) == &myClassB::DoItToo)
{
// This functor calls the 'DoItToo' method.
}
}
// etc...
}
Thanks in advance!