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 #include <functional> 00026 00027 #include "XrdCl/XrdClStatus.hh" 00028 #include "XrdCl/XrdClURL.hh" 00029 #include "XrdCl/XrdClPoller.hh" 00030 #include "XrdCl/XrdClInQueue.hh" 00031 #include "XrdCl/XrdClPostMasterInterfaces.hh" 00032 #include "XrdCl/XrdClAnyObject.hh" 00033 #include "XrdCl/XrdClTaskManager.hh" 00034 00035 #include "XrdSys/XrdSysPthread.hh" 00036 00037 namespace XrdCl 00038 { 00039 class Stream; 00040 class JobManager; 00041 class VirtualRedirector; 00042 class TickGeneratorTask; 00043 class Job; 00044 00045 //---------------------------------------------------------------------------- 00047 //---------------------------------------------------------------------------- 00048 class Channel 00049 { 00050 public: 00051 //------------------------------------------------------------------------ 00059 //------------------------------------------------------------------------ 00060 Channel( const URL &url, 00061 Poller *poller, 00062 TransportHandler *transport, 00063 TaskManager *taskManager, 00064 JobManager *jobManager ); 00065 00066 //------------------------------------------------------------------------ 00068 //------------------------------------------------------------------------ 00069 ~Channel(); 00070 00071 //------------------------------------------------------------------------ 00073 //------------------------------------------------------------------------ 00074 const URL &GetURL() const 00075 { 00076 return pUrl; 00077 } 00078 00079 //------------------------------------------------------------------------ 00089 //------------------------------------------------------------------------ 00090 Status Send( Message *msg, bool stateful, time_t expires ); 00091 00092 //------------------------------------------------------------------------ 00105 //------------------------------------------------------------------------ 00106 Status Send( Message *msg, 00107 OutgoingMsgHandler *handler, 00108 bool stateful, 00109 time_t expires ); 00110 00111 //------------------------------------------------------------------------ 00121 //------------------------------------------------------------------------ 00122 Status Receive( Message *&msg, MessageFilter *filter, time_t expires ); 00123 00124 //------------------------------------------------------------------------ 00131 //------------------------------------------------------------------------ 00132 Status Receive( IncomingMsgHandler *handler, time_t expires ); 00133 00134 //------------------------------------------------------------------------ 00141 //------------------------------------------------------------------------ 00142 Status QueryTransport( uint16_t query, AnyObject &result ); 00143 00144 //------------------------------------------------------------------------ 00146 //------------------------------------------------------------------------ 00147 void RegisterEventHandler( ChannelEventHandler *handler ); 00148 00149 //------------------------------------------------------------------------ 00151 //------------------------------------------------------------------------ 00152 void RemoveEventHandler( ChannelEventHandler *handler ); 00153 00154 //------------------------------------------------------------------------ 00156 //------------------------------------------------------------------------ 00157 void Tick( time_t now ); 00158 00159 //------------------------------------------------------------------------ 00161 //------------------------------------------------------------------------ 00162 Status ForceDisconnect(); 00163 00164 //------------------------------------------------------------------------ 00166 //------------------------------------------------------------------------ 00167 uint16_t NbConnectedStrm(); 00168 00169 //------------------------------------------------------------------------ 00171 //------------------------------------------------------------------------ 00172 void SetOnConnectHandler( Job *onConnJob ); 00173 00174 private: 00175 00176 URL pUrl; 00177 Poller *pPoller; 00178 TransportHandler *pTransport; 00179 TaskManager *pTaskManager; 00180 std::vector<Stream *> pStreams; 00181 XrdSysMutex pMutex; 00182 AnyObject pChannelData; 00183 InQueue pIncoming; 00184 TickGeneratorTask *pTickGenerator; 00185 JobManager *pJobManager; 00186 }; 00187 } 00188 00189 #endif // __XRD_CL_POST_CHANNEL_HH__