Collage
0.6.1
|
00001 00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef CO_CONNECTION_SET_H 00019 #define CO_CONNECTION_SET_H 00020 00021 #include <co/connectionListener.h> // base class 00022 #include <lunchbox/thread.h> // for LB_TS_VAR 00023 00024 namespace co 00025 { 00026 namespace detail { class ConnectionSet; } 00027 00029 class ConnectionSet : public ConnectionListener 00030 { 00031 public: 00032 enum Event 00033 { 00034 EVENT_NONE = 0, 00035 EVENT_CONNECT, 00036 EVENT_DISCONNECT, 00037 EVENT_DATA, 00038 EVENT_TIMEOUT, 00039 EVENT_INTERRUPT, 00040 EVENT_ERROR, 00041 EVENT_SELECT_ERROR, 00042 EVENT_INVALID_HANDLE, 00043 EVENT_ALL 00044 }; 00045 00046 CO_API ConnectionSet(); 00047 CO_API ~ConnectionSet(); 00048 00049 CO_API void addConnection( ConnectionPtr connection ); 00050 CO_API bool removeConnection( ConnectionPtr connection ); 00051 CO_API void clear(); 00052 CO_API size_t getSize() const; 00053 CO_API bool isEmpty() const; 00054 00055 CO_API const Connections& getConnections() const; 00056 00067 CO_API Event select( const uint32_t timeout = LB_TIMEOUT_INDEFINITE ); 00068 00072 CO_API void interrupt(); 00073 00075 void setDirty(); 00076 00077 CO_API int getError() const; 00078 CO_API ConnectionPtr getConnection(); 00079 00080 private: 00081 detail::ConnectionSet* const _impl; 00082 00083 bool _setupFDSet(); 00084 bool _buildFDSet(); 00085 virtual void notifyStateChanged( Connection* ); 00086 00087 Event _getSelectResult( const uint32_t index ); 00088 LB_TS_VAR( _selectThread ); 00089 }; 00090 00091 CO_API std::ostream& operator << ( std::ostream& os, 00092 const ConnectionSet* set ); 00093 CO_API std::ostream& operator << ( std::ostream& os, 00094 const ConnectionSet::Event event ); 00095 } 00096 00097 #endif // CO_CONNECTION_SET_H