xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCl
XrdClPoller.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3
// Author: Lukasz Janyst <ljanyst@cern.ch>
4
//------------------------------------------------------------------------------
5
// XRootD is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// XRootD is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17
//------------------------------------------------------------------------------
18
19
#ifndef __XRD_CL_POLLER_HH__
20
#define __XRD_CL_POLLER_HH__
21
22
#include <stdint.h>
23
#include <string>
24
25
namespace
XrdCl
26
{
27
class
Socket;
28
class
Poller;
29
30
//----------------------------------------------------------------------------
32
//----------------------------------------------------------------------------
33
class
SocketHandler
34
{
35
public
:
36
//------------------------------------------------------------------------
38
//------------------------------------------------------------------------
39
enum
EventType
40
{
41
ReadyToRead
= 0x01,
42
ReadTimeOut
= 0x02,
43
ReadyToWrite
= 0x04,
44
WriteTimeOut
= 0x08
45
};
46
47
//------------------------------------------------------------------------
48
// Destructor
49
//------------------------------------------------------------------------
50
virtual
~SocketHandler
() {}
51
52
//------------------------------------------------------------------------
54
//------------------------------------------------------------------------
55
virtual
void
Initialize
(
Poller
* ) {}
56
57
//------------------------------------------------------------------------
59
//------------------------------------------------------------------------
60
virtual
void
Finalize
() {};
61
62
//------------------------------------------------------------------------
64
//------------------------------------------------------------------------
65
virtual
void
Event
( uint8_t type,
66
Socket
*socket ) = 0;
67
68
//------------------------------------------------------------------------
70
//------------------------------------------------------------------------
71
static
std::string
EventTypeToString
( uint8_t event )
72
{
73
std::string ev;
74
if
( event &
ReadyToRead
) ev +=
"ReadyToRead|"
;
75
if
( event &
ReadTimeOut
) ev +=
"ReadTimeOut|"
;
76
if
( event &
ReadyToWrite
) ev +=
"ReadyToWrite|"
;
77
if
( event &
WriteTimeOut
) ev +=
"WriteTimeOut|"
;
78
ev.erase( ev.length()-1, 1) ;
79
return
ev;
80
}
81
};
82
83
//----------------------------------------------------------------------------
85
//----------------------------------------------------------------------------
86
class
Poller
87
{
88
public
:
89
//------------------------------------------------------------------------
91
//------------------------------------------------------------------------
92
virtual
~Poller
() {}
93
94
//------------------------------------------------------------------------
96
//------------------------------------------------------------------------
97
virtual
bool
Initialize
() = 0;
98
99
//------------------------------------------------------------------------
101
//------------------------------------------------------------------------
102
virtual
bool
Finalize
() = 0;
103
104
//------------------------------------------------------------------------
106
//------------------------------------------------------------------------
107
virtual
bool
Start
() = 0;
108
109
//------------------------------------------------------------------------
111
//------------------------------------------------------------------------
112
virtual
bool
Stop
() = 0;
113
114
//------------------------------------------------------------------------
119
//------------------------------------------------------------------------
120
virtual
bool
AddSocket
(
Socket
*socket,
121
SocketHandler
*handler ) = 0;
122
123
//------------------------------------------------------------------------
125
//------------------------------------------------------------------------
126
virtual
bool
RemoveSocket
(
Socket
*socket ) = 0;
127
128
//------------------------------------------------------------------------
135
//------------------------------------------------------------------------
136
virtual
bool
EnableReadNotification
(
Socket
*socket,
137
bool
notify,
138
uint16_t timeout = 60 ) = 0;
139
140
//------------------------------------------------------------------------
146
//------------------------------------------------------------------------
147
virtual
bool
EnableWriteNotification
(
Socket
*socket,
148
bool
notify,
149
uint16_t timeout = 60 ) = 0;
150
151
//------------------------------------------------------------------------
153
//------------------------------------------------------------------------
154
virtual
bool
IsRegistered
(
Socket
*socket ) = 0;
155
156
//------------------------------------------------------------------------
158
//------------------------------------------------------------------------
159
virtual
bool
IsRunning
()
const
= 0;
160
};
161
}
162
163
#endif // __XRD_CL_POLLER_HH__
Generated by
1.8.3.1