xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XrdClFileOperations.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN)
3 // Author: Krzysztof Jamrog <krzysztof.piotr.jamrog@cern.ch>,
4 // Michal Simon <michal.simon@cern.ch>
5 //------------------------------------------------------------------------------
6 // This file is part of the XRootD software suite.
7 //
8 // XRootD is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Lesser General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // XRootD is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public License
19 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
20 //
21 // In applying this licence, CERN does not waive the privileges and immunities
22 // granted to it by virtue of its status as an Intergovernmental Organization
23 // or submit itself to any jurisdiction.
24 //------------------------------------------------------------------------------
25 
26 #ifndef __XRD_CL_FILE_OPERATIONS_HH__
27 #define __XRD_CL_FILE_OPERATIONS_HH__
28 
29 #include "XrdCl/XrdClFile.hh"
30 #include "XrdCl/XrdClOperations.hh"
32 #include "XrdCl/XrdClCtx.hh"
33 
34 namespace XrdCl
35 {
36 
37  //----------------------------------------------------------------------------
43  //----------------------------------------------------------------------------
44  template<template<bool> class Derived, bool HasHndl, typename Response, typename ... Arguments>
45  class FileOperation: public ConcreteOperation<Derived, HasHndl, Response, Arguments...>
46  {
47 
48  template<template<bool> class, bool, typename, typename ...> friend class FileOperation;
49 
50  public:
51  //------------------------------------------------------------------------
56  //------------------------------------------------------------------------
57  FileOperation( Ctx<File> f, Arguments... args): ConcreteOperation<Derived, false, Response, Arguments...>( std::move( args )... ), file( std::move( f ) )
58  {
59  }
60 
61  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  template<bool from>
70  ConcreteOperation<Derived, HasHndl, Response, Arguments...>( std::move( op ) ), file( op.file )
71  {
72 
73  }
74 
75  //------------------------------------------------------------------------
77  //------------------------------------------------------------------------
78  virtual ~FileOperation()
79  {
80 
81  }
82 
83  protected:
84 
85  //------------------------------------------------------------------------
87  //------------------------------------------------------------------------
89  };
90 
91  //----------------------------------------------------------------------------
93  //----------------------------------------------------------------------------
94  template<bool HasHndl>
97  {
98  //------------------------------------------------------------------------
104  //------------------------------------------------------------------------
105  struct ExResp : public Resp<void>
106  {
107  //--------------------------------------------------------------------
111  //--------------------------------------------------------------------
112  ExResp( const Ctx<File> &file ): file( file )
113  {
114  }
115 
116  //--------------------------------------------------------------------
121  //--------------------------------------------------------------------
122  inline ResponseHandler* Create( std::function<void( XRootDStatus&,
123  StatInfo& )> func )
124  {
125  return new ExOpenFuncWrapper( this->file, func );
126  }
127 
128  //--------------------------------------------------------------------
130  //--------------------------------------------------------------------
131  using Resp<void>::Create;
132 
133  //--------------------------------------------------------------------
135  //--------------------------------------------------------------------
137  };
138 
139  public:
140 
141  //------------------------------------------------------------------------
143  //------------------------------------------------------------------------
146  FileOperation<OpenImpl, HasHndl, Resp<void>, Arg<std::string>, Arg<OpenFlags::Flags>,
147  Arg<Access::Mode>>( std::move( f ), std::move( url ), std::move( flags ),
148  std::move( mode ) )
149  {
150  }
151 
152  //------------------------------------------------------------------------
158  //------------------------------------------------------------------------
159  template<bool from>
161  FileOperation<OpenImpl, HasHndl, Resp<void>, Arg<std::string>, Arg<OpenFlags::Flags>,
162  Arg<Access::Mode>>( std::move( open ) )
163  {
164  }
165 
166 
167  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  enum { UrlArg, FlagsArg, ModeArg };
171 
172  //------------------------------------------------------------------------
177  //------------------------------------------------------------------------
178  template<typename Hdlr>
179  OpenImpl<true> operator>>( Hdlr &&hdlr )
180  {
181  ExResp factory( *this->file );
182  return this->StreamImpl( factory.Create( hdlr ) );
183  }
184 
185  //------------------------------------------------------------------------
187  //------------------------------------------------------------------------
188  std::string ToString()
189  {
190  return "Open";
191  }
192 
193  protected:
194 
195  //------------------------------------------------------------------------
200  //------------------------------------------------------------------------
201  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
202  {
203  const std::string &url = std::get<UrlArg>( this->args );
204  OpenFlags::Flags flags = std::get<FlagsArg>( this->args );
205  Access::Mode mode = std::get<ModeArg>( this->args );
206  uint16_t timeout = pipelineTimeout < this->timeout ?
207  pipelineTimeout : this->timeout;
208  return this->file->Open( url, flags, mode, handler, timeout );
209  }
210  };
212 
213  //----------------------------------------------------------------------------
215  //----------------------------------------------------------------------------
216  template<bool HasHndl>
217  class ReadImpl: public FileOperation<ReadImpl, HasHndl, Resp<ChunkInfo>,
218  Arg<uint64_t>, Arg<uint32_t>, Arg<void*>>
219  {
220  public:
221 
222  //------------------------------------------------------------------------
224  //------------------------------------------------------------------------
227 
228  //------------------------------------------------------------------------
230  //------------------------------------------------------------------------
232 
233  //------------------------------------------------------------------------
235  //------------------------------------------------------------------------
236  std::string ToString()
237  {
238  return "Read";
239  }
240 
241  protected:
242 
243  //------------------------------------------------------------------------
249  //------------------------------------------------------------------------
250  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
251  {
252  uint64_t offset = std::get<OffsetArg>( this->args ).Get();
253  uint32_t size = std::get<SizeArg>( this->args ).Get();
254  void *buffer = std::get<BufferArg>( this->args ).Get();
255  uint16_t timeout = pipelineTimeout < this->timeout ?
256  pipelineTimeout : this->timeout;
257  return this->file->Read( offset, size, buffer, handler, timeout );
258  }
259  };
260 
261  //----------------------------------------------------------------------------
263  //----------------------------------------------------------------------------
265  Arg<void*> buffer, uint16_t timeout = 0 )
266  {
267  return ReadImpl<false>( std::move( file ), std::move( offset ), std::move( size ),
268  std::move( buffer ) ).Timeout( timeout );
269  }
270 
271  //----------------------------------------------------------------------------
273  //----------------------------------------------------------------------------
274  template<bool HasHndl>
275  class CloseImpl: public FileOperation<CloseImpl, HasHndl, Resp<void>>
276  {
277  public:
278 
279  //------------------------------------------------------------------------
281  //------------------------------------------------------------------------
283 
284  //------------------------------------------------------------------------
286  //------------------------------------------------------------------------
287  std::string ToString()
288  {
289  return "Close";
290  }
291 
292  protected:
293 
294  //------------------------------------------------------------------------
300  //------------------------------------------------------------------------
301  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
302  {
303  uint16_t timeout = pipelineTimeout < this->timeout ?
304  pipelineTimeout : this->timeout;
305  return this->file->Close( handler, timeout );
306  }
307  };
309 
310  //----------------------------------------------------------------------------
312  //----------------------------------------------------------------------------
313  template<bool HasHndl>
314  class StatImpl: public FileOperation<StatImpl, HasHndl, Resp<StatInfo>, Arg<bool>>
315  {
316  public:
317 
318  //------------------------------------------------------------------------
320  //------------------------------------------------------------------------
322 
323  //------------------------------------------------------------------------
325  //------------------------------------------------------------------------
326  enum { ForceArg };
327 
328  //------------------------------------------------------------------------
330  //------------------------------------------------------------------------
331  std::string ToString()
332  {
333  return "Stat";
334  }
335 
336  protected:
337 
338  //------------------------------------------------------------------------
344  //------------------------------------------------------------------------
345  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
346  {
347  bool force = std::get<ForceArg>( this->args ).Get();
348  uint16_t timeout = pipelineTimeout < this->timeout ?
349  pipelineTimeout : this->timeout;
350  return this->file->Stat( force, handler, timeout );
351  }
352  };
353 
354  //----------------------------------------------------------------------------
357  //----------------------------------------------------------------------------
358  inline StatImpl<false> Stat( Ctx<File> file, Arg<bool> force, uint16_t timeout = 0 )
359  {
360  return StatImpl<false>( std::move( file ), std::move( force ) ).Timeout( timeout );
361  }
362 
363  //----------------------------------------------------------------------------
365  //----------------------------------------------------------------------------
366  template<bool HasHndl>
367  class WriteImpl: public FileOperation<WriteImpl, HasHndl, Resp<void>, Arg<uint64_t>,
368  Arg<uint32_t>, Arg<const void*>>
369  {
370  public:
371 
372  //------------------------------------------------------------------------
374  //------------------------------------------------------------------------
377 
378  //------------------------------------------------------------------------
380  //------------------------------------------------------------------------
382 
383  //------------------------------------------------------------------------
385  //------------------------------------------------------------------------
386  std::string ToString()
387  {
388  return "Write";
389  }
390 
391  protected:
392 
393  //------------------------------------------------------------------------
399  //------------------------------------------------------------------------
400  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
401  {
402  uint64_t offset = std::get<OffsetArg>( this->args ).Get();
403  uint32_t size = std::get<SizeArg>( this->args ).Get();
404  const void *buffer = std::get<BufferArg>( this->args ).Get();
405  uint16_t timeout = pipelineTimeout < this->timeout ?
406  pipelineTimeout : this->timeout;
407  return this->file->Write( offset, size, buffer, handler, timeout );
408  }
409  };
410 
411  //----------------------------------------------------------------------------
413  //----------------------------------------------------------------------------
415  Arg<const void*> buffer, uint16_t timeout = 0 )
416  {
417  return WriteImpl<false>( std::move( file ), std::move( offset ), std::move( size ),
418  std::move( buffer ) ).Timeout( timeout );
419  }
420 
421  //----------------------------------------------------------------------------
423  //----------------------------------------------------------------------------
424  template<bool HasHndl>
425  class SyncImpl: public FileOperation<SyncImpl, HasHndl, Resp<void>>
426  {
427  public:
428 
429  //------------------------------------------------------------------------
431  //------------------------------------------------------------------------
433 
434  //------------------------------------------------------------------------
436  //------------------------------------------------------------------------
437  std::string ToString()
438  {
439  return "Sync";
440  }
441 
442  protected:
443 
444  //------------------------------------------------------------------------
450  //------------------------------------------------------------------------
451  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
452  {
453  uint16_t timeout = pipelineTimeout < this->timeout ?
454  pipelineTimeout : this->timeout;
455  return this->file->Sync( handler, timeout );
456  }
457  };
459 
460  //----------------------------------------------------------------------------
462  //----------------------------------------------------------------------------
463  template<bool HasHndl>
464  class TruncateImpl: public FileOperation<TruncateImpl, HasHndl, Resp<void>, Arg<uint64_t>>
465  {
466  public:
467 
468  //------------------------------------------------------------------------
470  //------------------------------------------------------------------------
472 
473  //------------------------------------------------------------------------
475  //------------------------------------------------------------------------
476  enum { SizeArg };
477 
478  //------------------------------------------------------------------------
480  //------------------------------------------------------------------------
481  std::string ToString()
482  {
483  return "Truncate";
484  }
485 
486  protected:
487 
488  //------------------------------------------------------------------------
494  //------------------------------------------------------------------------
495  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
496  {
497  uint64_t size = std::get<SizeArg>( this->args ).Get();
498  uint16_t timeout = pipelineTimeout < this->timeout ?
499  pipelineTimeout : this->timeout;
500  return this->file->Truncate( size, handler, timeout );
501  }
502  };
503 
504  //----------------------------------------------------------------------------
507  //----------------------------------------------------------------------------
509  {
510  return TruncateImpl<false>( std::move( file ), std::move( size ) );
511  }
512 
513  //----------------------------------------------------------------------------
515  //----------------------------------------------------------------------------
516  template<bool HasHndl>
517  class VectorReadImpl: public FileOperation<VectorReadImpl, HasHndl,
518  Resp<VectorReadInfo>, Arg<ChunkList>, Arg<void*>>
519  {
520  public:
521 
522  //------------------------------------------------------------------------
524  //------------------------------------------------------------------------
527 
528  //------------------------------------------------------------------------
530  //------------------------------------------------------------------------
531  enum { ChunksArg, BufferArg };
532 
533  //------------------------------------------------------------------------
535  //------------------------------------------------------------------------
536  std::string ToString()
537  {
538  return "VectorRead";
539  }
540 
541  protected:
542 
543  //------------------------------------------------------------------------
549  //------------------------------------------------------------------------
550  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
551  {
552  ChunkList &chunks = std::get<ChunksArg>( this->args ).Get();
553  void *buffer = std::get<BufferArg>( this->args ).Get();
554  uint16_t timeout = pipelineTimeout < this->timeout ?
555  pipelineTimeout : this->timeout;
556  return this->file->VectorRead( chunks, buffer, handler, timeout );
557  }
558  };
560 
561  //----------------------------------------------------------------------------
563  //----------------------------------------------------------------------------
564  template<bool HasHndl>
565  class VectorWriteImpl: public FileOperation<VectorWriteImpl, HasHndl, Resp<void>,
566  Arg<ChunkList>>
567  {
568  public:
569 
570  //------------------------------------------------------------------------
572  //------------------------------------------------------------------------
574 
575  //------------------------------------------------------------------------
577  //------------------------------------------------------------------------
578  enum { ChunksArg };
579 
580  //------------------------------------------------------------------------
582  //------------------------------------------------------------------------
583  std::string ToString()
584  {
585  return "VectorWrite";
586  }
587 
588  protected:
589 
590  //------------------------------------------------------------------------
596  //------------------------------------------------------------------------
597  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
598  {
599  const ChunkList &chunks = std::get<ChunksArg>( this->args ).Get();
600  uint16_t timeout = pipelineTimeout < this->timeout ?
601  pipelineTimeout : this->timeout;
602  return this->file->VectorWrite( chunks, handler, timeout );
603  }
604  };
606 
607  //----------------------------------------------------------------------------
609  //----------------------------------------------------------------------------
610  template<bool HasHndl>
611  class WriteVImpl: public FileOperation<WriteVImpl, HasHndl, Resp<void>, Arg<uint64_t>,
612  Arg<std::vector<iovec>>>
613  {
614  public:
615 
616  //------------------------------------------------------------------------
618  //------------------------------------------------------------------------
621 
622  //------------------------------------------------------------------------
624  //------------------------------------------------------------------------
625  enum { OffsetArg, IovArg };
626 
627  //------------------------------------------------------------------------
629  //------------------------------------------------------------------------
630  std::string ToString()
631  {
632  return "WriteV";
633  }
634 
635  protected:
636 
637  //------------------------------------------------------------------------
643  //------------------------------------------------------------------------
644  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
645  {
646  uint64_t offset = std::get<OffsetArg>( this->args ).Get();
647  std::vector<iovec> &stdiov = std::get<IovArg>( this->args ).Get();
648  uint16_t timeout = pipelineTimeout < this->timeout ?
649  pipelineTimeout : this->timeout;
650 
651  int iovcnt = stdiov.size();
652  iovec iov[iovcnt];
653  for( size_t i = 0; i < stdiov.size(); ++i )
654  {
655  iov[i].iov_base = stdiov[i].iov_base;
656  iov[i].iov_len = stdiov[i].iov_len;
657  }
658 
659  return this->file->WriteV( offset, iov, iovcnt, handler, timeout );
660  }
661  };
662 
663  //----------------------------------------------------------------------------
665  //----------------------------------------------------------------------------
667  Arg<std::vector<iovec>> iov, uint16_t timeout = 0 )
668  {
669  return WriteVImpl<false>( std::move( file ), std::move( offset ),
670  std::move( iov ) ).Timeout( timeout );
671  }
672 
673  //----------------------------------------------------------------------------
675  //----------------------------------------------------------------------------
676  template<bool HasHndl>
677  class FcntlImpl: public FileOperation<FcntlImpl, HasHndl, Resp<Buffer>, Arg<Buffer>>
678  {
679  public:
680 
681  //------------------------------------------------------------------------
683  //------------------------------------------------------------------------
685 
686  //------------------------------------------------------------------------
688  //------------------------------------------------------------------------
689  enum { BufferArg };
690 
691  //------------------------------------------------------------------------
693  //------------------------------------------------------------------------
694  std::string ToString()
695  {
696  return "Fcntl";
697  }
698 
699  protected:
700 
701  //------------------------------------------------------------------------
707  //------------------------------------------------------------------------
708  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
709  {
710  Buffer &arg = std::get<BufferArg>( this->args ).Get();
711  uint16_t timeout = pipelineTimeout < this->timeout ?
712  pipelineTimeout : this->timeout;
713  return this->file->Fcntl( arg, handler, timeout );
714  }
715  };
717 
718  //----------------------------------------------------------------------------
720  //----------------------------------------------------------------------------
721  template<bool HasHndl>
722  class VisaImpl: public FileOperation<VisaImpl, HasHndl, Resp<Buffer>>
723  {
724  public:
725 
726  //------------------------------------------------------------------------
728  //------------------------------------------------------------------------
730 
731  //------------------------------------------------------------------------
733  //------------------------------------------------------------------------
734  std::string ToString()
735  {
736  return "Visa";
737  }
738 
739  protected:
740 
741  //------------------------------------------------------------------------
747  //------------------------------------------------------------------------
748  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
749  {
750  uint16_t timeout = pipelineTimeout < this->timeout ?
751  pipelineTimeout : this->timeout;
752  return this->file->Visa( handler, timeout );
753  }
754  };
756 
757  //----------------------------------------------------------------------------
759  //----------------------------------------------------------------------------
760  template<bool HasHndl>
761  class SetXAttrImpl: public FileOperation<SetXAttrImpl, HasHndl, Resp<void>,
762  Arg<std::string>, Arg<std::string>>
763  {
764  public:
765 
766  //------------------------------------------------------------------------
768  //------------------------------------------------------------------------
771 
772  //------------------------------------------------------------------------
774  //------------------------------------------------------------------------
775  enum { NameArg, ValueArg };
776 
777  //------------------------------------------------------------------------
779  //------------------------------------------------------------------------
780  std::string ToString()
781  {
782  return "SetXAttrImpl";
783  }
784 
785  protected:
786 
787  //------------------------------------------------------------------------
793  //------------------------------------------------------------------------
794  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
795  {
796  std::string &name = std::get<NameArg>( this->args ).Get();
797  std::string &value = std::get<ValueArg>( this->args ).Get();
798  // wrap the arguments with a vector
799  std::vector<xattr_t> attrs;
800  attrs.push_back( xattr_t( name, value ) );
801  // wrap the PipelineHandler so the response gets unpacked properly
802  UnpackXAttrStatus *h = new UnpackXAttrStatus( handler );
803  uint16_t timeout = pipelineTimeout < this->timeout ?
804  pipelineTimeout : this->timeout;
805  XRootDStatus st = this->file->SetXAttr( attrs, h, timeout );
806  if( !st.IsOK() ) delete h;
807  return st;
808  }
809  };
810 
811  //----------------------------------------------------------------------------
814  //----------------------------------------------------------------------------
816  {
817  return SetXAttrImpl<false>( std::move( file ), std::move( name ), std::move( value ) );
818  }
819 
820  //----------------------------------------------------------------------------
822  //----------------------------------------------------------------------------
823  template<bool HasHndl>
824  class SetXAttrBulkImpl: public FileOperation<SetXAttrBulkImpl, HasHndl,
825  Resp<std::vector<XAttrStatus>>, Arg<std::vector<xattr_t>>>
826  {
827  public:
828 
829  //------------------------------------------------------------------------
831  //------------------------------------------------------------------------
834 
835  //------------------------------------------------------------------------
837  //------------------------------------------------------------------------
838  enum { AttrsArg };
839 
840  //------------------------------------------------------------------------
842  //------------------------------------------------------------------------
843  std::string ToString()
844  {
845  return "SetXAttrBulkImpl";
846  }
847 
848 
849  protected:
850 
851  //------------------------------------------------------------------------
857  //------------------------------------------------------------------------
858  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
859  {
860  std::vector<xattr_t> &attrs = std::get<AttrsArg>( this->args ).Get();
861  uint16_t timeout = pipelineTimeout < this->timeout ?
862  pipelineTimeout : this->timeout;
863  return this->file->SetXAttr( attrs, handler, timeout );
864  }
865  };
866 
867  //----------------------------------------------------------------------------
870  //----------------------------------------------------------------------------
871  inline SetXAttrBulkImpl<false> SetXAttr( Ctx<File> file, Arg<std::vector<xattr_t>> attrs )
872  {
873  return SetXAttrBulkImpl<false>( std::move( file ), std::move( attrs ) );
874  }
875 
876  //----------------------------------------------------------------------------
878  //----------------------------------------------------------------------------
879  template<bool HasHndl>
880  class GetXAttrImpl: public FileOperation<GetXAttrImpl, HasHndl, Resp<std::string>,
881  Arg<std::string>>
882  {
883  public:
884 
885  //------------------------------------------------------------------------
887  //------------------------------------------------------------------------
890 
891  //------------------------------------------------------------------------
893  //------------------------------------------------------------------------
894  enum { NameArg };
895 
896  //------------------------------------------------------------------------
898  //------------------------------------------------------------------------
899  std::string ToString()
900  {
901  return "GetXAttrImpl";
902  }
903 
904  protected:
905 
906  //------------------------------------------------------------------------
912  //------------------------------------------------------------------------
913  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
914  {
915  std::string &name = std::get<NameArg>( this->args ).Get();
916  // wrap the argument with a vector
917  std::vector<std::string> attrs;
918  attrs.push_back( name );
919  // wrap the PipelineHandler so the response gets unpacked properly
920  UnpackXAttr *h = new UnpackXAttr( handler );
921  uint16_t timeout = pipelineTimeout < this->timeout ?
922  pipelineTimeout : this->timeout;
923  XRootDStatus st = this->file->GetXAttr( attrs, h, timeout );
924  if( !st.IsOK() ) delete handler;
925  return st;
926  }
927  };
928 
929  //----------------------------------------------------------------------------
932  //----------------------------------------------------------------------------
934  {
935  return GetXAttrImpl<false>( std::move( file ), std::move( name ) );
936  }
937 
938  //----------------------------------------------------------------------------
940  //----------------------------------------------------------------------------
941  template<bool HasHndl>
942  class GetXAttrBulkImpl: public FileOperation<GetXAttrBulkImpl, HasHndl, Resp<std::vector<XAttr>>,
943  Arg<std::vector<std::string>>>
944  {
945  public:
946 
947  //------------------------------------------------------------------------
949  //------------------------------------------------------------------------
952 
953  //------------------------------------------------------------------------
955  //------------------------------------------------------------------------
956  enum { NamesArg };
957 
958  //------------------------------------------------------------------------
960  //------------------------------------------------------------------------
961  std::string ToString()
962  {
963  return "GetXAttrBulkImpl";
964  }
965 
966 
967  protected:
968 
969  //------------------------------------------------------------------------
975  //------------------------------------------------------------------------
976  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
977  {
978  std::vector<std::string> &attrs = std::get<NamesArg>( this->args ).Get();
979  uint16_t timeout = pipelineTimeout < this->timeout ?
980  pipelineTimeout : this->timeout;
981  return this->file->GetXAttr( attrs, handler, timeout );
982  }
983  };
984 
985  //----------------------------------------------------------------------------
988  //----------------------------------------------------------------------------
989  inline GetXAttrBulkImpl<false> GetXAttr( Ctx<File> file, Arg<std::vector<std::string>> attrs )
990  {
991  return GetXAttrBulkImpl<false>( std::move( file ), std::move( attrs ) );
992  }
993 
994  //----------------------------------------------------------------------------
996  //----------------------------------------------------------------------------
997  template<bool HasHndl>
998  class DelXAttrImpl: public FileOperation<DelXAttrImpl, HasHndl, Resp<void>,
999  Arg<std::string>>
1000  {
1001  public:
1002 
1003  //------------------------------------------------------------------------
1005  //------------------------------------------------------------------------
1007 
1008  //------------------------------------------------------------------------
1010  //------------------------------------------------------------------------
1011  enum { NameArg };
1012 
1013  //------------------------------------------------------------------------
1015  //------------------------------------------------------------------------
1016  std::string ToString()
1017  {
1018  return "DelXAttrImpl";
1019  }
1020 
1021  protected:
1022 
1023  //------------------------------------------------------------------------
1029  //------------------------------------------------------------------------
1030  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1031  {
1032  std::string &name = std::get<NameArg>( this->args ).Get();
1033  // wrap the argument with a vector
1034  std::vector<std::string> attrs;
1035  attrs.push_back( name );
1036  // wrap the PipelineHandler so the response gets unpacked properly
1037  UnpackXAttrStatus *h = new UnpackXAttrStatus( handler );
1038  uint16_t timeout = pipelineTimeout < this->timeout ?
1039  pipelineTimeout : this->timeout;
1040  XRootDStatus st = this->file->DelXAttr( attrs, h, timeout );
1041  if( !st.IsOK() ) delete h;
1042  return st;
1043  }
1044  };
1045 
1046  //----------------------------------------------------------------------------
1049  //----------------------------------------------------------------------------
1051  {
1052  return DelXAttrImpl<false>( std::move( file ), std::move( name ) );
1053  }
1054 
1055  //----------------------------------------------------------------------------
1057  //----------------------------------------------------------------------------
1058  template<bool HasHndl>
1059  class DelXAttrBulkImpl: public FileOperation<DelXAttrBulkImpl, HasHndl,
1060  Resp<std::vector<XAttrStatus>>, Arg<std::vector<std::string>>>
1061  {
1062  public:
1063 
1064  //------------------------------------------------------------------------
1066  //------------------------------------------------------------------------
1069 
1070  //------------------------------------------------------------------------
1072  //------------------------------------------------------------------------
1073  enum { NamesArg };
1074 
1075  //------------------------------------------------------------------------
1077  //------------------------------------------------------------------------
1078  std::string ToString()
1079  {
1080  return "DelXAttrBulkImpl";
1081  }
1082 
1083 
1084  protected:
1085 
1086  //------------------------------------------------------------------------
1092  //------------------------------------------------------------------------
1093  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1094  {
1095  std::vector<std::string> &attrs = std::get<NamesArg>( this->args ).Get();
1096  uint16_t timeout = pipelineTimeout < this->timeout ?
1097  pipelineTimeout : this->timeout;
1098  return this->file->DelXAttr( attrs, handler, timeout );
1099  }
1100  };
1101 
1102  //----------------------------------------------------------------------------
1105  //----------------------------------------------------------------------------
1106  inline DelXAttrBulkImpl<false> DelXAttr( Ctx<File> file, Arg<std::vector<std::string>> attrs )
1107  {
1108  return DelXAttrBulkImpl<false>( std::move( file ), std::move( attrs ) );
1109  }
1110 
1111  //----------------------------------------------------------------------------
1113  //----------------------------------------------------------------------------
1114  template<bool HasHndl>
1115  class ListXAttrImpl: public FileOperation<ListXAttrImpl, HasHndl,
1116  Resp<std::vector<XAttr>>>
1117  {
1118  public:
1119 
1120  //------------------------------------------------------------------------
1122  //------------------------------------------------------------------------
1124 
1125  //------------------------------------------------------------------------
1127  //------------------------------------------------------------------------
1128  std::string ToString()
1129  {
1130  return "ListXAttrImpl";
1131  }
1132 
1133 
1134  protected:
1135 
1136  //------------------------------------------------------------------------
1142  //------------------------------------------------------------------------
1143  XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1144  {
1145  uint16_t timeout = pipelineTimeout < this->timeout ?
1146  pipelineTimeout : this->timeout;
1147  return this->file->ListXAttr( handler, timeout );
1148  }
1149  };
1150 
1151  //----------------------------------------------------------------------------
1154  //----------------------------------------------------------------------------
1156  {
1157  return ListXAttrImpl<false>( std::move( file ) );
1158  }
1159 }
1160 
1161 #endif // __XRD_CL_FILE_OPERATIONS_HH__
1162 
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:858
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:794
Definition: XrdClFileOperations.hh:1073
ListXAttrImpl< false > ListXAttr(Ctx< File > file)
Definition: XrdClFileOperations.hh:1155
std::string ToString()
Definition: XrdClFileOperations.hh:630
CloseImpl< false > Close
Definition: XrdClFileOperations.hh:308
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:976
std::string ToString()
Definition: XrdClFileOperations.hh:780
FileOperation(FileOperation< Derived, from, Response, Arguments...> &&op)
Definition: XrdClFileOperations.hh:69
Close operation (.
Definition: XrdClFileOperations.hh:275
Definition: XrdClFileOperations.hh:578
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:1093
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:1030
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
Definition: XrdClFileOperations.hh:815
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:400
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:1143
Utility class for storing a pointer to operation context.
Definition: XrdClCtx.hh:37
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:980
VectorReadImpl< false > VectorRead
Definition: XrdClFileOperations.hh:559
Definition: XrdClFileOperations.hh:894
VectorRead operation (.
Definition: XrdClFileOperations.hh:517
FcntlImpl< false > Fcntl
Definition: XrdClFileOperations.hh:716
std::string ToString()
Definition: XrdClFileOperations.hh:843
Object stat info.
Definition: XrdClXRootDResponses.hh:399
std::string ToString()
Definition: XrdClFileOperations.hh:287
std::string ToString()
Definition: XrdClFileOperations.hh:188
Definition: XrdClFileOperations.hh:625
Definition: XrdClOperationTimeout.hh:19
std::string ToString()
Definition: XrdClFileOperations.hh:1078
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:550
Ctx< File > file
The underlying XrdCl::File object.
Definition: XrdClFileOperations.hh:136
DelXAttr bulk operation (.
Definition: XrdClFileOperations.hh:1059
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:451
VectorWrite operation (.
Definition: XrdClFileOperations.hh:565
uint16_t timeout
Operation timeout.
Definition: XrdClOperations.hh:766
Fcntl operation (.
Definition: XrdClFileOperations.hh:677
DelXAttrImpl< false > DelXAttr(Ctx< File > file, Arg< std::string > name)
Definition: XrdClFileOperations.hh:1050
SyncImpl< false > Sync
Definition: XrdClFileOperations.hh:458
SetXAttr operation (.
Definition: XrdClFileOperations.hh:761
std::string ToString()
Definition: XrdClFileOperations.hh:386
Visa operation (.
Definition: XrdClFileOperations.hh:722
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:708
FileOperation(Ctx< File > f, Arguments...args)
Definition: XrdClFileOperations.hh:57
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.
Definition: XrdClFileOperations.hh:264
std::string ToString()
Definition: XrdClFileOperations.hh:481
Access mode.
Definition: XrdClFileSystem.hh:116
Definition: XrdClFileOperations.hh:476
GetXAttr operation (.
Definition: XrdClFileOperations.hh:880
std::string ToString()
Definition: XrdClFileOperations.hh:437
Definition: XrdClFileOperations.hh:231
Read operation (.
Definition: XrdClFileOperations.hh:217
std::string ToString()
Definition: XrdClFileOperations.hh:583
std::string ToString()
Definition: XrdClFileOperations.hh:694
std::string ToString()
Definition: XrdClFileOperations.hh:236
OpenImpl< true > operator>>(Hdlr &&hdlr)
Definition: XrdClFileOperations.hh:179
std::string ToString()
Definition: XrdClFileOperations.hh:1128
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
Definition: XrdClFileOperations.hh:933
Definition: XrdClFileOperations.hh:170
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size)
Definition: XrdClFileOperations.hh:508
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:748
VectorWriteImpl< false > VectorWrite
Definition: XrdClFileOperations.hh:605
ListXAttr bulk operation (.
Definition: XrdClFileOperations.hh:1115
std::string ToString()
Definition: XrdClFileOperations.hh:734
Definition: XrdClOperationHandlers.hh:623
Truncate operation (.
Definition: XrdClFileOperations.hh:464
WriteV operation (.
Definition: XrdClFileOperations.hh:611
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Definition: XrdClFileOperations.hh:231
Definition: XrdOucIOVec.hh:65
std::string ToString()
Definition: XrdClFileOperations.hh:331
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.
Definition: XrdClFileOperations.hh:414
Definition: XrdClFileOperations.hh:775
Definition: XrdClFileOperations.hh:381
virtual ~FileOperation()
Destructor.
Definition: XrdClFileOperations.hh:78
SetXAttr bulk operation (.
Definition: XrdClFileOperations.hh:824
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:644
Helper class for unpacking single XAttr from bulk response.
Definition: XrdClOperationHandlers.hh:76
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:201
std::tuple< Args...> args
Operation arguments.
Definition: XrdClOperations.hh:761
Definition: XrdClArg.hh:232
Definition: XrdClFileOperations.hh:105
Definition: XrdClArg.hh:294
Stat operation (.
Definition: XrdClFileOperations.hh:314
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:495
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:913
Request status.
Definition: XrdClXRootDResponses.hh:218
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
Definition: XrdClFileOperations.hh:358
Definition: XrdClFileOperations.hh:231
GetXAttr bulk operation (.
Definition: XrdClFileOperations.hh:942
Sync operation (.
Definition: XrdClFileOperations.hh:425
Definition: XrdClFileOperations.hh:326
std::string ToString()
Definition: XrdClFileOperations.hh:899
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:250
Definition: XrdClFileOperations.hh:381
Definition: XrdClOperations.hh:58
Lambda wrapper.
Definition: XrdClOperationHandlers.hh:311
OpenImpl(OpenImpl< from > &&open)
Definition: XrdClFileOperations.hh:160
Definition: XrdClFileOperations.hh:45
Handle an async response.
Definition: XrdClXRootDResponses.hh:1050
Definition: XrdClFileSystem.hh:123
Helper class for unpacking single XAttrStatus from bulk response.
Definition: XrdClOperationHandlers.hh:41
std::string ToString()
Definition: XrdClFileOperations.hh:536
OpenImpl< false > Open
Definition: XrdClFileOperations.hh:211
Definition: XrdClFileOperations.hh:1011
friend class FileOperation
Definition: XrdClFileOperations.hh:48
ResponseHandler * Create(std::function< void(XRootDStatus &, StatInfo &)> func)
Definition: XrdClFileOperations.hh:122
Open operation (.
Definition: XrdClFileOperations.hh:95
Mode
Access mode.
Definition: XrdClFileSystem.hh:121
std::string ToString()
Definition: XrdClFileOperations.hh:1016
#define open
Definition: XrdPosix.hh:71
Definition: XrdClFileOperations.hh:956
VisaImpl< false > Visa
Definition: XrdClFileOperations.hh:755
Definition: XrdClFileOperations.hh:531
Definition: XrdClFileOperations.hh:381
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:345
Definition: XrdClFileOperations.hh:838
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:597
WriteVImpl< false > WriteV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, uint16_t timeout=0)
Factory for creating WriteVImpl objects.
Definition: XrdClFileOperations.hh:666
Definition: XrdClFileOperations.hh:531
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition: XrdClFileOperations.hh:301
Definition: XrdClFileOperations.hh:689
Definition: XrdClFileOperations.hh:625
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:75
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition: XrdClXRootDResponses.hh:289
bool IsOK() const
We&#39;re fine.
Definition: XrdClStatus.hh:122
Ctx< File > file
The file object itself.
Definition: XrdClFileOperations.hh:88
Write operation (.
Definition: XrdClFileOperations.hh:367
std::string ToString()
Definition: XrdClFileOperations.hh:961
Definition: XrdClFileOperations.hh:775
ExResp(const Ctx< File > &file)
Definition: XrdClFileOperations.hh:112
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition: XrdClOperations.hh:304
OpenImpl(Ctx< File > f, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None)
Constructor (.
Definition: XrdClFileOperations.hh:144
Binary blob representation.
Definition: XrdClBuffer.hh:33
DelXAttr operation (.
Definition: XrdClFileOperations.hh:998
Definition: XrdClOperations.hh:541