XRootD
Loading...
Searching...
No Matches
XrdClChannelHandlerList.cc
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 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
21
22namespace XrdCl
23{
24 //----------------------------------------------------------------------------
25 // Add a channel event handler
26 //----------------------------------------------------------------------------
28 {
29 XrdSysMutexHelper scopedLock( pMutex );
30 pHandlers.push_back( handler );
31 }
32
33 //----------------------------------------------------------------------------
34 // Remove the channel event handler
35 //----------------------------------------------------------------------------
37 {
38 XrdSysMutexHelper scopedLock( pMutex );
39 std::list<ChannelEventHandler*>::iterator it;
40 for( it = pHandlers.begin(); it != pHandlers.end(); ++it )
41 {
42 if( *it == handler )
43 {
44 pHandlers.erase( it );
45 return;
46 }
47 }
48 }
49
50 //----------------------------------------------------------------------------
51 // Report an event to the channel event handlers
52 //----------------------------------------------------------------------------
55 Status status )
56 {
57 XrdSysMutexHelper scopedLock( pMutex );
58 std::list<ChannelEventHandler*>::iterator it;
59 for( it = pHandlers.begin(); it != pHandlers.end(); )
60 {
61 bool st = (*it)->OnChannelEvent( event, status );
62 if( !st )
63 it = pHandlers.erase( it );
64 else
65 ++it;
66 }
67 }
68}
69
ChannelEvent
Events that may have occurred to the channel.
void RemoveHandler(ChannelEventHandler *handler)
Remove the channel event handler.
void AddHandler(ChannelEventHandler *handler)
Add a channel event handler.
void ReportEvent(ChannelEventHandler::ChannelEvent event, Status status)
Report an event to the channel event handlers.
Procedure execution status.