Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:04:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2013
0004  * Author: Adrien Devresse <adrien.devresse@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020 */
0021 
0022 #ifndef DAVIX_COPY_HPP
0023 #define DAVIX_COPY_HPP
0024 
0025 #ifndef __DAVIX_INSIDE__
0026 #error "Only davix.h or davix.hpp should be included."
0027 #endif
0028 
0029 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0030 
0031 #include <vector>
0032 
0033 
0034 namespace Davix {
0035 
0036 struct DAVIX_EXPORT PerformanceMarker
0037 {
0038     size_t    index, count;
0039 
0040     time_t begin, latest;
0041     off_t  transferred;
0042 
0043     off_t transferAvg;
0044     off_t transferInstant;
0045 
0046     PerformanceMarker();
0047 };
0048 
0049 enum IPtype {undefined=0, IPv4=4, IPv6=6};
0050 
0051 struct DAVIX_EXPORT PerformanceData
0052 {
0053     time_t begin, latest;
0054 
0055     enum IPtype ipflag;
0056 
0057     std::vector<PerformanceMarker> markers;
0058 
0059     PerformanceData();
0060     ~PerformanceData();
0061 
0062     void update(const PerformanceMarker& in);
0063 
0064     time_t absElapsed() const;
0065 
0066     off_t avgTransfer(void) const;
0067 
0068     off_t diffTransfer() const;
0069 
0070     off_t totalTransferred() const;
0071 };
0072 
0073 
0074 
0075 class DAVIX_EXPORT DavixCopy
0076 {
0077 public:
0078     DavixCopy(Context & c, const RequestParams *params);
0079     virtual ~DavixCopy();
0080 
0081     void copy(const Uri &source, const Uri &destination, unsigned nstreams, DavixError **error);
0082 
0083     // Callbacks
0084     typedef void (*PerformanceCallback)(const PerformanceData& perfData, void* data);
0085     typedef bool (*CancellationCallback)(void* data);
0086 
0087     void setPerformanceCallback(PerformanceCallback callback, void *udata);
0088     void setCancellationCallback(CancellationCallback callback, void *udata);
0089 
0090     std::string getTransferSourceHost() const;
0091     std::string getTransferDestinationHost() const;
0092 
0093 private:
0094     class DavixCopyInternal *d_ptr;
0095 
0096     DavixCopy(const DavixCopy&);
0097     DavixCopy& operator = (const DavixCopy&);
0098 };
0099 
0100 }
0101 
0102 #endif
0103 
0104 #endif // DAVIX_COPY_HPP