3#include "VaultRecordSet.h"
8 VaultOperationResult VaultRecordSet::RequestRecords(
const VaultRequestType& requestType,
const std::string& key,
const T& beginKeyValue,
9 const T& endKeyValue, VaultRecordSet& vaultRecordSet,
const bool& isIncludeBeginKeyValue,
10 const bool& isIncludeEndKeyValue,
const std::size_t& amountOfRecords,
const std::function<
bool(
const VaultRecordRef&)>& requestPredicat)
const noexcept
12 VaultOperationResult res;
14 if (GetIsParentVaultValid())
16 if (&vaultRecordSet ==
this)
18 res.IsOperationSuccess =
false;
19 res.ResultCode = VaultOperationResultCode::SameVaultRecordSetInRequest;
23 ReadLock<RecursiveReadWriteMutex> readLock(ParentVault->RecursiveReadWriteMtx);
26 if (vaultRecordSet.ParentVault != ParentVault)
28 vaultRecordSet.Reset();
31 vaultRecordSet.ParentVault = ParentVault;
34 for (
auto& keyCopierIt : VaultKeyCopiers)
35 keyCopierIt.second(&vaultRecordSet);
38 vaultRecordSet.KeysOrder = KeysOrder;
41 vaultRecordSet.UniqueKeys = UniqueKeys;
43 else vaultRecordSet.Clear();
46 ParentVault->RecordSetsSet.emplace(&vaultRecordSet);
48 res =
Vault::RequestRecords(requestType, key, beginKeyValue, endKeyValue, vaultRecordSet, isIncludeBeginKeyValue, isIncludeEndKeyValue, amountOfRecords, requestPredicat);
49 vaultRecordSet.ParentVault = ParentVault;
55 res.RequestedType =
typeid(beginKeyValue);
56 res.IsOperationSuccess =
false;
68 if (GetIsParentVaultValid())
77 res.IsOperationSuccess =
false;
89 if (GetIsParentVaultValid())
100 res.IsOperationSuccess =
false;
112 if (GetIsParentVaultValid())
118 ref.Vlt = ParentVault;
124 res.IsOperationSuccess =
false;
177 template <VaultRequestType Type>
186 res.IsOperationSuccess =
false;
187 res.ResultCode = VaultOperationResultCode::SameVaultRecordSetInRequest;
222 res.IsOperationSuccess =
false;
232 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
233 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
234 RemoveRecord<std::string>(\"Key\", \"Value\") or RemoveRecord(\"Key\", std::string(\"Value\"))");
238 if (GetIsParentVaultValid())
247 res.IsOperationSuccess =
false;
257 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
258 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
259 RemoveRecords<std::string>(\"Key\", \"Value\") or RemoveRecords(\"Key\", std::string(\"Value\"))");
263 if (GetIsParentVaultValid())
272 res.IsOperationSuccess =
false;
282 if (GetIsParentVaultValid())
Iterator class for all library maps.
Definition Map.h:18
bool EraseRecord(const VaultRecordRef &recordRefToErase) noexcept
Method for deleting a record from a Vault.
Definition Vault.cpp:593
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition Vault.hpp:641
void SortBy(const std::string &key, const F &&func, const bool &isReverse=false, const std::size_t &amountOfRecords=-1) const noexcept
Method for handle sorted records.
Definition Vault.hpp:1085
VaultOperationResult GetRecord(const std::string &key, const T &keyValue, VaultRecordRef &vaultRecordRef) const noexcept
The method for getting a reference to the data inside Vault.
Definition Vault.hpp:691
VaultOperationResult RequestRecords(const VaultRequestType &requestType, const std::string &key, const T &beginKeyValue, const T &endKeyValue, VaultRecordSet &vaultRecordSet, const bool &isIncludeBeginKeyValue, const bool &isIncludeEndKeyValue, const std::size_t &amountOfRecords, const std::function< bool(const VaultRecordRef &)> &requestPredicat) const noexcept
The method for getting the result of the request.
Definition Vault.hpp:304
VaultOperationResult GetRecords(const std::string &key, const T &keyValue, std::vector< VaultRecordRef > &recordsRefs, const std::size_t &amountOfRecords=-1) const noexcept
The method for getting a vector of references to the data inside Vault.
Definition Vault.hpp:746
VaultOperationResult Request(const VaultRequest< Type > &&request, VaultRecordSet &vaultRecordSet) const
A method for complex requests.
Definition Vault.hpp:875
std::unordered_set< VaultRecordSet * > RecordSetsSet
Unordered set with all VaultRecordSet pointers.
Definition Vault.h:112
VaultOperationResult EraseRecords(const std::string &key, const T &keyValue, const std::size_t &amountOfRecords=-1) noexcept
The method for erase records using key and value.
Definition Vault.hpp:1004
A class that provides access to data inside Vault.
Definition VaultRecordRef.h:21
A class for storing query results.
Definition VaultRecordSet.h:14
VaultOperationResult GetRecord(const std::string &key, const T &keyValue, VaultRecordRef &vaultRecordRef) const noexcept
The method for getting a reference to the data inside Vault.
Definition VaultRecordSet.hpp:85
void SortBy(const std::string &key, const F &&func, const bool &isReverse=false, const std::size_t &amountOfRecords=-1) const noexcept
Method for handle sorted records.
Definition VaultRecordSet.hpp:280
VaultOperationResult RequestLess(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
A method for getting all records that have a value less than keyValue stored by the key key.
Definition VaultRecordSet.hpp:153
VaultOperationResult RequestLessOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
A method for getting all records that have a value less than or equal to keyValue stored by the key k...
Definition VaultRecordSet.hpp:160
VaultOperationResult RequestGreaterOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
A method for getting all records that have a value greater than or equal to keyValue stored by the ke...
Definition VaultRecordSet.hpp:146
VaultOperationResult RequestGreater(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
A method for getting all records that have a value greater than keyValue stored by the key key.
Definition VaultRecordSet.hpp:139
VaultOperationResult Request(const VaultRequest< Type > &&request, VaultRecordSet &vaultRecordSet) const
A method for complex requests.
Definition VaultRecordSet.hpp:178
VaultOperationResult RequestEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
A method for getting all records that have a value equal to keyValue stored by the key key.
Definition VaultRecordSet.hpp:132
VaultOperationResult RemoveRecords(const std::string &key, const T &keyValue, const std::size_t &amountOfRecords=-1) noexcept
The method for remove records using key and value.
Definition VaultRecordSet.hpp:255
VaultOperationResult GetRecords(const std::string &key, const T &keyValue, std::vector< VaultRecordRef > &recordsRefs, const std::size_t &amountOfRecords=-1) const noexcept
The method for getting a vector of references to the data inside Vault.
Definition VaultRecordSet.hpp:108
VaultOperationResult RequestInterval(const std::string &key, const T &beginKeyValue, const T &endKeyValue, VaultRecordSet &vaultRecordSet, const bool &isIncludeBeginKeyValue=true, const bool &isIncludeEndKeyValue=true, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &requestPredicat=DefaultRequestPredicat) const
The method for getting the result of the request.
Definition VaultRecordSet.hpp:167
bool GetIsParentVaultValid() const noexcept
Method for checking the validity of the parent Vault.
Definition VaultRecordSet.cpp:119
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition VaultRecordSet.hpp:64
@ ParentVaultNotValid
This code is returned when calling VaultRecordSet operations when the parent Vault is not valid.
Structure for storing the results of MVault operations.
Definition VaultOperationResult.h:40