SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
Container.h
1 /*
2  Copyright © CloudBackend AB 2020 - 2023.
3 */
4 
5 #ifndef INCLUDE_CBE_CONTAINER_H_
6 #define INCLUDE_CBE_CONTAINER_H_
7 
8 #include "cbe/Types.h"
9 #include "cbe/delegate/container/MoveDelegate.h"
10 #include "cbe/delegate/container/RenameDelegate.h"
11 #include "cbe/delegate/container/RemoveDelegate.h"
12 #include "cbe/delegate/AclDelegate.h"
13 #include "cbe/delegate/CreateContainerDelegate.h"
14 #include "cbe/delegate/CreateObjectDelegate.h"
15 #include "cbe/delegate/Error.h"
16 #include "cbe/delegate/PublishDelegate.h"
17 #include "cbe/delegate/PublishSuccess.h"
18 #include "cbe/delegate/ShareDelegate.h"
19 #include "cbe/delegate/UnPublishDelegate.h"
20 #include "cbe/delegate/UnShareDelegate.h"
21 #include "cbe/delegate/UnSubscribeDelegate.h"
22 #include "cbe/delegate/UploadDelegate.h"
23 #include "cbe/delegate/QueryDelegate.h"
24 #include "cbe/delegate/QueryJoinDelegate.h"
25 
26 #ifndef CBE_NO_SYNC
27 #include "cbe/delegate/ProgressEventFn.h"
28 #endif
29 
30 #include "cbe/util/Context.h"
31 #include "cbe/util/ErrorInfo.h"
32 #include "cbe/util/Exception.h"
33 #include "cbe/util/Optional.h"
34 
35 #include "cbe/Item.h"
36 #include "cbe/Object.h"
37 #include "cbe/Types.h"
38 
39 namespace CBI {
40 class Container;
41 using ContainerPtr = std::shared_ptr<CBI::Container>;
42 class ItemEventProtocol;
43 using ItemDelegatePtr = std::shared_ptr<ItemEventProtocol>;
44 } // namespace CBI
45 
46 namespace cbe
47 {
48 class QueryChainExt;
49 class QueryChainSync;
50 
51 namespace delegate {
52  class AclDelegate;
53  class ShareDelegate;
54  class UnShareDelegate;
55 }
56 
57 class Filter;
58 
62 class Container : public cbe::Item
63 {
64 public:
79  cbe::Container createContainer(const std::string& name,
81 #ifndef CBE_NO_SYNC
85  using CreateContainerException = delegate::CreateContainerDelegate::Exception;
100  cbe::Container createContainer(const std::string& name);
101 
108  using CreateContainerError = delegate::CreateContainerDelegate::ErrorInfo;
131  const std::string& name,
132  CreateContainerError& error);
133 #endif // #ifndef CBE_NO_SYNC
134  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
150  void move(cbe::ContainerId dstId, MoveDelegatePtr delegate);
151 
152 #ifndef CBE_NO_SYNC
156  using MoveException = delegate::container::MoveDelegate::Exception;
172 
202  cbe::ContainerId dstId,
203  MoveError& error);
204 #endif // #ifndef CBE_NO_SYNC
205  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
220  void rename(const std::string& name, RenameDelegatePtr delegate);
221 
222 #ifndef CBE_NO_SYNC
226  using RenameException = delegate::container::RenameDelegate::Exception;
241  cbe::Container rename(const std::string& name);
242 
272  RenameError& error);
273 #endif // #ifndef CBE_NO_SYNC
274  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
289  void remove(RemoveDelegatePtr delegate);
290 #ifndef CBE_NO_SYNC
294  using RemoveException = delegate::container::RemoveDelegate::Exception;
310 
340  RemoveError& error);
341 #endif // #ifndef CBE_NO_SYNC
342  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
367  cbe::KeyValues keyValues,
368  CreateObjectDelegatePtr delegate);
374  CreateObjectDelegatePtr delegate);
375 
376 #ifndef CBE_NO_SYNC
380  using CreateObjectException = delegate::CreateObjectDelegate::Exception;
395  cbe::Object createObject(std::string name,
396  cbe::KeyValues keyValues);
397 
404  using CreateObjectError = delegate::CreateObjectDelegate::ErrorInfo;
427  std::string name,
428  cbe::KeyValues keyValues,
429  CreateObjectError& error);
430 #endif // #ifndef CBE_NO_SYNC
431  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
457  cbe::Object upload(const std::string& filePath,
458  UploadDelegatePtr delegate);
459 
480  cbe::Object upload(const std::string& name,
481  const std::string& path,
482  UploadDelegatePtr delegate);
483 
493  cbe::Object upload(const std::string& name,
494  std::uint64_t length,
495  const char* byteData,
496  UploadDelegatePtr delegate);
497 #ifndef CBE_NO_SYNC
510  using UploadException = delegate::UploadDelegate::Exception;
542  const std::string& filePath,
543  delegate::ProgressEventFn&& progressEventFn);
544 
553  const std::string& filePath);
554 
573  const std::string& name,
574  const std::string& path,
575  delegate::ProgressEventFn&& progressEventFn);
585  const std::string& name,
586  const std::string& path);
587 
606  const std::string& name,
607  std::uint64_t length,
608  const char* byteData,
609  delegate::ProgressEventFn&& progressEventFn);
618  const std::string& name,
619  std::uint64_t length,
620  const char* byteData);
634  using UploadError = delegate::UploadDelegate::ErrorInfo;
635 
669  const std::string& filePath,
670  delegate::ProgressEventFn&& progressEventFn,
671  UploadError& error);
680  const std::string& filePath,
681  UploadError& error);
682 
704  const std::string& name,
705  const std::string& path,
706  delegate::ProgressEventFn&& progressEventFn,
707  UploadError& error);
717  const std::string& name,
718  const std::string& path,
719  UploadError& error);
720 
737  const std::string& name,
738  std::uint64_t length,
739  const char* byteData,
740  delegate::ProgressEventFn&& progressEventFn,
741  UploadError& error);
751  const std::string& name,
752  std::uint64_t length,
753  const char* byteData,
754  UploadError& error);
755 #endif // #ifndef CBE_NO_SYNC
756  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
781  QueryDelegatePtr delegate);
782 
788  using QueryJoinDelegatePtr = std::shared_ptr<delegate::QueryJoinDelegate>;
808 
809 #ifndef CBE_NO_SYNC
811  using QueryException = delegate::QueryDelegate::Exception;
822  cbe::QueryChainSync query();
833  cbe::QueryChainSync query(Filter filter);
834 
836  using QueryJoinError = delegate::QueryJoinDelegate::ErrorInfo;
837 
846  cbe::QueryChainSync query(QueryJoinError& error);
855  cbe::QueryChainSync query(Filter filter,
856  QueryJoinError& error);
857  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
859  using QueryError = delegate::QueryDelegate::ErrorInfo;
860 #endif // #ifndef CBE_NO_SYNC
861  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
881  cbe::QueryChain queryWithPath(std::string relativePath,
882  QueryDelegatePtr delegate);
883 #ifndef CBE_NO_SYNC
887  using queryWithPathException = delegate::QueryDelegate::Exception;
902  cbe::QueryResult queryWithPath(std::string relativePath);
903 
910  using queryWithPathError = delegate::QueryDelegate::ErrorInfo;
933  std::string relativePath,
934  queryWithPathError& error);
935 #endif // #ifndef CBE_NO_SYNC
936  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
959  cbe::QueryResult search(std::string tags, QueryDelegatePtr delegate);
960 
961 #ifndef CBE_NO_SYNC
965  using SearchException = delegate::QueryDelegate::Exception;
980  cbe::QueryResult search(std::string tags);
981 
988  using SearchError = delegate::QueryDelegate::ErrorInfo;
1011  SearchError& error);
1012 #endif // #ifndef CBE_NO_SYNC
1013  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1040 #ifndef CBE_NO_SYNC
1056 
1079  SearchError& error);
1080 #endif // #ifndef CBE_NO_SYNC
1081  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1102  SetAclDelegatePtr delegate);
1103 
1104 #ifndef CBE_NO_SYNC
1108  using SetAclException = delegate::AclDelegate::Exception;
1124 
1131  using SetAclError = delegate::AclDelegate::ErrorInfo;
1155  SetAclError& error);
1156 #endif // #ifndef CBE_NO_SYNC
1157  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1171  void getAcl(GetAclDelegatePtr delegate);
1172 
1173 #ifndef CBE_NO_SYNC
1177  using GetAclException = delegate::AclDelegate::Exception;
1192  cbe::AclMap getAcl();
1193 
1200  using GetAclError = delegate::AclDelegate::ErrorInfo;
1222  cbe::util::Optional<cbe::AclMap> getAcl(GetAclError& error);
1223 #endif // #ifndef CBE_NO_SYNC
1224  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1244  void share(cbe::UserId toUserGroup,
1245  std::string description,
1246  ShareDelegatePtr delegate);
1247 
1248 #ifndef CBE_NO_SYNC
1252  using ShareException = delegate::ShareDelegate::Exception;
1268  std::string description);
1269 
1276  using ShareError = delegate::ShareDelegate::ErrorInfo;
1299  cbe::UserId toUserGroup,
1300  std::string description,
1301  ShareError& error);
1302 #endif // #ifndef CBE_NO_SYNC
1303  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1309  using UnShareDelegatePtr = std::shared_ptr<delegate::UnShareDelegate>;
1321  void unShare(cbe::ShareId shareId, UnShareDelegatePtr delegate);
1322 
1323 #ifndef CBE_NO_SYNC
1327  using UnShareException = delegate::UnShareDelegate::Exception;
1343 
1350  using UnShareError = delegate::UnShareDelegate::ErrorInfo;
1373  cbe::ShareId shareId,
1374  UnShareError& error);
1375 #endif // #ifndef CBE_NO_SYNC
1376  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1398  cbe::PublishVisibility privacy,
1399  std::string description,
1400  std::string password,
1401  PublishDelegatePtr delegate);
1402 
1403 #ifndef CBE_NO_SYNC
1407  using PublishException = delegate::PublishDelegate::Exception;
1424  cbe::PublishVisibility privacy,
1425  std::string description,
1426  std::string password);
1427 
1435  using PublishError = delegate::PublishDelegate::ErrorInfo;
1459  cbe::PublishAccess security,
1460  cbe::PublishVisibility privacy,
1461  std::string description,
1462  std::string password,
1463  PublishError& error);
1464 #endif // #ifndef CBE_NO_SYNC
1465  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1466 
1490 #ifndef CBE_NO_SYNC
1494  using UnPublishException = delegate::UnPublishDelegate::Exception;
1510 
1517  using UnPublishError = delegate::UnPublishDelegate::ErrorInfo;
1540  UnPublishError& error);
1541 #endif // #ifndef CBE_NO_SYNC
1542  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1561 
1562 #ifndef CBE_NO_SYNC
1566  using UnSubscribeException = delegate::UnSubscribeDelegate::Exception;
1582 
1589  using UnSubscribeError = delegate::UnSubscribeDelegate::ErrorInfo;
1612  UnSubscribeError& error);
1613 #endif // #ifndef CBE_NO_SYNC
1614  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1616 private:
1617  struct Impl;
1618  Impl& getImpl() const;
1619 
1620  friend class Account;
1621  friend class CloudBackend;
1622  friend class Database;
1623  friend class Filter;
1624  friend class Group;
1625  friend class QueryChain;
1626 
1627  Container(CBI::ContainerPtr cbiPeerPtr);
1628  // CBI::Container& getCbiPeer() const;
1629  CBI::ContainerPtr getCbiPeerPtr() const;
1630 }; // class Container
1631 
1632 } // namespace cbe
1633 
1634 #endif // INCLUDE_CBE_CONTAINER_H_
Login account information.
Definition: Account.h:26
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
delegate::AclDelegatePtr GetAclDelegatePtr
Definition: Container.h:1163
delegate::AclDelegatePtr SetAclDelegatePtr
Definition: Container.h:1087
delegate::CreateObjectDelegatePtr CreateObjectDelegatePtr
Definition: Container.h:348
void getAcl(GetAclDelegatePtr delegate)
Retrieves its ACL map.
void unShare(cbe::ShareId shareId, UnShareDelegatePtr delegate)
Revoke a previous share.
cbe::QueryChainExt query(Filter filter, delegate::QueryJoinDelegatePtr delegate)
Select list of objects using filter, for join.
cbe::QueryChain query(Filter filter, QueryDelegatePtr delegate)
Select list of objects using filter.
cbe::Object upload(const std::string &name, const std::string &path, UploadDelegatePtr delegate)
Create an object in current container by uploading a file.
delegate::container::RenameDelegatePtr RenameDelegatePtr
Definition: Container.h:211
delegate::container::RemoveDelegatePtr RemoveDelegatePtr
Definition: Container.h:280
delegate::UnPublishDelegatePtr UnPublishDelegatePtr
Definition: Container.h:1472
cbe::Object createObject(std::string name, cbe::KeyValues keyValues, CreateObjectDelegatePtr delegate)
Create a new object.
void rename(const std::string &name, RenameDelegatePtr delegate)
Change the name of the container.
void unSubscribe(UnSubscribeDelegatePtr delegate)
UnSubscribes from this container.
std::shared_ptr< delegate::UnShareDelegate > UnShareDelegatePtr
Definition: Container.h:1309
void setAcl(cbe::AclMap aclMap, SetAclDelegatePtr delegate)
set ACL.
cbe::QueryResult search(cbe::Filter filter, QueryDelegatePtr delegate)
Search using filter.
delegate::ShareDelegatePtr ShareDelegatePtr
Definition: Container.h:1230
void unPublish(UnPublishDelegatePtr delegate)
UnPublishes this container.
cbe::QueryChain query(QueryDelegatePtr queryDelegate)
Select list of objects.
cbe::QueryChainExt query(delegate::QueryJoinDelegatePtr delegate)
Select list of objects, for join.
cbe::QueryResult search(std::string tags, QueryDelegatePtr delegate)
Search by tags.
cbe::Object upload(const std::string &name, std::uint64_t length, const char *byteData, UploadDelegatePtr delegate)
Upload from local memory to an object.
void remove(RemoveDelegatePtr delegate)
Delete the container.
void publish(cbe::PublishAccess security, cbe::PublishVisibility privacy, std::string description, std::string password, PublishDelegatePtr delegate)
Publishes a container and its content to any user.
delegate::container::MoveDelegatePtr MoveDelegatePtr
Definition: Container.h:140
delegate::PublishDelegatePtr PublishDelegatePtr
Definition: Container.h:1382
void share(cbe::UserId toUserGroup, std::string description, ShareDelegatePtr delegate)
Make accessible by other user.
delegate::CreateContainerDelegatePtr CreateContainerDelegatePtr
Definition: Container.h:70
cbe::Container createContainer(const std::string &name, CreateContainerDelegatePtr delegate)
Create a container.
delegate::UnSubscribeDelegatePtr UnSubscribeDelegatePtr
Definition: Container.h:1548
std::shared_ptr< delegate::QueryJoinDelegate > QueryJoinDelegatePtr
Definition: Container.h:788
delegate::UploadDelegatePtr UploadDelegatePtr
Definition: Container.h:441
cbe::Object upload(const std::string &filePath, UploadDelegatePtr delegate)
Upload object to container with file given by filePath.
cbe::QueryChain queryWithPath(std::string relativePath, QueryDelegatePtr delegate)
Select list of objects in hierarchy.
void move(cbe::ContainerId dstId, MoveDelegatePtr delegate)
Move a container to a different parent.
cbe::Object createObject(std::string name, CreateObjectDelegatePtr delegate)
delegate::QueryDelegatePtr QueryDelegatePtr
Definition: Container.h:762
A database.
Definition: Database.h:27
Use to select Item that meets specific criterias when doing a query.
Definition: Filter.h:40
A group of members.
Definition: Group.h:42
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
Extension of class QueryChain.
Definition: QueryChain.h:150
To do a search for Object combining more than one Container table.
Definition: QueryChain.h:32
resultset of data retrieved.
Definition: QueryResult.h:51
Definition: AclDelegate.h:22
Convenience type that bundles the parameter passed to method cbe::delegate::ShareDelegate::onShareSuc...
Definition: PublishSuccess.h:14
QueryDelegate::ErrorInfo ErrorInfo
Definition: QueryJoinDelegate.h:47
Definition: ShareDelegate.h:20
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
Definition: UnShareDelegate.h:20
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::container::RemoveDelegat...
Definition: RemoveDelegate.h:74
Class template Optional manages an optional contained value - i.e., a value that is either present or...
Definition: Optional.h:20
std::shared_ptr< RemoveDelegate > RemoveDelegatePtr
Definition: RemoveDelegate.h:67
std::shared_ptr< RenameDelegate > RenameDelegatePtr
Definition: RenameDelegate.h:64
std::shared_ptr< MoveDelegate > MoveDelegatePtr
Definition: MoveDelegate.h:64
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< 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< CreateContainerDelegate > CreateContainerDelegatePtr
Definition: CreateContainerDelegate.h:67
std::shared_ptr< QueryJoinDelegate > QueryJoinDelegatePtr
Definition: QueryJoinDelegate.h:76
std::shared_ptr< AclDelegate > AclDelegatePtr
Definition: AclDelegate.h:68
std::shared_ptr< QueryDelegate > QueryDelegatePtr
Definition: QueryDelegate.h:100
std::shared_ptr< CreateObjectDelegate > CreateObjectDelegatePtr
Definition: CreateObjectDelegate.h:63
std::shared_ptr< UploadDelegate > UploadDelegatePtr
Definition: UploadDelegate.h:83
std::shared_ptr< UnSubscribeDelegate > UnSubscribeDelegatePtr
Definition: UnSubscribeDelegate.h:69
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
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 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: CreateContainerDelegate.h:41
Definition: CreateObjectDelegate.h:41
Definition: PublishDelegate.h:38
Definition: QueryDelegate.h:61
Definition: ShareDelegate.h:42
Definition: UnPublishDelegate.h:42
Definition: UnShareDelegate.h:38
Definition: UnSubscribeDelegate.h:41
Definition: UploadDelegate.h:57