olp-cpp-sdk  1.22.0
VersionedLayerClient.h
1 /*
2  * Copyright (C) 2019-2024 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 <memory>
23 #include <string>
24 #include <vector>
25 
26 #include <olp/core/client/ApiError.h>
27 #include <olp/core/client/ApiResponse.h>
28 #include <olp/core/client/CancellationToken.h>
29 #include <olp/core/client/HRN.h>
30 #include <olp/core/client/OlpClientSettings.h>
31 #include <olp/dataservice/read/DataRequest.h>
32 #include <olp/dataservice/read/DataServiceReadApi.h>
33 #include <olp/dataservice/read/PartitionsRequest.h>
34 #include <olp/dataservice/read/PrefetchPartitionsRequest.h>
35 #include <olp/dataservice/read/PrefetchTileResult.h>
36 #include <olp/dataservice/read/PrefetchTilesRequest.h>
37 #include <olp/dataservice/read/TileRequest.h>
38 #include <olp/dataservice/read/Types.h>
39 #include <boost/optional.hpp>
40 
41 namespace olp {
42 namespace dataservice {
43 namespace read {
44 class VersionedLayerClientImpl;
45 
46 // clang-format off
97 // clang-format on
98 class DATASERVICE_READ_API VersionedLayerClient final {
99  public:
125  VersionedLayerClient(client::HRN catalog, std::string layer_id,
126  boost::optional<int64_t> catalog_version,
127  client::OlpClientSettings settings);
128 
131 
134 
137 
140 
142 
149 
170  DataResponseCallback callback);
171 
189 
213  DataResponseCallback callback);
236 
250  TileRequest request, AggregatedDataResponseCallback callback);
251 
264  TileRequest request);
265 
283  PartitionsResponseCallback callback);
284 
303  PartitionsRequest partitions_request,
304  PartitionsStreamCallback partition_stream_callback,
305  CallbackNoResult callback);
306 
324  PartitionsRequest partitions_request);
325 
343  PartitionsResponseCallback callback);
344 
371  PrefetchTilesRequest request, PrefetchTilesResponseCallback callback,
372  PrefetchStatusCallback status_callback = nullptr);
373 
399  PrefetchTilesRequest request,
400  PrefetchStatusCallback status_callback = nullptr);
401 
426  PrefetchPartitionsResponseCallback callback,
427  PrefetchPartitionsStatusCallback status_callback = nullptr);
428 
452  PrefetchPartitionsStatusCallback status_callback = nullptr);
453 
464  bool RemoveFromCache(const std::string& partition_id);
465 
476  bool RemoveFromCache(const geo::TileKey& tile);
477 
488  client::ApiNoResponse DeleteFromCache(const std::string& partition_id);
489 
501 
512  bool IsCached(const std::string& partition_id) const;
513 
526  bool IsCached(const geo::TileKey& tile, bool aggregated = false) const;
527 
551  bool Protect(const TileKeys& tiles);
552 
574  bool Protect(const std::string& partition_id);
575 
597  bool Protect(const std::vector<std::string>& partition_ids);
598 
618  bool Release(const TileKeys& tiles);
619 
639  bool Release(const std::string& partition_id);
640 
660  bool Release(const std::vector<std::string>& partition_ids);
661 
662  private:
663  std::unique_ptr<VersionedLayerClientImpl> impl_;
664 };
665 
666 } // namespace read
667 } // namespace dataservice
668 } // namespace olp
Represents a request outcome.
Definition: ApiResponse.h:65
A wrapper template that you can use to cancel a request or wait for it to finalize.
Definition: ApiResponse.h:281
Cancels service requests.
Definition: CancellationToken.h:33
Allows a Here Resource Name (HRN) to be passed to the operations that require it.
Definition: HRN.h:34
Encapsulates the fields required to request data for the given catalog, layer, and partition.
Definition: DataRequest.h:43
Encapsulates the fields required to request a list of partitions for the given catalog and layer.
Definition: PartitionsRequest.h:40
Encapsulates the fields required to prefetch a list of partitions for the given catalog and layer.
Definition: PrefetchPartitionsRequest.h:40
Encapsulates the fields required to prefetch the specified layers, tiles, and levels.
Definition: PrefetchTilesRequest.h:47
Encapsulates the fields required to request tile for the given key.
Definition: TileRequest.h:42
Gets data from a versioned layer of the HERE platform.
Definition: VersionedLayerClient.h:98
VersionedLayerClient(VersionedLayerClient &&other) noexcept
A default move constructor.
bool CancelPendingRequests()
Cancels all active and pending requests.
client::CancellationToken GetAggregatedData(TileRequest request, AggregatedDataResponseCallback callback)
Fetches data of a tile or its closest ancestor.
client::CancellableFuture< AggregatedDataResponse > GetAggregatedData(TileRequest request)
Fetches data of a tile or its closest ancestor.
VersionedLayerClient(const VersionedLayerClient &other)=delete
A copy constructor.
client::CancellationToken PrefetchTiles(PrefetchTilesRequest request, PrefetchTilesResponseCallback callback, PrefetchStatusCallback status_callback=nullptr)
Prefetches a set of tiles asynchronously.
client::CancellationToken QuadTreeIndex(TileRequest tile_request, PartitionsResponseCallback callback)
Fetches a list of partitions including data size, checksum and crc asynchronously.
bool Protect(const std::vector< std::string > &partition_ids)
Protect partitions from eviction.
client::CancellableFuture< PrefetchTilesResponse > PrefetchTiles(PrefetchTilesRequest request, PrefetchStatusCallback status_callback=nullptr)
Prefetches a set of tiles asynchronously.
client::CancellationToken GetData(DataRequest data_request, DataResponseCallback callback)
Fetches data asynchronously using a partition ID or data handle.
bool Release(const std::string &partition_id)
Removes partition from protection.
VersionedLayerClient & operator=(const VersionedLayerClient &other)=delete
A copy assignment operator.
bool Release(const std::vector< std::string > &partition_ids)
Removes partitions from protection.
bool RemoveFromCache(const std::string &partition_id)
Removes the partition from the mutable disk cache.
bool Protect(const TileKeys &tiles)
Protects tile keys from eviction.
bool IsCached(const std::string &partition_id) const
Checks whether the partition is cached.
bool RemoveFromCache(const geo::TileKey &tile)
Removes the tile from the mutable disk cache.
client::CancellationToken PrefetchPartitions(PrefetchPartitionsRequest request, PrefetchPartitionsResponseCallback callback, PrefetchPartitionsStatusCallback status_callback=nullptr)
Prefetches a set of partitions asynchronously.
client::CancellationToken GetPartitions(PartitionsRequest partitions_request, PartitionsResponseCallback callback)
Fetches a list of partitions of the given generic layer asynchronously.
bool Protect(const std::string &partition_id)
Protect partition from eviction.
client::CancellableFuture< PrefetchPartitionsResponse > PrefetchPartitions(PrefetchPartitionsRequest request, PrefetchPartitionsStatusCallback status_callback=nullptr)
Prefetches a set of partitions asynchronously.
VersionedLayerClient & operator=(VersionedLayerClient &&other) noexcept
A move assignment operator.
client::CancellationToken StreamLayerPartitions(PartitionsRequest partitions_request, PartitionsStreamCallback partition_stream_callback, CallbackNoResult callback)
Fetches a list of partitions of the given generic layer asynchronously. Client does not cache the par...
bool Release(const TileKeys &tiles)
Removes a list of tiles from protection.
client::CancellableFuture< DataResponse > GetData(DataRequest data_request)
Fetches data asynchronously using a partition ID or data handle.
client::ApiNoResponse DeleteFromCache(const std::string &partition_id)
Removes the partition from the mutable disk cache.
VersionedLayerClient(client::HRN catalog, std::string layer_id, boost::optional< int64_t > catalog_version, client::OlpClientSettings settings)
Creates the VersionedLayerClient instance with the specified catalog version.
client::CancellableFuture< DataResponse > GetData(TileRequest request)
Fetches data asynchronously using a TileKey.
client::CancellationToken GetData(TileRequest request, DataResponseCallback callback)
Fetches data asynchronously using a TileKey.
bool IsCached(const geo::TileKey &tile, bool aggregated=false) const
Checks whether the tile is cached.
client::ApiNoResponse DeleteFromCache(const geo::TileKey &tile)
Removes the tile from the mutable disk cache.
client::CancellableFuture< PartitionsResponse > GetPartitions(PartitionsRequest partitions_request)
Fetches a list of partitions of the given generic layer asynchronously.
Addresses a tile in a quadtree.
Definition: TileKey.h:63
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Configures the behavior of the OlpClient class.
Definition: OlpClientSettings.h:180