olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
TileRequest.h
1/*
2 * Copyright (C) 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
26#include <olp/core/geo/tiling/TileKey.h>
27#include <olp/core/porting/optional.h>
28#include <olp/core/thread/TaskScheduler.h>
29#include <olp/dataservice/read/FetchOptions.h>
30
31namespace olp {
32namespace dataservice {
33namespace read {
34
42class DATASERVICE_READ_API TileRequest final {
43 public:
54 const porting::optional<std::string>& GetBillingTag() const {
55 return billing_tag_;
56 }
57
67 template <class T = porting::optional<std::string>>
69 billing_tag_ = std::forward<T>(tag);
70 return *this;
71 }
72
81 tile_key_ = std::move(tile_key);
82 return *this;
83 }
84
90 const geo::TileKey& GetTileKey() const { return tile_key_; }
91
100 FetchOptions GetFetchOption() const { return fetch_option_; }
101
112 TileRequest& WithFetchOption(FetchOptions fetch_option) {
113 fetch_option_ = fetch_option;
114 return *this;
115 }
116
124 uint32_t GetPriority() const { return priority_; }
125
133 TileRequest& WithPriority(uint32_t priority) {
134 priority_ = priority;
135 return *this;
136 }
137
145 std::string CreateKey(const std::string& layer_id) const {
146 std::stringstream out;
147 out << layer_id << "[" << GetTileKey().ToHereTile() << "]";
148 if (GetBillingTag()) {
149 out << "$" << *GetBillingTag();
150 }
151 out << "^" << GetFetchOption();
152 return out.str();
153 }
154
155 private:
156 porting::optional<std::string> billing_tag_;
157 geo::TileKey tile_key_;
158 FetchOptions fetch_option_{OnlineIfNotFound};
159 uint32_t priority_{thread::NORMAL};
160};
161
162} // namespace read
163} // namespace dataservice
164} // namespace olp
Encapsulates the fields required to request tile for the given key.
Definition TileRequest.h:42
TileRequest & WithFetchOption(FetchOptions fetch_option)
Sets the fetch option that you can use to set the source from which data should be fetched.
Definition TileRequest.h:112
TileRequest & WithTileKey(geo::TileKey tile_key)
Sets the tile key for the request.
Definition TileRequest.h:80
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition TileRequest.h:54
TileRequest & WithPriority(uint32_t priority)
Sets the priority of the request.
Definition TileRequest.h:133
std::string CreateKey(const std::string &layer_id) const
Creates a readable format for the request.
Definition TileRequest.h:145
TileRequest & WithBillingTag(T &&tag)
Sets the billing tag for the request.
Definition TileRequest.h:68
FetchOptions GetFetchOption() const
Gets the fetch option that controls how requests are handled.
Definition TileRequest.h:100
uint32_t GetPriority() const
Gets the request priority.
Definition TileRequest.h:124
const geo::TileKey & GetTileKey() const
Gets a tile key value.
Definition TileRequest.h:90
Addresses a tile in a quadtree.
Definition TileKey.h:63
Rules all the other namespaces.
Definition AppleSignInProperties.h:24