HoverRace  2.0
BlockingTransfer.h
Go to the documentation of this file.
1 
2 // BlockingTransfer.h
3 //
4 // Copyright (c) 2009, 2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "BaseTransfer.h"
25 
26 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
27 # ifdef MR_ENGINE
28 # define MR_DllDeclare __declspec( dllexport )
29 # else
30 # define MR_DllDeclare __declspec( dllimport )
31 # endif
32 #else
33 # define MR_DllDeclare
34 #endif
35 
36 namespace HoverRace {
37 namespace Net {
38 
44 {
46  public:
47  BlockingTransfer(const Agent &agent, std::string &buf,
48  std::shared_ptr<CancelFlag> cancelFlag);
49  BlockingTransfer(const Agent &agent, std::ostream &buf,
50  std::shared_ptr<CancelFlag> cancelFlag);
51  virtual ~BlockingTransfer() { }
52  private:
53  void Init();
54 
55  public:
56  virtual bool IsComplete() const { return true; }
57 
58  public:
59  void Go();
60 
61  private:
62  static size_t StringWriteFunc(void *ptr, size_t size, size_t nmemb, void *stream);
63  static size_t StreamWriteFunc(void *ptr, size_t size, size_t nmemb, void *stream);
64  static size_t ProgressFunc(void *cancelFlag, double, double, double, double);
65 
66  private:
67  std::shared_ptr<CancelFlag> cancelFlag;
68 };
69 
70 } // namespace Net
71 } // namespace HoverRace
72 
73 #undef MR_DllDeclare
The network transfer agent (wrapper for libcurl).
Definition: Agent.h:46
This is used for the simple forms of transfer, only used in Agent::Get.
Definition: BlockingTransfer.h:43
MR_DllDeclare void Init()
Definition: ColorTools.cpp:142
#define MR_DllDeclare
Definition: BlockingTransfer.h:33
std::shared_ptr< CancelFlag > cancelFlag
Definition: BlockingTransfer.h:67
Base class for standard Agent transfers.
Definition: BaseTransfer.h:47
Definition: Announcement.h:24
virtual bool IsComplete() const
Definition: BlockingTransfer.h:56
BaseTransfer SUPER
Definition: BlockingTransfer.h:45
virtual ~BlockingTransfer()
Definition: BlockingTransfer.h:51