Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SelectServerInterface.h
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * SelectServerInterface.h
17  * An interface to a SelectServer that enforces clean separation.
18  * Copyright (C) 2010 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_IO_SELECTSERVERINTERFACE_H_
22 #define INCLUDE_OLA_IO_SELECTSERVERINTERFACE_H_
23 
24 #include <ola/Callback.h>
25 #include <ola/Clock.h>
26 #include <ola/io/Descriptor.h>
27 #include <ola/thread/SchedulingExecutorInterface.h>
28 
29 namespace ola {
30 namespace io {
31 
33  public :
35  virtual ~SelectServerInterface() {}
36 
37  virtual bool AddReadDescriptor(class ReadFileDescriptor *descriptor) = 0;
38  virtual bool AddReadDescriptor(class ConnectedDescriptor *socket,
39  bool delete_on_close = false) = 0;
40  virtual bool RemoveReadDescriptor(
41  class ReadFileDescriptor *descriptor) = 0;
42  virtual bool RemoveReadDescriptor(class ConnectedDescriptor *socket) = 0;
43 
44  virtual bool AddWriteDescriptor(
45  class WriteFileDescriptor *descriptor) = 0;
46  virtual bool RemoveWriteDescriptor(
47  class WriteFileDescriptor *descriptor) = 0;
48 
49  virtual ola::thread::timeout_id RegisterRepeatingTimeout(
50  unsigned int ms,
51  Callback0<bool> *closure) = 0;
52  virtual ola::thread::timeout_id RegisterRepeatingTimeout(
53  const ola::TimeInterval &interval,
54  ola::Callback0<bool> *closure) = 0;
55 
56  virtual ola::thread::timeout_id RegisterSingleTimeout(
57  unsigned int ms,
58  SingleUseCallback0<void> *closure) = 0;
59  virtual ola::thread::timeout_id RegisterSingleTimeout(
60  const ola::TimeInterval &interval,
61  SingleUseCallback0<void> *closure) = 0;
62 
63  virtual void RemoveTimeout(ola::thread::timeout_id id) = 0;
64 
65  virtual const TimeStamp *WakeUpTime() const = 0;
66 };
67 } // namespace io
68 } // namespace ola
69 #endif // INCLUDE_OLA_IO_SELECTSERVERINTERFACE_H_