26 #ifndef __XRD_CL_FILE_OPERATIONS_HH__
27 #define __XRD_CL_FILE_OPERATIONS_HH__
44 template<
template<
bool>
class Derived,
bool HasHndl,
typename Response,
typename ... Arguments>
48 template<
template<
bool>
class, bool,
typename,
typename ...>
friend class FileOperation;
94 template<
bool HasHndl>
105 struct ExResp :
public Resp<void>
112 ExResp(
const Ctx<File> &file ): file( file )
147 Arg<
Access::
Mode>>( std::move( f ), std::move( url ), std::move( flags ),
178 template<
typename Hdlr>
181 ExResp factory( *this->file );
182 return this->StreamImpl( factory.Create( hdlr ) );
203 const std::string &url = std::get<UrlArg>( this->args );
206 uint16_t timeout = pipelineTimeout < this->timeout ?
207 pipelineTimeout : this->timeout;
208 return this->file->Open( url, flags, mode, handler, timeout );
218 return OpenImpl<false>( std::move( file ), std::move( url ), std::move( flags ),
219 std::move( mode ) ).
Timeout( timeout );
225 template<
bool HasHndl>
227 Arg<uint64_t>, Arg<uint32_t>, Arg<void*>>
261 uint64_t offset = std::get<OffsetArg>( this->
args ).Get();
262 uint32_t size = std::get<SizeArg>( this->
args ).Get();
263 void *buffer = std::get<BufferArg>( this->
args ).Get();
264 uint16_t
timeout = pipelineTimeout < this->timeout ?
265 pipelineTimeout : this->
timeout;
276 return ReadImpl<false>( std::move( file ), std::move( offset ), std::move( size ),
277 std::move( buffer ) ).
Timeout( timeout );
283 template<
bool HasHndl>
285 Arg<uint64_t>, Arg<uint32_t>, Arg<void*>>
319 uint64_t offset = std::get<OffsetArg>( this->
args ).Get();
320 uint32_t size = std::get<SizeArg>( this->
args ).Get();
321 void *buffer = std::get<BufferArg>( this->
args ).Get();
322 uint16_t
timeout = pipelineTimeout < this->timeout ?
323 pipelineTimeout : this->
timeout;
333 uint16_t timeout = 0 )
335 return PgReadImpl<false>( std::move( file ), std::move( offset ), std::move( size ),
336 std::move( buffer ) ).
Timeout( timeout );
356 return Read( std::move( file ), std::move( offset ), std::move( size ),
357 std::move( buffer ), timeout );
360 template<>
inline PgReadImpl<false>
362 Arg<void*> buffer, uint16_t timeout )
364 return PgRead( std::move( file ), std::move( offset ), std::move( size ),
365 std::move( buffer ), timeout );
371 template<
bool HasHndl>
373 Arg<uint64_t>, Arg<uint32_t>, Arg<void*>, Arg<std::vector<uint32_t>>>
407 uint64_t offset = std::get<OffsetArg>( this->
args ).Get();
408 uint32_t size = std::get<SizeArg>( this->
args ).Get();
409 void *buffer = std::get<BufferArg>( this->
args ).Get();
410 std::vector<uint32_t> cksums = std::get<CksumsArg>( this->
args ).Get();
411 uint16_t
timeout = pipelineTimeout < this->timeout ?
412 pipelineTimeout : this->
timeout;
413 return this->file->PgWrite( offset, size, buffer, cksums,
handler,
timeout );
422 Arg<std::vector<uint32_t>> cksums,
423 uint16_t timeout = 0 )
426 std::move( buffer ), std::move( cksums ) ).
Timeout( timeout );
434 uint16_t timeout = 0 )
436 std::vector<uint32_t> cksums;
438 std::move( buffer ), std::move( cksums ) ).
Timeout( timeout );
444 template<
bool HasHndl>
473 uint16_t
timeout = pipelineTimeout < this->timeout ?
474 pipelineTimeout : this->
timeout;
490 template<
bool HasHndl>
524 bool force = std::get<ForceArg>( this->
args ).Get();
525 uint16_t
timeout = pipelineTimeout < this->timeout ?
526 pipelineTimeout : this->
timeout;
543 template<
bool HasHndl>
545 Arg<uint32_t>, Arg<const void*>>
579 uint64_t offset = std::get<OffsetArg>( this->
args ).Get();
580 uint32_t size = std::get<SizeArg>( this->
args ).Get();
581 const void *buffer = std::get<BufferArg>( this->
args ).Get();
582 uint16_t
timeout = pipelineTimeout < this->timeout ?
583 pipelineTimeout : this->
timeout;
584 return this->file->Write( offset, size, buffer,
handler,
timeout );
594 return WriteImpl<false>( std::move( file ), std::move( offset ), std::move( size ),
595 std::move( buffer ) ).
Timeout( timeout );
601 template<
bool HasHndl>
630 uint16_t
timeout = pipelineTimeout < this->timeout ?
631 pipelineTimeout : this->
timeout;
647 template<
bool HasHndl>
681 uint64_t size = std::get<SizeArg>( this->
args ).Get();
682 uint16_t
timeout = pipelineTimeout < this->timeout ?
683 pipelineTimeout : this->
timeout;
700 template<
bool HasHndl>
702 Resp<VectorReadInfo>, Arg<ChunkList>, Arg<void*>>
737 void *buffer = std::get<BufferArg>( this->
args ).Get();
738 uint16_t
timeout = pipelineTimeout < this->timeout ?
739 pipelineTimeout : this->
timeout;
740 return this->file->VectorRead( chunks, buffer,
handler,
timeout );
754 uint16_t timeout = 0 )
762 template<
bool HasHndl>
783 return "VectorWrite";
797 const ChunkList &chunks = std::get<ChunksArg>( this->
args ).Get();
798 uint16_t
timeout = pipelineTimeout < this->timeout ?
799 pipelineTimeout : this->
timeout;
808 uint16_t timeout = 0 )
816 template<
bool HasHndl>
818 Arg<std::vector<iovec>>>
852 uint64_t offset = std::get<OffsetArg>( this->
args ).Get();
853 std::vector<iovec> &stdiov = std::get<IovArg>( this->
args ).Get();
854 uint16_t
timeout = pipelineTimeout < this->timeout ?
855 pipelineTimeout : this->
timeout;
857 int iovcnt = stdiov.size();
859 for(
size_t i = 0; i < stdiov.size(); ++i )
861 iov[i].iov_base = stdiov[i].iov_base;
862 iov[i].iov_len = stdiov[i].iov_len;
873 Arg<std::vector<iovec>>
iov, uint16_t timeout = 0 )
882 template<
bool HasHndl>
916 Buffer &arg = std::get<BufferArg>( this->
args ).Get();
917 uint16_t
timeout = pipelineTimeout < this->timeout ?
918 pipelineTimeout : this->
timeout;
927 template<
bool HasHndl>
956 uint16_t
timeout = pipelineTimeout < this->timeout ?
957 pipelineTimeout : this->
timeout;
966 template<
bool HasHndl>
968 Arg<std::string>, Arg<std::string>>
988 return "SetXAttrImpl";
1002 std::string &name = std::get<NameArg>( this->
args ).Get();
1003 std::string &value = std::get<ValueArg>( this->
args ).Get();
1005 std::vector<xattr_t> attrs;
1006 attrs.push_back(
xattr_t( name, value ) );
1009 uint16_t
timeout = pipelineTimeout < this->timeout ?
1010 pipelineTimeout : this->
timeout;
1012 if( !st.
IsOK() )
delete h;
1029 template<
bool HasHndl>
1031 Resp<std::vector<XAttrStatus>>, Arg<std::vector<xattr_t>>>
1051 return "SetXAttrBulkImpl";
1066 std::vector<xattr_t> &attrs = std::get<AttrsArg>( this->
args ).Get();
1067 uint16_t
timeout = pipelineTimeout < this->timeout ?
1068 pipelineTimeout : this->
timeout;
1085 template<
bool HasHndl>
1107 return "GetXAttrImpl";
1121 std::string &name = std::get<NameArg>( this->
args ).Get();
1123 std::vector<std::string> attrs;
1124 attrs.push_back( name );
1127 uint16_t
timeout = pipelineTimeout < this->timeout ?
1128 pipelineTimeout : this->
timeout;
1130 if( !st.
IsOK() )
delete h;
1147 template<
bool HasHndl>
1149 Arg<std::vector<std::string>>>
1169 return "GetXAttrBulkImpl";
1184 std::vector<std::string> &attrs = std::get<NamesArg>( this->
args ).Get();
1185 uint16_t
timeout = pipelineTimeout < this->timeout ?
1186 pipelineTimeout : this->
timeout;
1203 template<
bool HasHndl>
1224 return "DelXAttrImpl";
1238 std::string &name = std::get<NameArg>( this->
args ).Get();
1240 std::vector<std::string> attrs;
1241 attrs.push_back( name );
1244 uint16_t
timeout = pipelineTimeout < this->timeout ?
1245 pipelineTimeout : this->
timeout;
1247 if( !st.
IsOK() )
delete h;
1264 template<
bool HasHndl>
1266 Resp<std::vector<XAttrStatus>>, Arg<std::vector<std::string>>>
1286 return "DelXAttrBulkImpl";
1301 std::vector<std::string> &attrs = std::get<NamesArg>( this->
args ).Get();
1302 uint16_t
timeout = pipelineTimeout < this->timeout ?
1303 pipelineTimeout : this->
timeout;
1320 template<
bool HasHndl>
1322 Resp<std::vector<XAttr>>>
1336 return "ListXAttrImpl";
1351 uint16_t
timeout = pipelineTimeout < this->timeout ?
1352 pipelineTimeout : this->
timeout;
int open(const char *path, int oflag,...)
Binary blob representation.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
std::tuple< Args... > args
Operation arguments.
uint16_t timeout
Operation timeout.
Derived< HasHndl > Timeout(uint16_t timeout)
Set operation timeout.
DelXAttr bulk operation (.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
FileOperation(Ctx< File > f, Arguments... args)
virtual ~FileOperation()
Destructor.
FileOperation(FileOperation< Derived, from, Response, Arguments... > &&op)
friend class FileOperation
Ctx< File > file
The file object itself.
GetXAttr bulk operation (.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
ListXAttr bulk operation (.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
OpenImpl(OpenImpl< from > &&open)
OpenImpl< true > operator>>(Hdlr &&hdlr)
OpenImpl(Ctx< File > f, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None)
Constructor (.
std::unique_ptr< PipelineHandler > handler
Operation handler.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Handle an async response.
SetXAttr bulk operation (.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Helper class for unpacking single XAttrStatus from bulk response.
Helper class for unpacking single XAttr from bulk response.
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
VectorWriteImpl< false > VectorWrite(Ctx< File > file, Arg< ChunkList > chunks, uint16_t timeout=0)
Factory for creating VectorWriteImpl objects.
DelXAttrImpl< false > DelXAttr(Ctx< File > file, Arg< std::string > name)
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
WriteImpl< false > Write(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< const void * > buffer, uint16_t timeout=0)
Factory for creating WriteImpl objects.
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
ReadImpl< false > Read(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating ReadImpl objects.
ReadImpl< false > RdWithRsp< ChunkInfo >(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout)
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
OpenImpl< false > Open(Ctx< File > file, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None, uint16_t timeout=0)
Factory for creating ReadImpl objects.
PgWriteImpl< false > PgWrite(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, Arg< std::vector< uint32_t >> cksums, uint16_t timeout=0)
Factory for creating PgReadImpl objects.
SyncImpl< false > Sync(Ctx< File > file, uint16_t timeout=0)
Factory for creating SyncImpl objects.
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
VectorReadImpl< false > VectorRead(Ctx< File > file, Arg< ChunkList > chunks, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating VectorReadImpl objects.
std::vector< ChunkInfo > ChunkList
List of chunks.
ReadTrait< RSP >::RET RdWithRsp(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size, uint16_t timeout)
ListXAttrImpl< false > ListXAttr(Ctx< File > file)
WriteVImpl< false > WriteV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, uint16_t timeout=0)
Factory for creating WriteVImpl objects.
PgReadImpl< false > RdWithRsp< PageInfo >(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout)
PgReadImpl< false > PgRead(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating PgReadImpl objects.
CloseImpl< false > Close(Ctx< File > file, uint16_t timeout=0)
Factory for creating CloseImpl objects.
RdWithRsp: factory for creating ReadImpl/PgReadImpl objects.
Describe a data chunk for vector read.
Utility class for storing a pointer to operation context.
Open flags, may be or'd when appropriate.
Flags
Open flags, may be or'd when appropriate.
bool IsOK() const
We're fine.