// Invocation of pointers which supply the parameter type. Full invocation
// with paramters is posesible in this fashion with out knowing the class
// that the functor refers to.
void testGlobalReturnParams()
{
  ArGlobalRetFunctor<bool> functor(retFunction);
  ArGlobalRetFunctor1<char*, int> functor1(retFunction, 1);
  ArGlobalRetFunctor2<double, bool, std::string>
    functor2(retFunction, false, "default arg");
  ArRetFunctor<bool> *fBoolPtr;
  ArRetFunctor1<char*, int> *fCharPtr;
  ArRetFunctor2<double, bool, std::string> *fDoublePtr;
  bool bret;
  char *cret;
  double dret;

  printf("\n****** Testing global pointer invocation with return\n");
  fBoolPtr=&functor;
  puts("> bool retFunction() should return true...");
  bret=fBoolPtr->invokeR();
  printf("Returned: %d\n", bret);
  fCharPtr=&functor1;
  puts("> char* retFunction(7) should return \"Hello\"...");
  cret=fCharPtr->invokeR(7);
  printf("Returned: %s\n", cret);
  fDoublePtr=&functor2;
  puts("> double retFunction(false, \"argument 3\") should return 4.62...");
  dret=fDoublePtr->invokeR(false, "argument 3");
  printf("Returned: %e\n", dret);
}
void testReturnParams()
{
  TestClass test;
  ArRetFunctorC<bool, TestClass> functor(test, &TestClass::retFunction);
  ArRetFunctor1C<char*, TestClass, int>
    functor1(test, &TestClass::retFunction, 1);
  ArRetFunctor2C<double, TestClass, bool, std::string>
    functor2(test, &TestClass::retFunction, false, "default arg");
  ArRetFunctor<bool> *fBoolPtr;
  ArRetFunctor1<char*, int> *fCharPtr;
  ArRetFunctor2<double, bool, std::string> *fDoublePtr;
  bool bret;
  char *cret;
  double dret;

  printf("\n****** Testing pointer invocation with return\n");
  fBoolPtr=&functor;
  puts("> TestClass::retFunction() should return true");
  bret=fBoolPtr->invokeR();
  printf("Returned: %d\n", bret);
  fCharPtr=&functor1;
  puts("> TestClass::retFunction(7) should return \"Hello\"");
  cret=fCharPtr->invokeR(7);
  printf("Returned: %s\n", cret);
  fDoublePtr=&functor2;
  puts("> TestClass::retFunction(false, \"argument 3\") should return 4.62...");
  dret=fDoublePtr->invokeR(false, "argument 3");
  printf("Returned: %e\n", dret);
}
void DriverClass::invokeFunctors()
{
  bool ret;

  printf("Invoking functor1... ");
  myFunc1->invoke();

  printf("Invoking functor2... ");
  myFunc2->invoke(23);
	 

  /*
     For functors with return values, use invorkeR() instead of invoke()
     to get the return value.  The invoke() function can also be used to invoke
     the functor, but the return value is lost.  (And is a possible source
     of memory leaks if you were supposed to free a pointer returned.)
  */
  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");
}