XRootD
XrdClClassicCopyJob.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_CLASSIC_COPY_JOB_HH__
20 #define __XRD_CL_CLASSIC_COPY_JOB_HH__
21 
23 #include "XrdCl/XrdClCopyJob.hh"
24 
25 namespace XrdCl
26 {
27  class ClassicCopyJob: public CopyJob
28  {
29  public:
30  //------------------------------------------------------------------------
31  // Constructor
32  //------------------------------------------------------------------------
33  ClassicCopyJob( uint16_t jobId,
34  PropertyList *jobProperties,
35  PropertyList *jobResults );
36 
37  //------------------------------------------------------------------------
42  //------------------------------------------------------------------------
43  virtual XRootDStatus Run( CopyProgressHandler *progress = 0 );
44 
45  //------------------------------------------------------------------------
46  // Get the final result
47  //------------------------------------------------------------------------
48  inline const XRootDStatus& GetResult() const
49  {
50  return result;
51  }
52 
53  private:
54 
55  //------------------------------------------------------------------------
56  // Update the final result so it is clear that it is a source error
57  //------------------------------------------------------------------------
58  inline XrdCl::XRootDStatus& SourceError( XrdCl::XRootDStatus &status )
59  {
60  std::string msg = status.GetErrorMessage();
61  msg += " (source)";
62  status.SetErrorMessage( msg );
63  result = status;
64  return status;
65  }
66 
67  //------------------------------------------------------------------------
68  // Update the final result do it is clear that it is a destination error
69  //------------------------------------------------------------------------
70  inline XrdCl::XRootDStatus& DestinationError( XrdCl::XRootDStatus &status )
71  {
72  std::string msg = status.GetErrorMessage();
73  msg += " (destination)";
74  status.SetErrorMessage( msg );
75  result = status;
76  return status;
77  }
78 
79  //------------------------------------------------------------------------
80  // Set the final result
81  //------------------------------------------------------------------------
82  template<typename ... Args>
83  inline XRootDStatus& SetResult( Args&&... args )
84  {
85  result = XrdCl::XRootDStatus( std::forward<Args>(args)... );
86  return result;
87  }
88 
89  //------------------------------------------------------------------------
90  // The final result
91  //------------------------------------------------------------------------
92  XRootDStatus result;
93  };
94 }
95 
96 #endif // __XRD_CL_CLASSIC_COPY_JOB_HH__
const XRootDStatus & GetResult() const
ClassicCopyJob(uint16_t jobId, PropertyList *jobProperties, PropertyList *jobResults)
virtual XRootDStatus Run(CopyProgressHandler *progress=0)
Interface for copy progress notification.
A key-value pair map storing both keys and values as strings.
void SetErrorMessage(const std::string &message)
Set the error message.
const std::string & GetErrorMessage() const
Get error message.