libqicore-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
file.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef _QICORE_FILE_HPP_
3 #define _QICORE_FILE_HPP_
4 /*
5 ** Copyright (C) 2013 Aldebaran Robotics
6 ** See COPYING for the license
7 */
8 
9 #include <iosfwd>
10 #include <cassert>
11 
12 #include <qicore/api.hpp>
13 #include <qi/anyobject.hpp>
14 #include <qi/path.hpp>
15 #include <qi/future.hpp>
16 #include <qi/buffer.hpp>
17 #include <qi/property.hpp>
18 
19 #include <boost/shared_ptr.hpp>
20 
21 namespace qi
22 {
27 {
28 protected:
30  {
31  }
32 
33 public:
35  {
36  }
37 
39  enum Status
40  {
46  };
47 
51  Property<Status> status;
52 
59  Property<double> progress;
63  virtual bool isRunning() const = 0;
64 
66  // The following operations are reserved for the implementation of the associated operations.
67 
69  virtual void _reset() = 0;
70 
72  virtual void _notifyRunning() = 0;
73 
75  virtual void _notifyFinished() = 0;
76 
78  virtual void _notifyCancelled() = 0;
79 
81  virtual void _notifyFailed() = 0;
82 
90  virtual void _notifyProgressed(double newProgress) = 0;
91 };
92 
94 typedef qi::Object<ProgressNotifier> ProgressNotifierPtr;
95 
98 
105 {
106 protected:
108  {
109  }
110 
111 public:
112  virtual ~File()
113  {
114  }
115 
117  virtual std::streamsize size() const = 0;
118 
120  virtual bool isOpen() const = 0;
121 
123  virtual bool isRemote() const = 0;
124 
130  virtual ProgressNotifierPtr operationProgress() const = 0;
131 
133  // The following operations are reserved for the implementation of file processing algorithms.
134 
136  static const std::streamsize MAX_READ_SIZE = 1000000;
137 
149  virtual Buffer _read(std::streamsize countBytesToRead) = 0;
150 
165  virtual Buffer _read(std::streamoff beginOffset, std::streamsize countBytesToRead) = 0;
166 
174  virtual bool _seek(std::streamoff offsetFromBegin) = 0;
175 
181  virtual void _close() = 0;
182 };
183 
185 typedef qi::Object<File> FilePtr;
186 
193 QICORE_API FilePtr openLocalFile(const qi::Path& localPath);
194 
200 {
201 public:
202  virtual ~FileOperation()
203  {
204  }
205 
209  virtual Future<void> start() = 0;
210 
211 private:
212 };
213 
215 typedef boost::shared_ptr<FileOperation> FileOperationPtr;
216 
224 QICORE_API FileOperationPtr prepareCopyToLocal(FilePtr file, const Path& localPath);
225 
233 QICORE_API FutureSync<void> copyToLocal(FilePtr file, const Path& localPath);
234 }
235 
236 QI_TYPE_INTERFACE(File);
237 QI_TYPE_INTERFACE(ProgressNotifier);
238 QI_TYPE_ENUM_REGISTER(ProgressNotifier::Status);
239 
240 #endif // _QI_FILE_HPP_
virtual ~File()
Definition: file.hpp:112
Property< double > progress
Definition: file.hpp:59
File()
Definition: file.hpp:107
QI_TYPE_ENUM_REGISTER(ProgressNotifier::Status)
Property< Status > status
Definition: file.hpp:51
FileOperationPtr prepareCopyToLocal(FilePtr file, const Path &localPath)
The operation has been canceled by the user.
Definition: file.hpp:45
ProgressNotifierPtr createProgressNotifier()
boost::shared_ptr< FileOperation > FileOperationPtr
Pointer to a file operation.
Definition: file.hpp:215
The operation has failed.
Definition: file.hpp:44
virtual Future< void > start()=0
The operation finished successfully.
Definition: file.hpp:43
qi::Object< ProgressNotifier > ProgressNotifierPtr
Pointer to a ProgressNotifier with shared/remote semantic.
Definition: file.hpp:94
The operation is currently running.
Definition: file.hpp:42
FutureSync< void > copyToLocal(FilePtr file, const Path &localPath)
qi::Object< File > FilePtr
Pointer to a file with shared/remote semantic.
Definition: file.hpp:185
QI_TYPE_INTERFACE(File)
virtual ~ProgressNotifier()
Definition: file.hpp:34
virtual ~FileOperation()
Definition: file.hpp:202
FilePtr openLocalFile(const qi::Path &localPath)
The operation has not start yet.
Definition: file.hpp:41
#define QICORE_API
Definition: api.hpp:14