olp-cpp-sdk  1.22.0
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/deprecated.h>
29 #include <olp/core/thread/TaskScheduler.h>
30 #include <olp/dataservice/read/DataServiceReadApi.h>
31 #include <boost/optional.hpp>
32 
33 namespace olp {
34 namespace dataservice {
35 namespace read {
36 
47 class DATASERVICE_READ_API PrefetchTilesRequest final {
48  public:
54  inline const std::vector<geo::TileKey>& GetTileKeys() const {
55  return tile_keys_;
56  }
57 
66  std::vector<geo::TileKey> tile_keys) {
67  tile_keys_ = std::move(tile_keys);
68  return *this;
69  }
70 
76  inline unsigned int GetMinLevel() const { return min_level_; }
77 
85  inline PrefetchTilesRequest& WithMinLevel(unsigned int min_level) {
86  min_level_ = min_level;
87  return *this;
88  }
89 
95  inline unsigned int GetMaxLevel() const { return max_level_; }
96 
104  inline PrefetchTilesRequest& WithMaxLevel(unsigned int max_level) {
105  max_level_ = max_level;
106  return *this;
107  }
108 
119  inline const boost::optional<std::string>& GetBillingTag() const {
120  return billing_tag_;
121  }
122 
133  boost::optional<std::string> tag) {
134  billing_tag_ = std::move(tag);
135  return *this;
136  }
137 
148  inline PrefetchTilesRequest& WithBillingTag(std::string&& tag) {
149  billing_tag_ = std::move(tag);
150  return *this;
151  }
152 
167  bool data_aggregation_enabled) {
168  data_aggregation_enabled_ = data_aggregation_enabled;
169  return *this;
170  }
171 
179  inline bool GetDataAggregationEnabled() const {
180  return data_aggregation_enabled_;
181  }
182 
190  inline uint32_t GetPriority() const { return priority_; }
191 
199  inline PrefetchTilesRequest& WithPriority(uint32_t priority) {
200  priority_ = priority;
201  return *this;
202  }
203 
211  inline std::string CreateKey(const std::string& layer_id) const {
212  std::stringstream out;
213  out << layer_id << "[" << GetMinLevel() << "/" << GetMaxLevel() << "]"
214  << "(" << GetTileKeys().size() << ")";
215  if (GetBillingTag()) {
216  out << "$" << GetBillingTag().get();
217  }
218  return out.str();
219  }
220 
221  private:
222  std::string layer_id_;
223  std::vector<geo::TileKey> tile_keys_;
224  unsigned int min_level_{geo::TileKey::LevelCount};
225  unsigned int max_level_{geo::TileKey::LevelCount};
226  boost::optional<std::string> billing_tag_;
227  bool data_aggregation_enabled_{false};
228  uint32_t priority_{thread::LOW};
229 };
230 
231 } // namespace read
232 } // namespace dataservice
233 } // namespace olp
Encapsulates the fields required to prefetch the specified layers, tiles, and levels.
Definition: PrefetchTilesRequest.h:47
bool GetDataAggregationEnabled() const
Gets the data aggregation flag.
Definition: PrefetchTilesRequest.h:179
PrefetchTilesRequest & WithBillingTag(std::string &&tag)
Sets the billing tag for the request.
Definition: PrefetchTilesRequest.h:148
PrefetchTilesRequest & WithDataAggregationEnabled(bool data_aggregation_enabled)
Changes the prefetch behavior when prefetching a list of tiles.
Definition: PrefetchTilesRequest.h:166
PrefetchTilesRequest & WithPriority(uint32_t priority)
Sets the priority of the prefetch request.
Definition: PrefetchTilesRequest.h:199
unsigned int GetMinLevel() const
Gets the minimum tiles level to prefetch.
Definition: PrefetchTilesRequest.h:76
uint32_t GetPriority() const
Gets the request priority.
Definition: PrefetchTilesRequest.h:190
PrefetchTilesRequest & WithBillingTag(boost::optional< std::string > tag)
Sets the billing tag for the request.
Definition: PrefetchTilesRequest.h:132
unsigned int GetMaxLevel() const
Gets the maximum tiles level to prefetch.
Definition: PrefetchTilesRequest.h:95
PrefetchTilesRequest & WithMaxLevel(unsigned int max_level)
Sets the maximum tile level for the request.
Definition: PrefetchTilesRequest.h:104
PrefetchTilesRequest & WithMinLevel(unsigned int min_level)
Sets the minimum tiles level for the request.
Definition: PrefetchTilesRequest.h:85
std::string CreateKey(const std::string &layer_id) const
Creates a readable format for the request.
Definition: PrefetchTilesRequest.h:211
const boost::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition: PrefetchTilesRequest.h:119
const std::vector< geo::TileKey > & GetTileKeys() const
Get the vector of the root tile keys.
Definition: PrefetchTilesRequest.h:54
PrefetchTilesRequest & WithTileKeys(std::vector< geo::TileKey > tile_keys)
Sets the vector of the root tile keys for the request.
Definition: PrefetchTilesRequest.h:65
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24