Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
ObjectCollection.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Database_Document_ObjectCollection_h_
5#define _Stroika_Foundation_Database_Document_ObjectCollection_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
11
12/**
13 * \file
14 *
15 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
16 */
17
18namespace Stroika::Foundation::Database::Document::ObjectCollection {
19
20 using namespace Database::Document::Collection;
21 using DataExchange::ObjectVariantMapper;
22
23 /**
24 * Provide an API similar to Database::Document::Collection::Ptr, but using an ObjectVariantMapper
25 * to do IO with the higher level objects directly.
26 */
27 template <typename T>
29 private:
31
32 public:
33 /**
34 */
35 Ptr (const Ptr& src) = default;
36 Ptr (Ptr&& src) noexcept = default;
37 Ptr () noexcept = default;
38 Ptr (const Database::Document::Collection::Ptr& underlyingCollection, const ObjectVariantMapper& mapper);
39 using inherited::inherited;
40
41 public:
42 ~Ptr () = default;
43
44 public:
45 /**
46 */
47 nonvirtual Ptr& operator= (const Ptr& src) = default;
48 nonvirtual Ptr& operator= (Ptr&& src) noexcept = default;
49
50 public:
51 /**
52 * returns ID
53 */
54 using inherited::Add;
55 nonvirtual String Add (const T& v);
56
57 public:
58 /**
59 */
60 nonvirtual optional<T> GetOne (const IDType& id, const optional<Projection>& projection = {});
61
62 public:
63 /**
64 */
65 nonvirtual T GetOneOrThrow (const IDType& id, const optional<Projection>& projection = {});
66
67 public:
68 /**
69 */
70 nonvirtual Sequence<T> GetAll (const optional<Filter>& filter = {}, const optional<Projection>& projection = {});
71
72 public:
73 /**
74 */
75 using inherited::Replace;
76 nonvirtual void Replace (const T& newV);
77 nonvirtual void Replace (const IDType& id, const T& newV);
78
79 public:
80 /**
81 */
82 using inherited::Update;
83 nonvirtual void Update (const T& newV, const Set<String>& onlyTheseFields);
84 nonvirtual void Update (const IDType& id, const T& newV, const Set<String>& onlyTheseFields);
85
86 private:
87 ObjectVariantMapper fMapper_;
88 };
89
90 /**
91 */
92 template <typename T>
93 Ptr<T> New (const Database::Document::Collection::Ptr& underlyingCollection, const ObjectVariantMapper& mapper);
94
95}
96
97/*
98 ********************************************************************************
99 ***************************** Implementation Details ***************************
100 ********************************************************************************
101 */
102#include "ObjectCollection.inl"
103
104#endif /*_Stroika_Foundation_Database_Document_ObjectCollection_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Set<T> is a container of T, where once an item is added, additionally adds () do nothing.
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
nonvirtual void Update(const Document &newV)
Update the document named by 'id' - just updating fields in newV (all or ones given in argument onlyT...
nonvirtual Sequence< Document > GetAll(const optional< Filter > &filter={}, const optional< Projection > &projection={})
nonvirtual void Replace(const Document &newV)
except for issues of timing, equivalent to remove, and then add newV using id
nonvirtual optional< Document > GetOne(const IDType &id, const optional< Projection > &projection={})