- Aldebaran documentation |
- C++ Libraries |
- index

libqicore-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
26 class QICORE_API ProgressNotifier
27 {
28 protected:
29 ProgressNotifier() = default;
30
31 public:
32 virtual ~ProgressNotifier() = default;
33
35 enum Status
36 {
37 Status_Idle,
38 Status_Running,
39 Status_Finished,
40 Status_Failed,
41 Status_Canceled,
42 };
43
47 Property<Status> status;
48
55 Property<double> progress;
59 virtual bool isRunning() const = 0;
60
61 virtual Future<void> waitForFinished() = 0;
62
64 // The following operations are reserved for the implementation of the associated operations.
65
69 virtual void reset() = 0;
70
74 virtual void notifyRunning() = 0;
75
79 virtual void notifyFinished() = 0;
80
84 virtual void notifyCanceled() = 0;
85
89 virtual void notifyFailed() = 0;
90
100 virtual void notifyProgressed(double newProgress) = 0;
101
105 QI_API_DEPRECATED_MSG(Use 'reset' instead) virtual void _reset() = 0;
106 QI_API_DEPRECATED_MSG(Use 'notifyRunning' instead) virtual void _notifyRunning() = 0;
107 QI_API_DEPRECATED_MSG(Use 'notifyFinished' instead) virtual void _notifyFinished() = 0;
108 QI_API_DEPRECATED_MSG(Use 'notifyCanceled' instead) virtual void _notifyCanceled() = 0;
109 QI_API_DEPRECATED_MSG(Use 'notifyFailed' instead) virtual void _notifyFailed() = 0;
110 QI_API_DEPRECATED_MSG(Use 'notifyProgressed' instead) virtual void _notifyProgressed(double newProgress) = 0;
111 };
112
114 using ProgressNotifierPtr = qi::Object<ProgressNotifier>;
115
120 QICORE_API ProgressNotifierPtr createProgressNotifier(Future<void> operationFuture = {});
121
127 class QICORE_API File
128 {
129 protected:
130 File() = default;
131
132 public:
133 virtual ~File() = default;
134
135
137 virtual std::streamsize size() const = 0;
138
140 virtual bool isOpen() const = 0;
141
143 virtual bool isRemote() const = 0;
144
150 virtual ProgressNotifierPtr operationProgress() const = 0;
151
153 // The following operations are reserved for the implementation of file processing algorithms.
154
156 static const std::streamsize MAX_READ_SIZE = 1000000;
157
169 virtual Buffer read(std::streamsize countBytesToRead) = 0;
170
185 virtual Buffer read(std::streamoff beginOffset, std::streamsize countBytesToRead) = 0;
186
194 virtual bool seek(std::streamoff offsetFromBegin) = 0;
195
201 virtual void close() = 0;
202
206 QI_API_DEPRECATED_MSG(Use 'read' instead) virtual Buffer _read(std::streamsize countBytesToRead) = 0;
207 QI_API_DEPRECATED_MSG(Use 'read' instead) virtual Buffer _read(std::streamoff beginOffset, std::streamsize countBytesToRead) = 0;
208 QI_API_DEPRECATED_MSG(Use 'seek' instead) virtual bool _seek(std::streamoff offsetFromBegin) = 0;
209 QI_API_DEPRECATED_MSG(Use 'close' instead) virtual void _close() = 0;
210 };
211
213 using FilePtr = qi::Object<File>;
214
221 QICORE_API FilePtr openLocalFile(const qi::Path& localPath);
222
223 }
224
225 QI_TYPE_INTERFACE(File);
226 QI_TYPE_INTERFACE(ProgressNotifier);
227 QI_TYPE_ENUM(ProgressNotifier::Status);
228
229 #include <qicore/detail/fileoperation.hxx>
230
231 #endif // _QI_FILE_HPP_
qi::ProgressNotifier::progress
Property< double > progress
Definition: file.hpp:55
qi::ProgressNotifier::status
Property< Status > status
Definition: file.hpp:47
QI_TYPE_ENUM
QI_TYPE_ENUM(ProgressNotifier::Status)
qi::File
Definition: file.hpp:127
qi::FilePtr
qi::Object< File > FilePtr
Pointer to a file with shared/remote semantic.
Definition: file.hpp:213
api.hpp
qi::ProgressNotifierPtr
qi::Object< ProgressNotifier > ProgressNotifierPtr
Pointer to a ProgressNotifier with shared/remote semantic.
Definition: file.hpp:114
qi::ProgressNotifier::Status_Canceled
The operation has been canceled by the user.
Definition: file.hpp:41
qi::ProgressNotifier::Status
Status
Definition: file.hpp:35
qi::createProgressNotifier
ProgressNotifierPtr createProgressNotifier(Future< void > operationFuture={})
qi::ProgressNotifier::Status_Failed
The operation has failed.
Definition: file.hpp:40
qi::ProgressNotifier::Status_Finished
The operation finished successfully.
Definition: file.hpp:39
qi::ProgressNotifier::Status_Running
The operation is currently running.
Definition: file.hpp:38
QI_TYPE_INTERFACE
QI_TYPE_INTERFACE(File)
qi::openLocalFile
FilePtr openLocalFile(const qi::Path &localPath)
qi::ProgressNotifier::Status_Idle
The operation has not start yet.
Definition: file.hpp:37
fileoperation.hxx
QICORE_API
#define QICORE_API
Definition: api.hpp:14
qi::ProgressNotifier
Definition: file.hpp:26