Skip to content

Commit 29d9a23

Browse files
author
Andrei Popescu
authored
Adapts last of the core/client classes to coding style. (#700)
Last classes and structures are now adapted to the coding style. This also changes include headers in public headers to global scope so that it can support better the pre-installed SDK. Relates-to: OLPEDGE-567 Signed-off-by: Andrei Popescu <[email protected]>
1 parent c1c821f commit 29d9a23

File tree

7 files changed

+35
-67
lines changed

7 files changed

+35
-67
lines changed

olp-cpp-sdk-core/include/olp/core/client/OlpClientFactory.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,24 +22,21 @@
2222
#include <memory>
2323
#include <string>
2424

25-
#include "OlpClientSettings.h"
26-
2725
#include <olp/core/CoreApi.h>
2826

2927
namespace olp {
30-
namespace client {
31-
class OlpClient;
32-
}
3328

3429
/**
3530
* @brief The `client` namespace.
3631
*/
3732
namespace client {
33+
class OlpClient;
34+
struct OlpClientSettings;
35+
3836
/**
3937
* @brief Creates the `OlpClient` instances that are used for every HTTP
4038
* request.
4139
*/
42-
4340
class CORE_API OlpClientFactory {
4441
public:
4542
/**
@@ -53,5 +50,4 @@ class CORE_API OlpClientFactory {
5350
};
5451

5552
} // namespace client
56-
5753
} // namespace olp

olp-cpp-sdk-core/include/olp/core/client/OlpClientSettings.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,12 +27,11 @@
2727
#include <boost/optional.hpp>
2828

2929
#include <olp/core/client/BackdownStrategy.h>
30-
#include "olp/core/client/CancellationToken.h"
31-
#include "olp/core/client/HttpResponse.h"
32-
#include "olp/core/http/Network.h"
30+
#include <olp/core/client/CancellationToken.h>
31+
#include <olp/core/client/HttpResponse.h>
32+
#include <olp/core/http/Network.h>
3333

3434
namespace olp {
35-
3635
namespace cache {
3736
class KeyValueCache;
3837
} // namespace cache
@@ -46,13 +45,13 @@ class Network;
4645
} // namespace http
4746

4847
namespace client {
49-
5048
/**
5149
* @brief The type alias of the asynchronous network callback.
5250
*
5351
* Used to receive the `HttpResponse` instance.
5452
*/
5553
using NetworkAsyncCallback = std::function<void(HttpResponse)>;
54+
5655
/**
5756
* @brief The type alias of the cancel function.
5857
*

olp-cpp-sdk-core/include/olp/core/client/TaskContext.h

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ class CORE_API TaskContext {
102102
}
103103

104104
protected:
105-
/**
106-
* @brief A helper for unordered containers.
107-
*/
105+
/// A helper for unordered containers.
108106
friend struct TaskContextHash;
109107

110108
TaskContext() = default;
@@ -170,18 +168,11 @@ class CORE_API TaskContext {
170168
template <typename T>
171169
class TaskContextImpl : public Impl {
172170
public:
173-
/**
174-
* @brief Wraps the `T` typename in the API
175-
* response.
176-
*/
171+
/// Wraps the `T` typename in the API response.
177172
using Response = client::ApiResponse<T, client::ApiError>;
178-
/**
179-
* @brief The task that produces the `Response` instance.
180-
*/
173+
/// The task that produces the `Response` instance.
181174
using ExecuteFunc = std::function<Response(client::CancellationContext)>;
182-
/**
183-
* @brief Consumes the `Response` instance.
184-
*/
175+
/// Consumes the `Response` instance.
185176
using UserCallback = std::function<void(Response)>;
186177

187178
/**
@@ -199,7 +190,7 @@ class CORE_API TaskContext {
199190
context_(std::move(context)),
200191
state_{State::PENDING} {}
201192

202-
~TaskContextImpl() {}
193+
~TaskContextImpl() override{};
203194

204195
/**
205196
* @brief Checks for the cancellation, executes the task, and calls
@@ -247,7 +238,6 @@ class CORE_API TaskContext {
247238
callback = nullptr;
248239

249240
condition_.Notify();
250-
251241
state_.store(State::COMPLETED);
252242
}
253243

@@ -292,52 +282,30 @@ class CORE_API TaskContext {
292282
* @brief Indicates the state of the request.
293283
*/
294284
enum class State {
295-
/**
296-
* @brief The request waits to be executed.
297-
*/
285+
/// The request waits to be executed.
298286
PENDING,
299-
300-
/**
301-
* @brief The request is being executed.
302-
*/
287+
/// The request is being executed.
303288
IN_PROGRESS,
304-
305-
/**
306-
* @brief The request execution finished.
307-
*/
289+
/// The request execution finished.
308290
COMPLETED
309291
};
310292

311-
/**
312-
* @brief The mutex lock used to protect from the concurrent read and write
313-
* operations.
314-
*/
293+
/// The mutex lock used to protect from the concurrent read and write
294+
/// operations.
315295
std::mutex mutex_;
316-
/**
317-
* @brief The `ExecuteFunc` instance.
318-
*/
296+
/// The `ExecuteFunc` instance.
319297
ExecuteFunc execute_func_;
320-
/**
321-
* @brief The `UserCallback` instance.
322-
*/
298+
/// The `UserCallback` instance.
323299
UserCallback callback_;
324-
/**
325-
* @brief The `CancellationContext` instance.
326-
*/
300+
/// The `CancellationContext` instance.
327301
client::CancellationContext context_;
328-
/**
329-
* @brief The `Condition` instance.
330-
*/
302+
/// The `Condition` instance.
331303
client::Condition condition_;
332-
/**
333-
* @brief The `State` enum of the atomic type.
334-
*/
304+
/// The `State` enum of the atomic type.
335305
std::atomic<State> state_;
336306
};
337307

338-
/**
339-
* @brief The `Impl` instance.
340-
*/
308+
/// The `Impl` instance.
341309
std::shared_ptr<Impl> impl_;
342310
};
343311

olp-cpp-sdk-core/src/client/OlpClientFactory.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
#include "olp/core/client/OlpClientFactory.h"
2121

2222
#include "olp/core/client/OlpClient.h"
23+
#include "olp/core/client/OlpClientSettings.h"
2324

2425
namespace olp {
2526
namespace client {
2627

2728
std::shared_ptr<OlpClient> OlpClientFactory::Create(
2829
const OlpClientSettings& settings) {
29-
auto olpClient = std::make_shared<OlpClient>();
30-
olpClient->SetSettings(settings);
31-
return olpClient;
30+
auto olp_client = std::make_shared<OlpClient>();
31+
olp_client->SetSettings(settings);
32+
return olp_client;
3233
}
3334

3435
} // namespace client

olp-cpp-sdk-core/src/client/OlpClientSettings.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <random>
2120
#include "olp/core/client/OlpClientSettings.h"
21+
22+
#include <random>
23+
2224
#include "olp/core/client/HttpResponse.h"
2325
#include "olp/core/http/HttpStatusCode.h"
2426

olp-cpp-sdk-core/src/client/PendingRequests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <olp/core/client/PendingRequests.h>
20+
#include "olp/core/client/PendingRequests.h"
21+
2122
#include <olp/core/client/TaskContext.h>
2223
#include <olp/core/logging/Log.h>
2324

olp-cpp-sdk-core/src/client/Tokenizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ struct Tokenizer {
6666
size_t pos_{0};
6767
char sep_{'\0'};
6868
};
69+
6970
} // namespace client
7071
} // namespace olp

0 commit comments

Comments
 (0)