olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
Index.h
1/*
2 * Copyright (C) 2019-2023 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <map>
23#include <memory>
24#include <string>
25#include <utility>
26
27#include <olp/core/porting/optional.h>
28#include <olp/dataservice/write/DataServiceWriteApi.h>
29
30namespace olp {
31namespace dataservice {
32namespace write {
33namespace model {
34
35typedef std::string IndexName;
36
38enum class DATASERVICE_WRITE_API IndexType {
40 String,
41
43 Int,
44
46 Bool,
47
53 Heretile,
54
61 TimeWindow,
62
64 Unsupported
65};
66
68class DATASERVICE_WRITE_API IndexValue {
69 public:
75 explicit IndexValue(IndexType type) : indexType_(type) {}
76
78 IndexValue(const IndexValue&) = default;
79
81 IndexValue(IndexValue&&) = default;
82
85
87 IndexValue& operator=(const IndexValue&) = default;
88
90 virtual ~IndexValue() = default;
91
97 IndexType getIndexType() const { return indexType_; }
98
99 private:
100 IndexType indexType_{IndexType::Unsupported};
101};
102
104class DATASERVICE_WRITE_API UnsupportedIndexValue final : public IndexValue {
105 public:
111 explicit UnsupportedIndexValue(IndexType type) : IndexValue(type) {}
112};
113
115class DATASERVICE_WRITE_API BooleanIndexValue final : public IndexValue {
116 bool booleanValue_{false};
117
118 public:
125 BooleanIndexValue(bool booleanValue, IndexType type) : IndexValue(type) {
126 booleanValue_ = std::move(booleanValue);
127 }
128
134 const bool& GetValue() const { return booleanValue_; }
135
141 bool& GetMutableValue() { return booleanValue_; }
142
148 void SetValue(const bool& value) { this->booleanValue_ = value; }
149};
150
152class DATASERVICE_WRITE_API IntIndexValue final : public IndexValue {
153 int64_t intValue_{0};
154
155 public:
162 IntIndexValue(int64_t intValue, IndexType type) : IndexValue(type) {
163 intValue_ = std::move(intValue);
164 }
165
171 const int64_t& GetValue() const { return intValue_; }
172
178 int64_t& GetMutableValue() { return intValue_; }
179
185 void SetValue(const int64_t& value) { this->intValue_ = value; }
186};
187
189class DATASERVICE_WRITE_API StringIndexValue final : public IndexValue {
190 std::string stringValue_;
191
192 public:
199 StringIndexValue(std::string stringValue, IndexType type)
200 : IndexValue(type), stringValue_{std::move(stringValue)} {}
201
207 std::string GetValue() const { return stringValue_; }
208
214 std::string& GetMutableValue() { return stringValue_; }
215
221 void SetValue(const std::string& value) { this->stringValue_ = value; }
222};
223
225class DATASERVICE_WRITE_API TimeWindowIndexValue final : public IndexValue {
226 int64_t timeWindowValue_{0};
227
228 public:
235 TimeWindowIndexValue(int64_t timeWindowValue, IndexType type)
236 : IndexValue(type), timeWindowValue_{std::move(timeWindowValue)} {}
237
243 const int64_t& GetValue() const { return timeWindowValue_; }
244
251 int64_t& GetMutableValue() { return timeWindowValue_; }
252
258 void SetValue(const int64_t& value) { this->timeWindowValue_ = value; }
259};
260
262class DATASERVICE_WRITE_API HereTileIndexValue final : public IndexValue {
263 int64_t hereTileValue_{0};
264
265 public:
272 HereTileIndexValue(int64_t hereTileValue, IndexType type)
273 : IndexValue(type), hereTileValue_{std::move(hereTileValue)} {}
274
280 const int64_t& GetValue() const { return hereTileValue_; }
281
288 int64_t& GetMutableValue() { return hereTileValue_; }
289
295 void SetValue(const int64_t& value) { this->hereTileValue_ = value; }
296};
297
299class DATASERVICE_WRITE_API EmptyIndexValue final : public IndexValue {
300 public:
306 explicit EmptyIndexValue(IndexType type) : IndexValue(type) {}
307};
308
310class DATASERVICE_WRITE_API Index final {
311 public:
313 Index() = default;
314
321 Index(std::string uuid,
322 std::map<IndexName, std::shared_ptr<IndexValue>> indexFields)
323 : id_(std::move(uuid)), indexFields_(std::move(indexFields)) {}
324
325 private:
326 porting::optional<std::string> checksum_;
327 porting::optional<std::map<std::string, std::string>> metadata_;
328 porting::optional<int64_t> size_;
329 std::string id_;
330 std::map<IndexName, std::shared_ptr<IndexValue>> indexFields_;
331
332 public:
338 const porting::optional<std::string>& GetCheckSum() const {
339 return checksum_;
340 }
341
347 porting::optional<std::string>& GetMutableCheckSum() { return checksum_; }
348
354 void SetCheckSum(const std::string& value) { this->checksum_ = value; }
355
361 const porting::optional<std::map<std::string, std::string>>& GetMetadata()
362 const {
363 return metadata_;
364 }
365
371 porting::optional<std::map<std::string, std::string>>& GetMutableMetadata() {
372 return metadata_;
373 }
374
380 void SetMetadata(const std::map<std::string, std::string>& value) {
381 this->metadata_ = value;
382 }
383
389 const std::string& GetId() const { return id_; }
390
396 std::string& GetMutableId() { return id_; }
397
403 void SetId(const std::string& value) { this->id_ = value; }
404
410 const std::map<IndexName, std::shared_ptr<IndexValue>>& GetIndexFields()
411 const {
412 return indexFields_;
413 }
414
420 std::map<IndexName, std::shared_ptr<IndexValue>>& GetMutableIndexFields() {
421 return indexFields_;
422 }
423
430 const std::map<IndexName, std::shared_ptr<IndexValue>>& value) {
431 this->indexFields_ = value;
432 }
433
439 const porting::optional<int64_t>& GetSize() const { return size_; }
440
446 porting::optional<int64_t>& GetMutableSize() { return size_; }
447
453 void SetSize(const int64_t& value) { this->size_ = value; }
454};
455
456} // namespace model
457} // namespace write
458} // namespace dataservice
459} // namespace olp
Represents the index layer of the boolean type.
Definition Index.h:115
BooleanIndexValue(bool booleanValue, IndexType type)
Creates the BooleanIndexValue instance.
Definition Index.h:125
void SetValue(const bool &value)
Sets the boolean value.
Definition Index.h:148
bool & GetMutableValue()
Gets a mutable reference to the boolean value of the index layer.
Definition Index.h:141
const bool & GetValue() const
Gets the boolean value of the index layer.
Definition Index.h:134
Represents the index layer with an empty index value.
Definition Index.h:299
EmptyIndexValue(IndexType type)
Creates the EmptyIndexValue instance.
Definition Index.h:306
Represents the index layer of the HERE tile type.
Definition Index.h:262
const int64_t & GetValue() const
Gets the HERE tile value of the index layer.
Definition Index.h:280
HereTileIndexValue(int64_t hereTileValue, IndexType type)
Creates the HereTileIndexValue instance.
Definition Index.h:272
void SetValue(const int64_t &value)
Sets the HERE tile value.
Definition Index.h:295
int64_t & GetMutableValue()
Gets a mutable reference to the HERE tile value of the index layer.
Definition Index.h:288
Represents values supported by the HERE platform index layer.
Definition Index.h:68
IndexValue & operator=(const IndexValue &)=default
A default copy assignment operator.
IndexValue(const IndexValue &)=default
A default copy constructor.
IndexValue(IndexType type)
Creates the IndexValue instance.
Definition Index.h:75
IndexValue(IndexValue &&)=default
A default move constructor.
IndexType getIndexType() const
Gets the index value type.
Definition Index.h:97
virtual ~IndexValue()=default
A default virtual destructor.
IndexValue & operator=(IndexValue &&)=default
A default move assignment operator.
Represents the index layer.
Definition Index.h:310
void SetId(const std::string &value)
Sets the index layer ID.
Definition Index.h:403
const porting::optional< std::string > & GetCheckSum() const
Gets the checksum of the index layer.
Definition Index.h:338
Index(std::string uuid, std::map< IndexName, std::shared_ptr< IndexValue > > indexFields)
Creates the Index insatnce.
Definition Index.h:321
const porting::optional< int64_t > & GetSize() const
Gets the size of the index layer.
Definition Index.h:439
Index()=default
A default constructor.
const std::string & GetId() const
Gets the index layer ID.
Definition Index.h:389
void SetCheckSum(const std::string &value)
Sets the checksum.
Definition Index.h:354
const std::map< IndexName, std::shared_ptr< IndexValue > > & GetIndexFields() const
Gets the index value type.
Definition Index.h:410
std::string & GetMutableId()
Gets a mutable reference to the index layer ID.
Definition Index.h:396
std::map< IndexName, std::shared_ptr< IndexValue > > & GetMutableIndexFields()
Gets a mutable reference to the index value type.
Definition Index.h:420
void SetSize(const int64_t &value)
Sets the size of the index layer.
Definition Index.h:453
porting::optional< std::map< std::string, std::string > > & GetMutableMetadata()
Gets a mutable reference to the metadata of the index layer.
Definition Index.h:371
porting::optional< std::string > & GetMutableCheckSum()
Gets a mutable reference to the checksum of the index layer.
Definition Index.h:347
porting::optional< int64_t > & GetMutableSize()
Gets a mutable reference to the size of the index layer.
Definition Index.h:446
const porting::optional< std::map< std::string, std::string > > & GetMetadata() const
Gets the metadata of the index layer.
Definition Index.h:361
void SetMetadata(const std::map< std::string, std::string > &value)
Sets the metadata of the index layer.
Definition Index.h:380
void SetIndexFields(const std::map< IndexName, std::shared_ptr< IndexValue > > &value)
Sets the index value type.
Definition Index.h:429
Represents the index layer of the integer type.
Definition Index.h:152
int64_t & GetMutableValue()
Gets a mutable reference to the integer value of the index layer.
Definition Index.h:178
IntIndexValue(int64_t intValue, IndexType type)
Creates the IntIndexValue instance.
Definition Index.h:162
const int64_t & GetValue() const
Gets the integer value of the index layer.
Definition Index.h:171
void SetValue(const int64_t &value)
Sets the integer value.
Definition Index.h:185
Represents the index layer of the string type.
Definition Index.h:189
std::string GetValue() const
Gets the string value of the index layer.
Definition Index.h:207
std::string & GetMutableValue()
Gets a mutable reference to the string value of the index layer.
Definition Index.h:214
void SetValue(const std::string &value)
Sets the string value.
Definition Index.h:221
StringIndexValue(std::string stringValue, IndexType type)
Creates the StringIndexValue instance.
Definition Index.h:199
Represents the index layer of the time window type.
Definition Index.h:225
void SetValue(const int64_t &value)
Sets the time window value.
Definition Index.h:258
int64_t & GetMutableValue()
Gets a mutable reference to the time window value of the index layer.
Definition Index.h:251
const int64_t & GetValue() const
Gets the time vindow value of the index layer.
Definition Index.h:243
TimeWindowIndexValue(int64_t timeWindowValue, IndexType type)
Creates the TimeWindowIndexValue instance.
Definition Index.h:235
Represents values that are not supported by the index layer.
Definition Index.h:104
UnsupportedIndexValue(IndexType type)
Creates the UnsupportedIndexValue instance.
Definition Index.h:111
Rules all the other namespaces.
Definition AppleSignInProperties.h:24