24#ifndef  _SB_EVENTHANDLER_H_ 
   25#define  _SB_EVENTHANDLER_H_ 
   27#include <Inventor/SbDelegate.h> 
   99template <
typename ArgType>
 
  112    DelegateVector delegateCopy = m_delegates;
 
  113    typename DelegateVector::const_iterator it = delegateCopy.begin();
 
  114    typename DelegateVector::const_iterator end = delegateCopy.end();
 
 
  123  void add(
void (*f)(ArgType))
 
  125    inventor::helper::SbDelegate<void, ArgType> delegate = inventor::helper::SbDelegate<void, ArgType>(f);
 
  126    m_delegates.push_back(delegate); 
 
 
  130  template <
typename ClassType>
 
  131  void add(ClassType& a, 
void (ClassType::*f)(ArgType))
 
  133    inventor::helper::SbDelegate<void, ArgType> delegate = inventor::helper::SbDelegate<void, ArgType>(a, f);
 
  134    m_delegates.push_back(delegate); 
 
 
  144    for ( 
typename DelegateVector::iterator itDelegate = m_delegates.begin(); itDelegate != m_delegates.end(); itDelegate++ )
 
  146      if ( itDelegate->equal(f) )
 
  148        m_delegates.erase(itDelegate);
 
 
  160  template <
typename ClassType>
 
  161  bool remove(ClassType& a, 
void (ClassType::*f)(ArgType))
 
  163    for ( 
typename DelegateVector::iterator itDelegate = m_delegates.begin(); itDelegate != m_delegates.end(); itDelegate++ )
 
  165      if ( itDelegate->equal(a, f) )
 
  167        m_delegates.erase(itDelegate);
 
 
  176  typedef std::vector< inventor::helper::SbDelegate<void, ArgType> > DelegateVector;
 
  178  DelegateVector m_delegates;
 
 
Class representing an event.
bool remove(void(*f)(ArgType))
Remove a static function.
void add(ClassType &a, void(ClassType::*f)(ArgType))
Add a member function callback for this event.
void operator()(ArgType arg)
Call all registered callbacks.
void add(void(*f)(ArgType))
Add a static function callback for this event.
bool remove(ClassType &a, void(ClassType::*f)(ArgType))
Remove a member function.