Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jamal Dahbur
libcloudstorage
Commits
86c03fa5
Commit
86c03fa5
authored
Feb 14, 2018
by
Paweł Wegner
Browse files
IRequest: introduced IGenericCallback.
parent
ccdf9f62
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/IItem.h
View file @
86c03fa5
...
...
@@ -27,6 +27,7 @@
#include
<chrono>
#include
<memory>
#include
<string>
#include
<vector>
namespace
cloudstorage
{
...
...
@@ -34,6 +35,7 @@ class IItem {
public:
using
Pointer
=
std
::
shared_ptr
<
IItem
>
;
using
TimeStamp
=
std
::
chrono
::
system_clock
::
time_point
;
using
List
=
std
::
vector
<
IItem
::
Pointer
>
;
static
constexpr
size_t
UnknownSize
=
-
1
;
static
const
TimeStamp
UnknownTimeStamp
;
...
...
src/IRequest.h
View file @
86c03fa5
...
...
@@ -48,7 +48,7 @@ struct GeneralData {
};
struct
PageData
{
std
::
vector
<
IItem
::
Pointer
>
items_
;
IItem
::
List
items_
;
std
::
string
next_token_
;
// empty if no next page
};
...
...
@@ -99,11 +99,20 @@ class IRequest : public IGenericRequest {
virtual
ReturnValue
result
()
=
0
;
};
class
IListDirectoryCallback
{
template
<
class
...
Arguments
>
class
IGenericCallback
{
public:
using
Pointer
=
std
::
shared_ptr
<
IListDirectoryCallback
>
;
using
Pointer
=
std
::
shared_ptr
<
IGenericCallback
>
;
virtual
~
IGenericCallback
()
=
default
;
virtual
~
IListDirectoryCallback
()
=
default
;
virtual
void
done
(
Arguments
...
args
)
=
0
;
};
class
IListDirectoryCallback
:
public
IGenericCallback
<
EitherError
<
IItem
::
List
>>
{
public:
using
Pointer
=
std
::
shared_ptr
<
IListDirectoryCallback
>
;
/**
* Called when directory's child was fetched.
...
...
@@ -111,21 +120,12 @@ class IListDirectoryCallback {
* @param item fetched item
*/
virtual
void
receivedItem
(
IItem
::
Pointer
item
)
=
0
;
/**
* Called when the request was successfully finished.
*
* @param result contains all retrieved children
*/
virtual
void
done
(
EitherError
<
std
::
vector
<
IItem
::
Pointer
>>
)
=
0
;
};
class
IDownloadFileCallback
{
class
IDownloadFileCallback
:
public
IGenericCallback
<
EitherError
<
void
>>
{
public:
using
Pointer
=
std
::
shared_ptr
<
IDownloadFileCallback
>
;
virtual
~
IDownloadFileCallback
()
=
default
;
/**
* Called when received a part of file.
*
...
...
@@ -134,11 +134,6 @@ class IDownloadFileCallback {
*/
virtual
void
receivedData
(
const
char
*
data
,
uint32_t
length
)
=
0
;
/**
* Called when the download has finished.
*/
virtual
void
done
(
EitherError
<
void
>
)
=
0
;
/**
* Called when progress has changed.
*
...
...
@@ -148,12 +143,10 @@ class IDownloadFileCallback {
virtual
void
progress
(
uint64_t
total
,
uint64_t
now
)
=
0
;
};
class
IUploadFileCallback
{
class
IUploadFileCallback
:
public
IGenericCallback
<
EitherError
<
IItem
>>
{
public:
using
Pointer
=
std
::
shared_ptr
<
IUploadFileCallback
>
;
virtual
~
IUploadFileCallback
()
=
default
;
/**
* Called when upload starts, can be also called when retransmission is
* required due to network issues.
...
...
@@ -174,11 +167,6 @@ class IUploadFileCallback {
*/
virtual
uint64_t
size
()
=
0
;
/**
* Called when the upload is finished sucessfully.
*/
virtual
void
done
(
EitherError
<
IItem
>
)
=
0
;
/**
* Called when upload progress changed.
*
...
...
@@ -233,8 +221,7 @@ using CreateDirectoryCallback = std::function<void(EitherError<IItem>)>;
using
MoveItemCallback
=
std
::
function
<
void
(
EitherError
<
IItem
>
)
>
;
using
RenameItemCallback
=
std
::
function
<
void
(
EitherError
<
IItem
>
)
>
;
using
ListDirectoryPageCallback
=
std
::
function
<
void
(
EitherError
<
PageData
>
)
>
;
using
ListDirectoryCallback
=
std
::
function
<
void
(
EitherError
<
std
::
vector
<
IItem
::
Pointer
>>
)
>
;
using
ListDirectoryCallback
=
std
::
function
<
void
(
EitherError
<
IItem
::
List
>
)
>
;
using
DownloadFileCallback
=
std
::
function
<
void
(
EitherError
<
void
>
)
>
;
using
UploadFileCallback
=
std
::
function
<
void
(
EitherError
<
IItem
>
)
>
;
using
GetThumbnailCallback
=
std
::
function
<
void
(
EitherError
<
void
>
)
>
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment