Developer Documentation
RAVL, Recognition And Vision Library
USER HOME PAGE CLASS LIST CONTENTS
Ravl - Core - Calls


Calls and Triggers

These classes provide a flexible method for handling function and method pointers. They have many of the advantages of using Signals in that you don't have to know the exact form a function pointer, but without the complexity.

Using triggers

Triggers are the simplest form of call. They allow an function with arbitrary set of parameters to be called on an event. It is used in classes such as TimedTriggerQueueC to call a method after a fixed delay, and in TickerTriggerC which calls a method repeatedly at a fixed frequency.

Creating a trigger is simple:

#include "Ravl/Trigger.hh"

TriggerC myTrigger;
You can assign a function to it using the Trigger call.
bool PrintNumber(int &i) {
  cout << "PrintNumber called with value " << i << "\n";
  return true;
}

myTrigger = Trigger(&PrintNumber,2);
Calling the function can be done with the () operator.
myTrigger();

Using calls

Calls are wrappers for C++ function pointers which allow you to find the difference between calling a method of a class and a normal function, and to add default arguments to the call that the code calling the function need not know about.

Default arguments

When you setup a callback function, you can set default parameters. This especially useful if the method you wish to call requires more information than the callback normally provides. In the 3rd argument is set to 3, since its only called with 2 arguments, 30 is passed as its default value.
#include "Ravl/Calls.hh"

bool callback(int &v1,double &v2,int &x) {
  // Do something....
  return true;
}

int myprog() {

  // Declare callback variable.
  CallFunc2<int,double> func;  
  
  // Setup call back.
  func = Trigger(&callback,10,20,30);

  // Some paramiters...  
  int v1 = 0;
  double v2 = 1.2;
  
  // Call function.
  func(v1,v2);
  
}

Normal classes:

 TriggerC Signal Event handle

Normal functions:

 Trigger(RetT (*nfunc)() )
 Trigger(RetT (*nfunc)(DataT & dat) ,const DataT &)
 Trigger(RetT (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 Trigger(RetT (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 Trigger(RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 Trigger(RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)
 Trigger(bool (*nfunc)() )
 Trigger(bool (*nfunc)(DataT & dat) ,const DataT &)
 Trigger(bool (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 Trigger(bool (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 Trigger(bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 Trigger(bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)
 Trigger(const ObjT &,RetT (*nfunc)() )
 Trigger(const ObjT &,RetT (*nfunc)(DataT &) ,const DataT &)
 Trigger(const ObjT &,RetT (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 Trigger(const ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 Trigger(const ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 Trigger(const ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)
 Trigger(const ObjT &,bool (*nfunc)() )
 Trigger(const ObjT &,bool (*nfunc)(DataT &) ,const DataT &)
 Trigger(const ObjT &,bool (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 Trigger(const ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 Trigger(const ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 Trigger(const ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)
 TriggerR(ObjT &,RetT (*nfunc)() )
 TriggerR(ObjT &,RetT (*nfunc)(DataT &) ,const DataT &)
 TriggerR(ObjT &,RetT (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 TriggerR(ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 TriggerR(ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 TriggerR(ObjT &,RetT (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)
 TriggerR(ObjT &,bool (*nfunc)() )
 TriggerR(ObjT &,bool (*nfunc)(DataT &) ,const DataT &)
 TriggerR(ObjT &,bool (*nfunc)(Data1T &,Data2T &) ,const Data1T &,const Data2T &)
 TriggerR(ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &) ,const Data1T &,const Data2T &,const Data3T &)
 TriggerR(ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &)
 TriggerR(ObjT &,bool (*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &) ,const Data1T &,const Data2T &,const Data3T &,const Data4T &,const Data5T &)

Advanced classes:

 CallFunc0C Signal Event handle
 CallFunc1C Signal Event handle
 CallFunc2C Signal Event handle
 CallFunc3C Signal Event handle
 CallFunc4C Signal Event handle
 CallFunc5C Signal Event handle
 CallMethod0C Signal Event handle
 CallMethod1C Signal Event handle
 CallMethod2C Signal Event handle
 CallMethod3C Signal Event handle
 CallMethod4C Signal Event handle
 CallMethod5C Signal Event handle
 CallMethodRef0C Signal Event handle
 CallMethodRef1C Signal Event handle
 CallMethodRef2C Signal Event handle
 CallMethodRef3C Signal Event handle
 CallMethodRef4C Signal Event handle
 CallMethodRef5C Signal Event handle

Develop classes:

 TriggerBodyC Signal Event handle
 CallFunc0BodyC Signal Event handle
 CallFunc1BodyC Signal Event handle
 CallFunc2BodyC Signal Event handle
 CallFunc3BodyC Signal Event handle
 CallFunc4BodyC Signal Event handle
 CallFunc5BodyC Signal Event handle
 CallMethod0BodyC Signal Event handle
 CallMethod1BodyC Signal Event handle
 CallMethod2BodyC Signal Event handle
 CallMethod3BodyC Signal Event handle
 CallMethod4BodyC Signal Event handle
 CallMethod5BodyC Signal Event handle
 CallMethodRef0BodyC Signal Event handle
 CallMethodRef1BodyC Signal Event handle
 CallMethodRef2BodyC Signal Event handle
 CallMethodRef3BodyC Signal Event handle
 CallMethodRef4BodyC Signal Event handle
 CallMethodRef5BodyC Signal Event handle
Documentation by CxxDoc: Tue Aug 13 10:00:48 2002