Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

event.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #ifndef header_event
00030 #define header_event
00031 
00032 #include "mutex.h"
00033 #include "socket_event_handler.h"
00034 #include <vector>
00035 
00036 class CL_Event
00037 {
00039 public:
00040         enum EventType
00041         {
00042                 type_native,
00043                 type_socket_read,
00044                 type_socket_write,
00045                 type_socket_exception
00046         };
00047 
00048         CL_Event(bool manual_reset = false, bool initial_state = false);
00049         
00050         CL_Event(CL_SocketEventHandler *socket_handler, EventType type);
00051         
00052         ~CL_Event();
00053 
00055 public:
00056 
00058 public:
00059         bool wait(int timeout = -1) const;
00060         
00061         static int wait(int count, CL_Event const * const * events, int timeout = -1, bool wait_all = false);
00062 
00063         static int wait(const std::vector<CL_Event *> &events, int timeout = -1, bool wait_all = false);
00064         
00065         void set();
00066         
00067         void reset();
00068 
00070 private:
00071         CL_Event(const CL_Event &copy);
00072         
00073         CL_Event &operator =(const CL_Event &copy);
00074 
00075 #ifdef WIN32
00076         HANDLE handle;
00077 #else
00078         mutable CL_Mutex mutex;
00079         
00080         bool manual_reset;
00081         
00082         mutable bool state;
00083         
00084         int wait_sockets[2];
00085 #endif
00086         EventType type;
00087         
00088         CL_SocketEventHandler *socket_handler;
00089 };
00090 
00091 #endif

Generated on Sat Feb 19 22:51:16 2005 for npcore by  doxygen 1.4.1