00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 00019 #ifndef __XRD_CL_POST_CHANNEL_HH__ 00020 #define __XRD_CL_POST_CHANNEL_HH__ 00021 00022 #include <stdint.h> 00023 #include <vector> 00024 #include <ctime> 00025 00026 #include "XrdCl/XrdClStatus.hh" 00027 #include "XrdCl/XrdClURL.hh" 00028 #include "XrdCl/XrdClPoller.hh" 00029 #include "XrdCl/XrdClInQueue.hh" 00030 #include "XrdCl/XrdClPostMasterInterfaces.hh" 00031 #include "XrdCl/XrdClAnyObject.hh" 00032 #include "XrdCl/XrdClTaskManager.hh" 00033 00034 #include "XrdSys/XrdSysPthread.hh" 00035 00036 namespace XrdCl 00037 { 00038 class Stream; 00039 class JobManager; 00040 class VirtualRedirector; 00041 class TickGeneratorTask; 00042 00043 //---------------------------------------------------------------------------- 00045 //---------------------------------------------------------------------------- 00046 class Channel 00047 { 00048 public: 00049 //------------------------------------------------------------------------ 00057 //------------------------------------------------------------------------ 00058 Channel( const URL &url, 00059 Poller *poller, 00060 TransportHandler *transport, 00061 TaskManager *taskManager, 00062 JobManager *jobManager ); 00063 00064 //------------------------------------------------------------------------ 00066 //------------------------------------------------------------------------ 00067 ~Channel(); 00068 00069 //------------------------------------------------------------------------ 00071 //------------------------------------------------------------------------ 00072 const URL &GetURL() const 00073 { 00074 return pUrl; 00075 } 00076 00077 //------------------------------------------------------------------------ 00087 //------------------------------------------------------------------------ 00088 Status Send( Message *msg, bool stateful, time_t expires ); 00089 00090 //------------------------------------------------------------------------ 00103 //------------------------------------------------------------------------ 00104 Status Send( Message *msg, 00105 OutgoingMsgHandler *handler, 00106 bool stateful, 00107 time_t expires ); 00108 00109 //------------------------------------------------------------------------ 00119 //------------------------------------------------------------------------ 00120 Status Receive( Message *&msg, MessageFilter *filter, time_t expires ); 00121 00122 //------------------------------------------------------------------------ 00129 //------------------------------------------------------------------------ 00130 Status Receive( IncomingMsgHandler *handler, time_t expires ); 00131 00132 //------------------------------------------------------------------------ 00139 //------------------------------------------------------------------------ 00140 Status QueryTransport( uint16_t query, AnyObject &result ); 00141 00142 //------------------------------------------------------------------------ 00144 //------------------------------------------------------------------------ 00145 void RegisterEventHandler( ChannelEventHandler *handler ); 00146 00147 //------------------------------------------------------------------------ 00149 //------------------------------------------------------------------------ 00150 void RemoveEventHandler( ChannelEventHandler *handler ); 00151 00152 //------------------------------------------------------------------------ 00154 //------------------------------------------------------------------------ 00155 void Tick( time_t now ); 00156 00157 //------------------------------------------------------------------------ 00159 //------------------------------------------------------------------------ 00160 Status ForceDisconnect(); 00161 00162 private: 00163 00164 URL pUrl; 00165 Poller *pPoller; 00166 TransportHandler *pTransport; 00167 TaskManager *pTaskManager; 00168 std::vector<Stream *> pStreams; 00169 XrdSysMutex pMutex; 00170 AnyObject pChannelData; 00171 InQueue pIncoming; 00172 TickGeneratorTask *pTickGenerator; 00173 JobManager *pJobManager; 00174 }; 00175 } 00176 00177 #endif // __XRD_CL_POST_CHANNEL_HH__