olp-cpp-sdk  1.21.0
OlpClientSettingsFactory.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 <memory>
23 #include <string>
24 
25 #include <boost/optional.hpp>
26 
27 #include "olp/core/CoreApi.h"
28 #include "olp/core/http/Network.h"
29 #include "olp/core/http/NetworkInitializationSettings.h"
30 #include "olp/core/thread/TaskScheduler.h"
31 
32 namespace olp {
33 namespace cache {
34 class KeyValueCache;
35 struct CacheSettings;
36 } // namespace cache
37 
38 namespace client {
39 struct OlpClientSettings;
40 
45 class CORE_API OlpClientSettingsFactory final {
46  public:
56  static std::unique_ptr<thread::TaskScheduler> CreateDefaultTaskScheduler(
57  size_t thread_count = 1u);
58 
77  static std::shared_ptr<http::Network> CreateDefaultNetworkRequestHandler(
78  size_t max_requests_count = 30u);
79 
100  static std::shared_ptr<http::Network> CreateDefaultNetworkRequestHandler(
102 
117  static std::unique_ptr<cache::KeyValueCache> CreateDefaultCache(
118  cache::CacheSettings settings);
119 
137  static void PrewarmConnection(const OlpClientSettings& settings,
138  const std::string& url,
139  http::Network::Callback callback = nullptr);
140 };
141 
142 } // namespace client
143 } // namespace olp
Fills in the OlpClientSettings structure with default handlers.
Definition: OlpClientSettingsFactory.h:45
static std::unique_ptr< cache::KeyValueCache > CreateDefaultCache(cache::CacheSettings settings)
Creates the KeyValueCache instance that includes both a small memory LRU cache and a larger persisten...
static std::shared_ptr< http::Network > CreateDefaultNetworkRequestHandler(size_t max_requests_count=30u)
Creates the Network instance used for all the non-local requests.
static std::shared_ptr< http::Network > CreateDefaultNetworkRequestHandler(http::NetworkInitializationSettings settings)
Creates the Network instance used for all the non-local requests.
static void PrewarmConnection(const OlpClientSettings &settings, const std::string &url, http::Network::Callback callback=nullptr)
This function helps you prewarm the connection to the provided host.
static std::unique_ptr< thread::TaskScheduler > CreateDefaultTaskScheduler(size_t thread_count=1u)
Creates the TaskScheduler instance used for all the delayed operations.
std::function< void(NetworkResponse response)> Callback
The callback that is called when the request is processed or canceled.
Definition: Network.h:41
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Settings for memory and disk caching.
Definition: CacheSettings.h:65
Configures the behavior of the OlpClient class.
Definition: OlpClientSettings.h:180
Settings for network initialization.
Definition: NetworkInitializationSettings.h:31