[Insight-developers] itk::Command

Bill Hoffman bill.hoffman@kitware.com
Mon, 20 Nov 2000 12:00:48 -0500


I have  checked in the itk::Command class and associated Observer 
pattern code in itk::LightObject.   There are examples in 
itkBasicArchitectureTest.cxx.   This will replace the use of function 
pointer callbacks in itk.   You can still create "C" style function callbacks
if you want, but that will not be the default.


The basic idea, is that when one of following events occurs:

     DeleteEvent,     StartEvent,    EndEvent,    ProgressEvent,    PickEvent,
     StartPickEvent,    EndPickEvent,    AbortCheckEvent,    ExitEvent,
     AnyEvent,    UserEvent = 1000

     
A virtual Execute function will be called on the Command object sub-class 
registered to be notified when the event occurs.   Here is the function:
   
  virtual void Execute(LightObject *caller, unsigned long event) = 0;


There are several convenience classes that implement the above virtual, via
pointers to functions:
  
MemberCommand - call a pointer to a member function
SimpleMemberCommand - call a pointer to a member function with no arguments.
CStyleCommand - call a "C" function

See itk::Command for full details.

-Bill