#include <string>
#include "Aria.h"
class CallbackContainer
{
public:
void callback1();
void callback2(int i);
bool callback3(const char *str);
};
void CallbackContainer::callback1()
{
printf("CallbackContainer::callback1 called.\n");
}
void CallbackContainer::callback2(int i)
{
printf("CallbackContainer::callback2 called with argument of '%d'\n", i);
}
bool CallbackContainer::callback3(const char *str)
{
printf("CallbackContainer::callback3 called with argument of '%s'.\n", str);
return(true);
}
void globalCallback()
{
printf("globalCallback() called.\n");
}
class DriverClass
{
public:
void invokeFunctors();
void setCallback1(
ArFunctor *func) {myFunc1=func;}
protected:
};
void DriverClass::invokeFunctors()
{
bool ret;
printf("Invoking functor1... ");
myFunc1->invoke();
printf("Invoking functor2... ");
myFunc2->invoke(23);
printf("Invoking functor3... ");
ret=myFunc3->invokeR("This is a string argument");
if (ret)
printf("\t-> functor3 returned 'true'\n");
else
printf("\t-> functor3 returned 'false'\n");
}
int main()
{
CallbackContainer cb;
DriverClass driver;
functor3(cb, &CallbackContainer::callback3);
driver.setCallback1(&functor1);
driver.setCallback2(&functor2);
driver.setCallback3(&functor3);
driver.invokeFunctors();
printf("Invoking globalFunctor... ");
printf("Invoking functor with constant argument... ");
printf("Invoking downcast functor... ");
return(0);
}