Ice 3.7 C++98 API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClientUtil.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_PATCH2_CLIENT_UTIL_H
6 #define ICE_PATCH2_CLIENT_UTIL_H
7 
8 #include <Ice/Ice.h>
9 #include <IceUtil/Thread.h>
10 #include <IcePatch2/FileServer.h>
11 
12 #include <stdio.h>
13 
14 namespace IcePatch2
15 {
16 
17 //
18 // The IcePatch2::PatcherFeedback class is implemented by IcePatch2 clients to
19 // allow the user to interact with the patching and report progress
20 // on the patching.
21 //
22 class ICEPATCH2_API PatcherFeedback : public IceUtil::Shared
23 {
24 public:
25 
26  virtual ~PatcherFeedback();
27 
28  //
29  // The summary file can't be loaded for the given reason. This
30  // should return true to accept doing a thorough patch, false
31  // otherwise.
32  //
33  virtual bool noFileSummary(const std::string& reason) = 0;
34 
35  //
36  // If no summary file is found and/or a thorough patch was
37  // specified, the following checksum methods are called to report
38  // the progression of the checksum computation for the local data
39  // directory. These methods should return false to interrupt the
40  // checksum, false otherwise.
41  //
42  virtual bool checksumStart() = 0;
43  virtual bool checksumProgress(const std::string&) = 0;
44  virtual bool checksumEnd() = 0;
45 
46  //
47  // These methods are called to report on the progression of the
48  // computation of the list of files to patch. This involves
49  // comparing the local checksums with the server checksums. These
50  // methods should return false to interrupt the computation, false
51  // otherwise.
52  //
53  virtual bool fileListStart() = 0;
54  virtual bool fileListProgress(Ice::Int) = 0;
55  virtual bool fileListEnd() = 0;
56 
57  //
58  // These methods are called to report on the progression of the
59  // file patching. Files to be updated are downloaded from the
60  // server, uncompressed and written to the local data directory.
61  // These methods should return false to interrupt the patching,
62  // false otherwise.
63  //
64  virtual bool patchStart(const std::string&, Ice::Long, Ice::Long, Ice::Long) = 0;
65  virtual bool patchProgress(Ice::Long, Ice::Long, Ice::Long, Ice::Long) = 0;
66  virtual bool patchEnd() = 0;
67 };
68 typedef IceUtil::Handle<PatcherFeedback> PatcherFeedbackPtr;
69 
70 //
71 // IcePatch2 clients instantiate the IcePatch2::Patcher class to patch
72 // a given local data directory.
73 //
74 class ICEPATCH2_API Patcher : public IceUtil::Shared
75 {
76 public:
77 
78  virtual ~Patcher();
79 
80  //
81  // Prepare the patching. This involves creating the local checksum
82  // files if no summary file exists or if a thorough patch was
83  // specified. This method also computes the list of files to be
84  // patched. This should be called once before any call to patch().
85  //
86  // Returns true if the patch preparation was successful, false if
87  // preparation failed (for example, because a thorough patch is
88  // necessary, but the user chose not to patch thorough), or raises
89  // std::string as an exception if there was an error.
90  //
91  virtual bool prepare() = 0;
92 
93  //
94  // Patch the files from the given path.
95  //
96  // Returns true if patching was successful, false if patching was
97  // aborted by the user, or raises std::string as an exception if
98  // there was an error.
99  //
100  virtual bool patch(const std::string&) = 0;
101 
102  //
103  // Finish the patching. This needs to be called once when the
104  // patching is finished to write the local checksum files to the
105  // disk.
106  //
107  virtual void finish() = 0;
108 };
109 typedef IceUtil::Handle<Patcher> PatcherPtr;
110 
111 //
112 // IcePatch2 clients instantiate the IcePatch2::Patcher class
113 // using the patcher factory.
114 //
115 class ICEPATCH2_API PatcherFactory : public IceUtil::noncopyable
116 {
117 public:
118 
119  //
120  // Create a patcher using configuration properties. The following
121  // properties are used to configure the patcher:
122  //
123  // - IcePatch2.InstanceName
124  // - IcePatch2.Endpoints
125  // - IcePatch2.Directory
126  // - IcePatch2.Thorough
127  // - IcePatch2.ChunkSize
128  // - IcePatch2.Remove
129  //
130  // See the Ice manual for more information on these properties.
131  //
132  static PatcherPtr create(const Ice::CommunicatorPtr&, const PatcherFeedbackPtr&);
133 
134  //
135  // Create a patcher with the given parameters. These parameters
136  // are equivalent to the configuration properties described above.
137  //
138  static PatcherPtr create(const FileServerPrx&, const PatcherFeedbackPtr&, const std::string&, bool, Ice::Int, Ice::Int);
139 };
140 
141 }
142 
143 #endif
Ice::Long
IceUtil::Int64 Long
The mapping for the Slice long type.
Definition: Config.h:60
FileServer.h
Ice::CommunicatorPtr
::IceInternal::Handle< Communicator > CommunicatorPtr
Definition: Communicator.h:604
Ice.h
IceUtil::noncopyable
Definition: Config.h:313
Thread.h
IceUtil::Handle
Definition: Handle.h:143
Ice::Int
int Int
The mapping for the Slice int type.
Definition: Config.h:54
IceUtil::Shared
Definition: Shared.h:78
ICEPATCH2_API
#define ICEPATCH2_API
Definition: FileInfo.h:51