orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
eventqueue.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef HYDROICEUTIL_EVENT_QUEUE_H 00012 #define HYDROICEUTIL_EVENT_QUEUE_H 00013 00014 #include <list> 00015 #include <IceUtil/Monitor.h> 00016 #include <IceUtil/Mutex.h> 00017 #include <IceUtil/Handle.h> 00018 #include <IceUtil/Shared.h> 00019 #include <hydroiceutil/event.h> 00020 00021 namespace hydroiceutil 00022 { 00023 00024 class EventQueueOptimizer : public IceUtil::Shared 00025 { 00026 public: 00033 virtual bool combine( EventPtr& existing, const EventPtr& extra ) { return false; }; 00034 }; 00035 00037 typedef IceUtil::Handle<EventQueueOptimizer> EventQueueOptimizerPtr; 00038 00105 class EventQueue : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex> 00106 { 00107 public: 00109 EventQueue( bool traceAddEvents=false, bool traceGetEvents=false ); 00110 00112 void setOptimizer( EventQueueOptimizerPtr optimizer ); 00113 00115 void add( const EventPtr& e ); 00116 00118 void add( int type ); 00119 00127 void optimizedAdd( const EventPtr& e ); 00128 00131 void get( EventPtr& e ); 00132 00135 bool timedGet( EventPtr& e, int timeoutMs ); 00136 00138 void clear(); 00139 00141 int size() const; 00142 00143 private: 00144 std::list<EventPtr> events_; 00145 EventQueueOptimizerPtr optimizer_; 00146 bool traceAddEvents_; 00147 bool traceGetEvents_; 00148 }; 00150 typedef IceUtil::Handle<EventQueue> EventQueuePtr; 00151 00157 class EventQueueHolder : public IceUtil::Shared 00158 { 00159 public: 00160 virtual ~EventQueueHolder() {}; 00168 virtual void postEvent( const EventPtr& e )=0; 00169 00171 void postEvent( int type ) { postEvent( new hydroiceutil::Event(type) ); }; 00172 }; 00174 typedef IceUtil::Handle<EventQueueHolder> EventQueueHolderPtr; 00175 00176 } // namespace 00177 00178 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)