Open Lighting Architecture  Latest Git
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 
43  public :
45  virtual ~SelectServerInterface() {}
46 
55  virtual bool AddReadDescriptor(class ReadFileDescriptor *descriptor) = 0;
56 
69  virtual bool AddReadDescriptor(class ConnectedDescriptor *descriptor,
70  bool delete_on_close = false) = 0;
71 
79  virtual void RemoveReadDescriptor(
80  class ReadFileDescriptor *descriptor) = 0;
81 
89  virtual void RemoveReadDescriptor(class ConnectedDescriptor *descriptor) = 0;
90 
97  virtual bool AddWriteDescriptor(
98  class WriteFileDescriptor *descriptor) = 0;
99 
107  virtual void RemoveWriteDescriptor(
108  class WriteFileDescriptor *descriptor) = 0;
109 
111  unsigned int ms,
112  Callback0<bool> *closure) = 0;
114  const ola::TimeInterval &interval,
115  ola::Callback0<bool> *closure) = 0;
116 
118  unsigned int ms,
119  SingleUseCallback0<void> *closure) = 0;
121  const ola::TimeInterval &interval,
122  SingleUseCallback0<void> *closure) = 0;
123 
124  virtual void RemoveTimeout(ola::thread::timeout_id id) = 0;
125 
133  virtual const TimeStamp *WakeUpTime() const = 0;
134 };
135 } // namespace io
136 } // namespace ola
137 #endif // INCLUDE_OLA_IO_SELECTSERVERINTERFACE_H_
A time interval, with usecond accuracy.
Definition: Clock.h:138
A 0 arg, single use callback that returns void.
Definition: Callback.h:157
virtual void RemoveReadDescriptor(class ReadFileDescriptor *descriptor)=0
Remove a ReadFileDescriptor for read-events.
Combines the ExecutorInterface and the SchedulerInterface.
Definition: SchedulingExecutorInterface.h:33
virtual ola::thread::timeout_id RegisterRepeatingTimeout(unsigned int ms, Callback0< bool > *closure)=0
Execute a callback periodically.
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition: Descriptor.h:282
A 0 argument callback which can be called multiple times.
Definition: Callback.h:129
virtual bool AddWriteDescriptor(class WriteFileDescriptor *descriptor)=0
Register a WriteFileDescriptor for write-events.
virtual void RemoveTimeout(ola::thread::timeout_id id)=0
Cancel an existing timeout.
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition: SchedulerInterface.h:34
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
virtual void RemoveWriteDescriptor(class WriteFileDescriptor *descriptor)=0
Remove a WriteFileDescriptor for write-events.
virtual ola::thread::timeout_id RegisterSingleTimeout(unsigned int ms, SingleUseCallback0< void > *closure)=0
Execute a callback after a certain time interval.
Represents a file descriptor that supports reading data.
Definition: Descriptor.h:140
virtual const TimeStamp * WakeUpTime() const =0
The time when this SelectServer was woken up.
virtual bool AddReadDescriptor(class ReadFileDescriptor *descriptor)=0
Register a ReadFileDescriptor for read-events.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Represents a point in time with microsecond accuracy.
Definition: Clock.h:191
Represents a file descriptor that supports writing data.
Definition: Descriptor.h:170