olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
PrefetchTilesRequest.h
1/*
2 * Copyright (C) 2019-2020 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 <sstream>
23#include <string>
24#include <utility>
25#include <vector>
26
27#include <olp/core/geo/tiling/TileKey.h>
28#include <olp/core/porting/optional.h>
29#include <olp/core/thread/TaskScheduler.h>
30#include <olp/dataservice/read/DataServiceReadApi.h>
31
32namespace olp {
33namespace dataservice {
34namespace read {
35
46class DATASERVICE_READ_API PrefetchTilesRequest final {
47 public:
53 const std::vector<geo::TileKey>& GetTileKeys() const { return tile_keys_; }
54
62 PrefetchTilesRequest& WithTileKeys(std::vector<geo::TileKey> tile_keys) {
63 tile_keys_ = std::move(tile_keys);
64 return *this;
65 }
66
72 unsigned int GetMinLevel() const { return min_level_; }
73
81 PrefetchTilesRequest& WithMinLevel(unsigned int min_level) {
82 min_level_ = min_level;
83 return *this;
84 }
85
91 unsigned int GetMaxLevel() const { return max_level_; }
92
100 PrefetchTilesRequest& WithMaxLevel(unsigned int max_level) {
101 max_level_ = max_level;
102 return *this;
103 }
104
115 const porting::optional<std::string>& GetBillingTag() const {
116 return billing_tag_;
117 }
118
128 template <class T = porting::optional<std::string>>
130 billing_tag_ = std::forward<T>(tag);
131 return *this;
132 }
133
148 const bool data_aggregation_enabled) {
149 data_aggregation_enabled_ = data_aggregation_enabled;
150 return *this;
151 }
152
160 bool GetDataAggregationEnabled() const { return data_aggregation_enabled_; }
161
169 uint32_t GetPriority() const { return priority_; }
170
178 PrefetchTilesRequest& WithPriority(uint32_t priority) {
179 priority_ = priority;
180 return *this;
181 }
182
190 std::string CreateKey(const std::string& layer_id) const {
191 std::stringstream out;
192 out << layer_id << "[" << GetMinLevel() << "/" << GetMaxLevel() << "]"
193 << "(" << GetTileKeys().size() << ")";
194 if (GetBillingTag()) {
195 out << "$" << *GetBillingTag();
196 }
197 return out.str();
198 }
199
200 private:
201 std::string layer_id_;
202 std::vector<geo::TileKey> tile_keys_;
203 unsigned int min_level_{geo::TileKey::LevelCount};
204 unsigned int max_level_{geo::TileKey::LevelCount};
205 porting::optional<std::string> billing_tag_;
206 bool data_aggregation_enabled_{false};
207 uint32_t priority_{thread::LOW};
208};
209
210} // namespace read
211} // namespace dataservice
212} // namespace olp
Encapsulates the fields required to prefetch the specified layers, tiles, and levels.
Definition PrefetchTilesRequest.h:46
PrefetchTilesRequest & WithTileKeys(std::vector< geo::TileKey > tile_keys)
Sets the vector of the root tile keys for the request.
Definition PrefetchTilesRequest.h:62
bool GetDataAggregationEnabled() const
Gets the data aggregation flag.
Definition PrefetchTilesRequest.h:160
PrefetchTilesRequest & WithPriority(uint32_t priority)
Sets the priority of the prefetch request.
Definition PrefetchTilesRequest.h:178
PrefetchTilesRequest & WithBillingTag(T &&tag)
Sets the billing tag for the request.
Definition PrefetchTilesRequest.h:129
PrefetchTilesRequest & WithMinLevel(unsigned int min_level)
Sets the minimum tiles level for the request.
Definition PrefetchTilesRequest.h:81
unsigned int GetMinLevel() const
Gets the minimum tiles level to prefetch.
Definition PrefetchTilesRequest.h:72
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition PrefetchTilesRequest.h:115
uint32_t GetPriority() const
Gets the request priority.
Definition PrefetchTilesRequest.h:169
unsigned int GetMaxLevel() const
Gets the maximum tiles level to prefetch.
Definition PrefetchTilesRequest.h:91
PrefetchTilesRequest & WithDataAggregationEnabled(const bool data_aggregation_enabled)
Changes the prefetch behavior when prefetching a list of tiles.
Definition PrefetchTilesRequest.h:147
std::string CreateKey(const std::string &layer_id) const
Creates a readable format for the request.
Definition PrefetchTilesRequest.h:190
const std::vector< geo::TileKey > & GetTileKeys() const
Get the vector of the root tile keys.
Definition PrefetchTilesRequest.h:53
PrefetchTilesRequest & WithMaxLevel(unsigned int max_level)
Sets the maximum tile level for the request.
Definition PrefetchTilesRequest.h:100
Rules all the other namespaces.
Definition AppleSignInProperties.h:24