00001 #include "AbstractMotionReceiver.h" 00002 #include <algorithm> 00003 #ifndef NO_GTKMM 00004 #include <gtkmm.h> 00005 #endif 00006 00007 AbstractMotionReceiver::AbstractMotionReceiver() : 00008 m_run(false) 00009 { 00010 } 00011 00012 AbstractMotionReceiver::~AbstractMotionReceiver() 00013 { 00014 #ifndef NO_GTKMM 00015 // Gtk::Main::quit(); 00016 #endif 00017 } 00018 00019 bool AbstractMotionReceiver::addObserver(IMotionObserver *obs) 00020 { 00021 observerList::iterator found = std::find(m_observers.begin(), m_observers.end(), obs); 00022 if (found == m_observers.end()) { 00023 m_observers.push_back(obs); 00024 return true; 00025 } 00026 return false; 00027 } 00028 00029 bool AbstractMotionReceiver::removeObserver(IMotionObserver *obs) 00030 { 00031 observerList::iterator found = std::find(m_observers.begin(), m_observers.end(), obs); 00032 if (found!= m_observers.end()) { 00033 m_observers.erase(found); 00034 return true; 00035 } 00036 return false; 00037 } 00038 00039 void AbstractMotionReceiver::notify(const Vector3d &v) 00040 { 00041 for (observerList::iterator it = m_observers.begin(); it != m_observers.end(); ++it) { 00042 (*it)->update(v); 00043 } 00044 }