|
|
|||
File indexing completed on 2026-01-08 10:33:34
0001 #ifndef __XRDSSISTREAM_HH__ 0002 #define __XRDSSISTREAM_HH__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S s i S t r e a m . h h */ 0006 /* */ 0007 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 #include <cerrno> 0033 0034 #include "XrdSsi/XrdSsiErrInfo.hh" 0035 0036 //----------------------------------------------------------------------------- 0037 //! The XrdSsiStream class describes an object capable of providing data for a 0038 //! response in real time. A pointer to such an object may be used to set this 0039 //! response mode via XrdSsiResponder::SetResponse(). Two kinds of streams exist: 0040 //! 0041 //! Active the stream supplies the buffer that contains the response data. 0042 //! The buffer is recycled via Buffer::Recycle() once the response data 0043 //! is sent. Active streams are supported only server-side. 0044 //! Passive the stream requires a buffer to be passed to it where response data 0045 //! will be placed. Only passive streams are created on the client-side. 0046 //! Passive streams can also work in asynchronous mode. However, async 0047 //! mode is never used server-side but may be requested client-side. 0048 //! 0049 //! The type of stream must be declared at the time the stream is created. You 0050 //! must supply an implementation for the associated stream type. 0051 //----------------------------------------------------------------------------- 0052 0053 class XrdSsiStream 0054 { 0055 public: 0056 0057 //----------------------------------------------------------------------------- 0058 //! The Buffer object is returned by active streams as they supply the buffer 0059 //! holding the requested data. Once the buffer is no longer needed it must be 0060 //! recycled by calling Recycle(). 0061 //----------------------------------------------------------------------------- 0062 0063 class Buffer 0064 { 0065 public: 0066 virtual void Recycle() = 0; //!> Call to recycle the buffer when finished 0067 0068 char *data; //!> -> Buffer containing the data 0069 Buffer *next; //!> For chaining by buffer receiver 0070 0071 Buffer(char *dp=0) : data(dp), next(0) {} 0072 virtual ~Buffer() {} 0073 }; 0074 0075 //----------------------------------------------------------------------------- 0076 //! Synchronously obtain data from an active stream (server-side only). 0077 //! 0078 //! @param eRef The object to receive any error description. 0079 //! @param dlen input: the optimal amount of data wanted (this is a hint) 0080 //! output: the actual amount of data returned in the buffer. 0081 //! @param last input: should be set to false. 0082 //! output: if true it indicates that no more data remains to be 0083 //! returned either for this call or on the next call. 0084 //! 0085 //! @return =0 No more data remains or an error occurred: 0086 //! last = true: No more data remains. 0087 //! last = false: A fatal error occurred, eRef has the reason. 0088 //! @return !0 Pointer to the Buffer object that contains a pointer to the 0089 //! the data (see below). The buffer must be returned to the 0090 //! stream using Buffer::Recycle(). The next member is usable. 0091 //----------------------------------------------------------------------------- 0092 0093 virtual Buffer *GetBuff(XrdSsiErrInfo &eRef, int &dlen, bool &last) 0094 {eRef.Set("Not an active stream", EOPNOTSUPP); return 0;} 0095 0096 //----------------------------------------------------------------------------- 0097 //! Asynchronously obtain data from a passive stream (client-side only). 0098 //! 0099 //! @param eRef reference to where error information is to be placed for 0100 //! encountered before during the stream initiation. When data is 0101 //! ready for processing, the ProcessResponseData() callback is 0102 //! called on the request associated with this stream. 0103 //! Also see XrdSsiRequest::GetResponseData() helper method. 0104 //! @param buff pointer to the buffer to receive the data. The buffer must 0105 //! remain valid until ProcessResponse() is called. 0106 //! @param blen the length of the buffer (i.e. maximum that can be returned). 0107 //! 0108 //! @return true The stream has been successfully scheduled to return the data. 0109 //! @return false The stream could not be scheduled; eRef holds the reason. 0110 //----------------------------------------------------------------------------- 0111 0112 virtual bool SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen) 0113 {eRef.Set("Not a passive stream", EOPNOTSUPP); return false;} 0114 0115 //----------------------------------------------------------------------------- 0116 //! Synchronously obtain data from a passive stream (client- or server-side). 0117 //! 0118 //! @param eRef The object to receive any error description. 0119 //! @param buff pointer to the buffer to receive the data. 0120 //! request object is notified that the operation completed. 0121 //! @param blen the length of the buffer (i.e. maximum that can be returned). 0122 //! @param last input: should be set to false. 0123 //! output: if true it indicates that no more data remains to be 0124 //! returned either for this call or on the next call. 0125 //! 0126 //! @return >0 The number of bytes placed in buff. 0127 //! @return =0 No more data remains and the stream becomes invalid. 0128 //! @return <0 Fatal error occurred; eRef holds the reason. 0129 //----------------------------------------------------------------------------- 0130 0131 virtual int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last) 0132 {eRef.Set("Not a passive stream", EOPNOTSUPP); return 0;} 0133 0134 //----------------------------------------------------------------------------- 0135 //! Stream type descriptor: 0136 //! 0137 //! isActive - Active stream that supplies it own buffers with data. 0138 //! GetBuff() & RetBuff() must be used. 0139 //! 0140 //! isPassive - Passive stream that provides data via a supplied buffer. 0141 //! SetBuff() must be used. 0142 //----------------------------------------------------------------------------- 0143 0144 enum StreamType {isActive = 0, isPassive}; 0145 0146 //----------------------------------------------------------------------------- 0147 //! Get the stream type descriptor. 0148 //! 0149 //! @return The stream type, isActive or isPassive. 0150 //----------------------------------------------------------------------------- 0151 0152 StreamType Type() {return SType;} 0153 0154 XrdSsiStream(StreamType stype) : SType(stype) {} 0155 0156 virtual ~XrdSsiStream() {} 0157 0158 protected: 0159 0160 const StreamType SType; 0161 }; 0162 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|