SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
Object.h
1 /*
2  Copyright © CloudBackend AB 2020-2023.
3 */
4 
5 #ifndef INCLUDE_CBE_OBJECT_H_
6 #define INCLUDE_CBE_OBJECT_H_
7 
8 #include "cbe/Item.h"
9 #include "cbe/Stream.h"
10 #include "cbe/Types.h"
11 
12 #include "cbe/delegate/AclDelegate.h"
13 #include "cbe/delegate/DownloadBinaryDelegate.h"
14 #include "cbe/delegate/DownloadDelegate.h"
15 #include "cbe/delegate/GetStreamsDelegate.h"
16 #include "cbe/delegate/object/MoveDelegate.h"
17 #include "cbe/delegate/object/RemoveDelegate.h"
18 #include "cbe/delegate/object/RenameDelegate.h"
19 #include "cbe/delegate/PublishDelegate.h"
20 #include "cbe/delegate/ShareDelegate.h"
21 #include "cbe/delegate/UnPublishDelegate.h"
22 #include "cbe/delegate/UnShareDelegate.h"
23 #include "cbe/delegate/UnSubscribeDelegate.h"
24 #include "cbe/delegate/UpdateKeyValuesDelegate.h"
25 #include "cbe/delegate/UploadDelegate.h"
26 
27 #ifndef CBE_NO_SYNC
28 #include "cbe/delegate/ProgressEventFn.h"
29 #endif
30 
31 #include "cbe/delegate/Error.h"
32 #include "cbe/util/ErrorInfo.h"
33 #include "cbe/util/Exception.h"
34 #include "cbe/util/Optional.h"
35 
36 #include <string>
37 #include <vector>
38 
39 namespace CBI {
40 class Object;
41 using ObjectPtr = std::shared_ptr<CBI::Object>;
42 class ItemEventProtocol;
43 using ItemDelegatePtr = std::shared_ptr<ItemEventProtocol>;
44 class TransferDownloadEventProtocol;
45 using TransferDownloadDelegatePtr =
46  std::shared_ptr<TransferDownloadEventProtocol>;
47 class TransferUploadEventProtocol;
48 using TransferUploadDelegatePtr = std::shared_ptr<TransferUploadEventProtocol>;
49 } // namespace CBI
50 
51 namespace cbe
52 {
53 
63 class Object : public cbe::Item
64 {
65 public:
81  void move(
82  cbe::ContainerId dstId,
83  MoveDelegatePtr delegate);
84 #ifndef CBE_NO_SYNC
88  using MoveException = delegate::object::MoveDelegate::Exception;
101  cbe::ContainerId dstId);
102 
130  cbe::ContainerId dstId,
131  MoveError& error);
132 #endif // #ifndef CBE_NO_SYNC
133  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
149  void rename(
150  const std::string& name, RenameDelegatePtr delegate);
151 #ifndef CBE_NO_SYNC
155  using RenameException = delegate::object::RenameDelegate::Exception;
168  const std::string& name);
169 
197  const std::string& name,
198  RenameError& error);
199 #endif // #ifndef CBE_NO_SYNC
200  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
215  void remove(
216  RemoveDelegatePtr delegate);
217 #ifndef CBE_NO_SYNC
221  using RemoveException = delegate::object::RemoveDelegate::Exception;
236 
264  RemoveError& error);
265 #endif // #ifndef CBE_NO_SYNC
266  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
289  void download(
290  const std::string& path,
291  DownloadDelegatePtr delegate);
292 #ifndef CBE_NO_SYNC
303  using DownloadException = delegate::DownloadDelegate::Exception;
329  const std::string& path,
330  delegate::ProgressEventFn&& progressEventFn);
337  const std::string& path);
349  using DownloadError = delegate::DownloadDelegate::ErrorInfo;
372  const std::string& path,
373  delegate::ProgressEventFn&& progressEventFn,
374  DownloadError& error);
381  const std::string& path,
382  DownloadError& error);
383 #endif // #ifndef CBE_NO_SYNC
384  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
406  void download(std::size_t&& sizeLimit,
407  DownloadBinaryDelegatePtr delegate);
408 #ifndef CBE_NO_SYNC
412  using DownloadBinaryException = delegate::DownloadBinaryDelegate::Exception;
433  delegate::DownloadBinarySuccess download(std::size_t&& sizeLimit,
434  delegate::ProgressEventFn&& progressEventFn);
440  delegate::DownloadBinarySuccess download(std::size_t&& sizeLimit);
441 
451  using DownloadBinaryError = delegate::DownloadBinaryDelegate::ErrorInfo;
474  std::size_t&& sizeLimit,
475  delegate::ProgressEventFn&& progressEventFn,
476  DownloadBinaryError& error);
483  std::size_t&& sizeLimit,
484  DownloadBinaryError& error);
485 #endif // #ifndef CBE_NO_SYNC
486  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
508  const std::string& path,
509  cbe::Stream stream,
510  DownloadDelegatePtr delegate);
511 #ifndef CBE_NO_SYNC
538  const std::string& path,
539  cbe::Stream stream,
540  delegate::ProgressEventFn&& progressEventFn);
547  const std::string& path,
548  cbe::Stream stream);
579  const std::string& path,
580  cbe::Stream stream,
581  delegate::ProgressEventFn&& progressEventFn,
582  DownloadError& error);
589  const std::string& path,
590  cbe::Stream stream,
591  DownloadError& error);
592 #endif // #ifndef CBE_NO_SYNC
593  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
627  const std::string& filePath,
628  cbe::StreamId streamId,
629  UploadDelegatePtr delegate);
630 #ifndef CBE_NO_SYNC
634  using UploadException = delegate::UploadDelegate::Exception;
663  const std::string& filePath,
664  cbe::StreamId streamId,
665  delegate::ProgressEventFn&& progressEventFn);
672  const std::string& filePath,
673  cbe::StreamId streamId);
674 
684  using UploadError = delegate::UploadDelegate::ErrorInfo;
717  const std::string& filePath,
718  cbe::StreamId streamId,
719  delegate::ProgressEventFn&& progressEventFn,
720  UploadError& error);
727  const std::string& filePath,
728  cbe::StreamId streamId,
729  UploadError& error);
730 #endif // #ifndef CBE_NO_SYNC
731  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
753  UpdateKeyValuesDelegatePtr delegate);
754 
764  UpdateKeyValuesDelegatePtr delegate);
765 #ifndef CBE_NO_SYNC
769  using UpdateKeyValuesException = delegate::UpdateKeyValuesDelegate::Exception;
796 
803  using UpdateKeyValuesError = delegate::UpdateKeyValuesDelegate::ErrorInfo;
827  UpdateKeyValuesError& error);
837  UpdateKeyValuesError& error);
838 #endif // #ifndef CBE_NO_SYNC
839  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
872  GetStreamsDelegatePtr delegate);
879 #ifndef CBE_NO_SYNC
883  using GetStreamsException = delegate::GetStreamsDelegate::Exception;
907 
914  using GetStreamsError = delegate::GetStreamsDelegate::ErrorInfo;
945  GetStreamsError& error);
946 #endif // #ifndef CBE_NO_SYNC
947  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
953  std::string getMimeType() const;
954 
958  uint64_t length() const;
959 
965  cbe::object_t getObjectType() const;
966 
971  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
986  void getAcl(
987  GetAclDelegatePtr delegate);
988 #ifndef CBE_NO_SYNC
992  using GetAclException = delegate::AclDelegate::Exception;
1006  cbe::AclMap getAcl();
1007 
1014  using GetAclError = delegate::AclDelegate::ErrorInfo;
1035  GetAclError& error);
1036 #endif // #ifndef CBE_NO_SYNC
1037  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1054  void setAcl(
1056  SetAclDelegatePtr delegate);
1057 #ifndef CBE_NO_SYNC
1061  using SetAclException = delegate::AclDelegate::Exception;
1077 
1084  using SetAclError = delegate::AclDelegate::ErrorInfo;
1106  SetAclError& error);
1107 #endif // #ifndef CBE_NO_SYNC
1108  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1129  void share(
1130  cbe::UserId toUserGroup,
1131  std::string description,
1132  ShareDelegatePtr delegate);
1133 #ifndef CBE_NO_SYNC
1137  using ShareException = delegate::ShareDelegate::Exception;
1152  cbe::UserId toUserGroup,
1153  std::string description);
1160  using ShareError = delegate::ShareDelegate::ErrorInfo;
1181  cbe::UserId toUserGroup,
1182  std::string description,
1183  ShareError& error);
1184 #endif // #ifndef CBE_NO_SYNC
1185  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1207  void unShare(
1208  cbe::ShareId shareId,
1209  UnShareDelegatePtr delegate);
1210 #ifndef CBE_NO_SYNC
1214  using UnShareException = delegate::UnShareDelegate::Exception;
1229  cbe::ShareId shareId);
1230 
1237  using UnShareError = delegate::UnShareDelegate::ErrorInfo;
1258  cbe::ShareId shareId,
1259  UnShareError& error);
1260 #endif // #ifndef CBE_NO_SYNC
1261  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1282  void publish(
1283  cbe::PublishAccess security,
1284  cbe::PublishVisibility privacy,
1285  std::string description,
1286  std::string password,
1287  PublishDelegatePtr delegate);
1288 #ifndef CBE_NO_SYNC
1292  using PublishException = delegate::PublishDelegate::Exception;
1310  cbe::PublishAccess security,
1311  cbe::PublishVisibility privacy,
1312  std::string description,
1313  std::string password);
1320  using PublishError = delegate::PublishDelegate::ErrorInfo;
1344  cbe::PublishAccess security,
1345  cbe::PublishVisibility privacy,
1346  std::string description,
1347  std::string password,
1348  PublishError& error);
1349 #endif // #ifndef CBE_NO_SYNC
1350  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1368  UnPublishDelegatePtr delegate);
1369 #ifndef CBE_NO_SYNC
1373  using UnPublishException = delegate::UnPublishDelegate::Exception;
1388 
1395  using UnPublishError = delegate::UnPublishDelegate::ErrorInfo;
1416  UnPublishError& error);
1417 #endif // #ifndef CBE_NO_SYNC
1418  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1437  UnSubscribeDelegatePtr delegate);
1438 #ifndef CBE_NO_SYNC
1442  using UnSubscribeException = delegate::UnSubscribeDelegate::Exception;
1457 
1464  using UnSubscribeError = delegate::UnSubscribeDelegate::ErrorInfo;
1485  UnSubscribeError& error);
1486 #endif // #ifndef CBE_NO_SYNC
1487  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1491  std::string url();
1493 
1494 private:
1495  struct Impl;
1496  Impl& getImpl() const;
1497 
1498  friend class CloudBackend;
1499  friend class Container;
1500  Object(CBI::ObjectPtr cbiPeerPtr);
1501  CBI::Object& getCbiPeer() const;
1502 }; // class Object
1503 
1504 } // namespace cbe
1505 
1506 #endif // INCLUDE_CBE_OBJECT_H_
The session that holds the connection with the cloud.
Definition: CloudBackend.h:47
A collection of Item, can also represent a table or folder.
Definition: Container.h:63
A set made up of Container and Object.
Definition: Item.h:36
std::string path() const
AclMap aclMap() const
std::string description() const
std::string name() const
Holder of a set of data, can represent a table row.
Definition: Object.h:64
void getAcl(GetAclDelegatePtr delegate)
Returns the Access Control List for current Object.
void downloadStream(const std::string &path, cbe::Stream stream, DownloadDelegatePtr delegate)
void unSubscribe(UnSubscribeDelegatePtr delegate)
UnSubscribes from this object.
uint64_t length() const
Returns the binary length/size in bytes of current object.
void updateKeyValues(UpdateKeyValuesDelegatePtr delegate)
Deletes all key/value pairs of data to the object.
delegate::object::RenameDelegatePtr RenameDelegatePtr
Definition: Object.h:139
void download(const std::string &path, DownloadDelegatePtr delegate)
Download the data of current object to the the local file system.
delegate::AclDelegatePtr GetAclDelegatePtr
Definition: Object.h:977
delegate::UnShareDelegatePtr UnShareDelegatePtr
Definition: Object.h:1191
void unShare(cbe::ShareId shareId, UnShareDelegatePtr delegate)
Unshare the object to a specific shareId created when sharing.
void remove(RemoveDelegatePtr delegate)
Remove the object from cloud and locally.
std::string getMimeType() const
Returns the mime type of the object.
delegate::object::RemoveDelegatePtr RemoveDelegatePtr
Definition: Object.h:206
cbe::object_t getObjectType() const
Returns the Object type.
void getStreams(GetStreamsDelegatePtr delegate)
Downloads the streams meta data associated with current object to the SDK's cache.
delegate::UnPublishDelegatePtr UnPublishDelegatePtr
Definition: Object.h:1356
void rename(const std::string &name, RenameDelegatePtr delegate)
Rename object.
delegate::GetStreamsDelegatePtr GetStreamsDelegatePtr
Definition: Object.h:845
void updateKeyValues(KeyValues keyValues, UpdateKeyValuesDelegatePtr delegate)
Adds key/value pair data to the object.
std::string url()
URL to current object.
void publish(cbe::PublishAccess security, cbe::PublishVisibility privacy, std::string description, std::string password, PublishDelegatePtr delegate)
Publishes current object to any user.
void move(cbe::ContainerId dstId, MoveDelegatePtr delegate)
Relocates an object to a different container.
delegate::UploadDelegatePtr UploadDelegatePtr
Definition: Object.h:599
cbe::KeyValues keyValues()
Returns all the key/values for current object as a map.
void uploadStream(const std::string &filePath, cbe::StreamId streamId, UploadDelegatePtr delegate)
Upload a file for adding a new or replacing existing stream attached to this object.
void unPublish(UnPublishDelegatePtr delegate)
UnPublishes current object.
delegate::UnSubscribeDelegatePtr UnSubscribeDelegatePtr
Definition: Object.h:1424
delegate::UpdateKeyValuesDelegatePtr UpdateKeyValuesDelegatePtr
Definition: Object.h:737
delegate::ShareDelegatePtr ShareDelegatePtr
Definition: Object.h:1114
cbe::Streams Streams
Collection of Stream objects.
Definition: Object.h:878
delegate::DownloadBinaryDelegatePtr DownloadBinaryDelegatePtr
Definition: Object.h:390
void setAcl(cbe::AclMap aclMap, SetAclDelegatePtr delegate)
Sets the Access Control List for current object.
void share(cbe::UserId toUserGroup, std::string description, ShareDelegatePtr delegate)
Share current object to a user.
delegate::DownloadDelegatePtr DownloadDelegatePtr
Definition: Object.h:275
delegate::object::MoveDelegatePtr MoveDelegatePtr
Definition: Object.h:71
delegate::AclDelegatePtr SetAclDelegatePtr
Definition: Object.h:1043
delegate::PublishDelegatePtr PublishDelegatePtr
Definition: Object.h:1267
void download(std::size_t &&sizeLimit, DownloadBinaryDelegatePtr delegate)
Download the binary data associated with current object.
A data file attached to Object.
Definition: Stream.h:24
Convenience type that bundles all parameters passed to method cbe::delegate::DownloadBinaryDelegate::...
Definition: DownloadBinarySuccess.h:17
Convenience type that bundles all parameters passed to method cbe::delegate::DownloadDelegate::onDown...
Definition: DownloadSuccess.h:16
Convenience type that bundles the parameter passed to method cbe::delegate::ShareDelegate::onShareSuc...
Definition: PublishSuccess.h:14
Convenience type that bundles the parameter passed to method cbe::delegate::ShareDelegate::onShareSuc...
Definition: ShareDelegate.h:77
Convenience type that bundles all parameters passed to method cbe::delegate::UnPublishDelegate::onUnP...
Definition: UnPublishDelegate.h:77
Convenience type that bundles the parameter passed to method cbe::delegate::ShareDelegate::onShareSuc...
Definition: UnShareDelegate.h:73
Convenience type that bundles all parameters passed to method cbe::delegate::UnSubscribeDelegate::onU...
Definition: UnSubscribeDelegate.h:76
Convenience type that bundles all parameters passed to method cbe::delegate::object::onRemoveSuccess.
Definition: RemoveDelegate.h:75
Class template Optional manages an optional contained value - i.e., a value that is either present or...
Definition: Optional.h:20
std::shared_ptr< MoveDelegate > MoveDelegatePtr
Definition: MoveDelegate.h:64
std::shared_ptr< RenameDelegate > RenameDelegatePtr
Definition: RenameDelegate.h:64
std::shared_ptr< RemoveDelegate > RemoveDelegatePtr
Definition: RemoveDelegate.h:68
std::function< void(const ChunkTransferred &)> ProgressEventFn
Callback interface function that the CloudBackend SDK uses to indicate the progress of an upload/down...
Definition: ProgressEventFn.h:19
std::shared_ptr< GetStreamsDelegate > GetStreamsDelegatePtr
Definition: GetStreamsDelegate.h:68
std::shared_ptr< UnPublishDelegate > UnPublishDelegatePtr
Definition: UnPublishDelegate.h:70
std::shared_ptr< ShareDelegate > ShareDelegatePtr
Definition: ShareDelegate.h:70
std::shared_ptr< PublishDelegate > PublishDelegatePtr
Definition: PublishDelegate.h:66
std::shared_ptr< UpdateKeyValuesDelegate > UpdateKeyValuesDelegatePtr
Definition: UpdateKeyValuesDelegate.h:66
std::shared_ptr< AclDelegate > AclDelegatePtr
Definition: AclDelegate.h:68
std::shared_ptr< UnShareDelegate > UnShareDelegatePtr
Definition: UnShareDelegate.h:66
std::shared_ptr< UploadDelegate > UploadDelegatePtr
Definition: UploadDelegate.h:83
std::shared_ptr< DownloadBinaryDelegate > DownloadBinaryDelegatePtr
Definition: DownloadBinaryDelegate.h:87
std::shared_ptr< UnSubscribeDelegate > UnSubscribeDelegatePtr
Definition: UnSubscribeDelegate.h:69
std::shared_ptr< DownloadDelegate > DownloadDelegatePtr
Definition: DownloadDelegate.h:84
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
std::vector< cbe::Stream > Streams
Collection of Stream objects.
Definition: Stream.h:49
std::map< cbe::AclGroupId, std::pair< cbe::Permissions, AclScope > > AclMap
ACL map (Access Control List) relating to users and groups.
Definition: Types.h:390
std::uint64_t StreamId
Uniquely identifies a cbe::Stream.
Definition: Types.h:118
std::uint64_t ShareId
Uniquely identifies a sharing of a cbe::Container or cbe::Object.
Definition: Types.h:113
std::uint64_t UserId
Uniquely identifies the CBE user number.
Definition: Types.h:126
std::uint64_t ContainerId
Unique Id of a cbe::Container.
Definition: Types.h:60
DefaultCtor
Default constructor marker.
Definition: Types.h:204
PublishVisibility
Definition: Types.h:357
PublishAccess
Definition: Types.h:342
std::map< std::string, std::pair< std::string, bool > > KeyValues
Map with key/value pairs, a.k.a. metadata.
Definition: Types.h:417
Definition: AclDelegate.h:41
Definition: DownloadBinaryDelegate.h:63
Definition: DownloadDelegate.h:56
Definition: GetStreamsDelegate.h:46
Definition: PublishDelegate.h:38
Definition: ShareDelegate.h:42
Definition: UnPublishDelegate.h:42
Definition: UnShareDelegate.h:38
Definition: UnSubscribeDelegate.h:41
Definition: UpdateKeyValuesDelegate.h:42
Definition: UploadDelegate.h:57