Skip to content

Commit 3ca6dc1

Browse files
authored
Adapt HRN, CancellationContext and Condition to coding style. (#594)
This commit adapt the above-mentioned classes the coding style, also marks the public members of HRN as deprecated and to be scoped to private by 05.2020 as it is not recommended by HERE Platform to interpret the HRN in any way. Users should only use public methods available and not care about the composition of the HRN string. Relates-to: OLPEDGE-567 Signed-off-by: Andrei Popescu <[email protected]>
1 parent c3501a4 commit 3ca6dc1

File tree

5 files changed

+187
-114
lines changed

5 files changed

+187
-114
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#include <functional>
2323
#include <memory>
2424
#include <mutex>
25-
#include "CancellationToken.h"
2625

2726
#include <olp/core/CoreApi.h>
27+
#include <olp/core/client/CancellationToken.h>
2828

2929
namespace olp {
3030
namespace client {

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919

2020
#pragma once
2121

22-
#include <olp/core/client/CancellationContext.h>
2322
#include <chrono>
2423
#include <condition_variable>
2524
#include <mutex>
2625

26+
#include <olp/core/client/CancellationContext.h>
27+
2728
namespace olp {
2829
namespace client {
2930

@@ -40,15 +41,13 @@ class Condition final {
4041
* routine.
4142
*/
4243
void Notify() {
43-
{
44-
std::unique_lock<std::mutex> lock(mutex_);
45-
signaled_ = true;
44+
std::unique_lock<std::mutex> lock(mutex_);
45+
signaled_ = true;
4646

47-
// Condition should be under the lock in order to not run into the data
48-
// race, which might occur when spurious wakeup happens in the other
49-
// thread while waiting for the condition's signal.
50-
condition_.notify_one();
51-
}
47+
// Condition should be under the lock in order to not run into the data
48+
// race, which might occur when spurious wakeup happens in the other
49+
// thread while waiting for the condition's signal.
50+
condition_.notify_one();
5251
}
5352

5453
/**

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

Lines changed: 108 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,75 +26,132 @@
2626

2727
namespace olp {
2828
namespace client {
29-
/// \brief The Here Resource Name (HRN) class, this allows HRN's to be passed to
30-
/// the operations that require it.
29+
30+
/**
31+
* @brief The Here Resource Name (HRN) class, this allows HRN's to be passed to
32+
* the operations that require it.
33+
*/
3134
class CORE_API HRN {
3235
public:
33-
/// The ServiceType enum defines the different objects that a HRN can refer to
36+
/**
37+
* @brief The ServiceType enum defines the different objects that a HRN can
38+
* refer to.
39+
*/
3440
enum ServiceType {
35-
Unknown, ///< the service type is unknown
36-
Data, ///< a data catalog
37-
Schema, ///< a schema type
38-
Pipeline ///< a pipeline instance
41+
Unknown, ///< The service type is unknown.
42+
Data, ///< This HRN represents a data catalog.
43+
Schema, ///< This HRN represents a schema type.
44+
Pipeline ///< This HRN represents a pipeline instance.
3945
};
4046

41-
/// the partition of the HRN
47+
/**
48+
* @brief Constructs a `HRN` from its string form.
49+
*
50+
* The passed string must start with "hrn:".
51+
*
52+
* @param input The `HRN` in string form.
53+
*/
54+
explicit HRN(const std::string& input);
55+
56+
/**
57+
* @brief Constructs a new instance of `HRN` from its string form.
58+
*
59+
* The passed string must start with "hrn:".
60+
*
61+
* @param input The `HRN` in string form.
62+
*
63+
* @return A new instance of `HRN` created from string.
64+
*/
65+
static HRN FromString(const std::string& input);
66+
67+
/**
68+
* @brief Constructs a unique instance of `HRN` from its string form.
69+
*
70+
* The passed string must start with "hrn:".
71+
*
72+
* @param input The `HRN` in string form.
73+
*
74+
* @return A new instance of `HRN` created from string.
75+
*/
76+
static std::unique_ptr<HRN> UniqueFromString(const std::string& input);
77+
78+
HRN() = default;
79+
80+
/**
81+
* @brief The HRN class equality operator.
82+
*/
83+
bool operator==(const HRN& rhs) const;
84+
85+
/**
86+
* @brief The HRN class inequality operator.
87+
*/
88+
bool operator!=(const HRN& rhs) const;
89+
90+
/**
91+
* @brief The HRN class bool operator.
92+
*
93+
* @return Returns true if this `HRN` instance has all service type relevant
94+
* fields not empty, false otherwise.
95+
*/
96+
explicit operator bool() const;
97+
98+
/**
99+
* @brief Checks the internal status of the `HRN` instance.
100+
*
101+
* @return Returns true if this `HRN` instance has at least one of the service
102+
* type relevant fields empty, false otherwise.
103+
*/
104+
bool IsNull() const;
105+
106+
/**
107+
* @brief Returns this `HRN` instance in its string form, prefixed with
108+
* "hrn:".
109+
*/
110+
std::string ToString() const;
111+
112+
/**
113+
* @brief Returns this `HRN` instance in its string form for catalog ID,
114+
* prefixed with "hrn:".
115+
*
116+
* @note Only relevant for when the `HRN` has ServiceType == Data.
117+
*/
118+
std::string ToCatalogHRNString() const;
119+
120+
/// The partition of the HRN, must be valid when ServiceType == Data or when
121+
/// when ServiceType == Pipeline
122+
/// @deprecated This field will be marked as private by 05.2020.
42123
std::string partition;
43-
/// the service of the HRN
124+
/// The service of the HRN.
125+
/// @deprecated This field will be marked as private by 05.2020.
44126
ServiceType service{ServiceType::Unknown};
45-
/// the region of the HRN
127+
/// The region of the HRN.
128+
/// @deprecated This field will be marked as private by 05.2020.
46129
std::string region;
47-
/// the account of the HRN
130+
/// The account of the HRN.
131+
/// @deprecated This field will be marked as private by 05.2020.
48132
std::string account;
49133

50-
/// Catalog ID, valid when HRNServiceType == Data
134+
/// The catalog ID, must be valid when ServiceType == Data.
135+
/// @deprecated This field will be marked as private by 05.2020.
51136
std::string catalogId;
52-
/// Layer ID, optional
137+
/// The layer ID, optional.
138+
/// @deprecated This field will be marked as private by 05.2020.
53139
std::string layerId;
54140

55-
/// Group ID, valid when HRNServiceType == Schema
141+
/// The group ID, must be valid when ServiceType == Schema.
142+
/// @deprecated This field will be marked as private by 05.2020.
56143
std::string groupId;
57-
/// Schema Name
144+
/// The schema name, must be valid when ServiceType == Schema.
145+
/// @deprecated This field will be marked as private by 05.2020.
58146
std::string schemaName;
59-
/// Version
147+
/// The version, must be valid when ServiceType == Schema.
148+
/// @deprecated This field will be marked as private by 05.2020.
60149
std::string version;
61150

62-
/// Pipeline ID, valid when HRNServiceType == Pipeline
151+
/// Pipeline ID, valid when ServiceType == Pipeline.
152+
/// @deprecated This field will be marked as private by 05.2020.
63153
std::string pipelineId;
64-
65-
/// \brief returns this HRN in its string form, prefixed with hrn:
66-
std::string ToString() const;
67-
68-
/// \brief returns this HRN in its string form for catalog ID, prefixed with
69-
/// hrn:
70-
std::string ToCatalogHRNString() const;
71-
72-
/// \brief default constructor
73-
HRN() = default;
74-
75-
/// \brief constructs a HRN from its string form. Must start with "hrn:".
76-
/// As a special case to support existing command line clients, http: and
77-
/// https: are also accepted
78-
explicit HRN(const std::string& input);
79-
80-
/// \brief constructs a HRN from its string form. Must start with "hrn:".
81-
/// As a special case to support existing command line clients, http: and
82-
/// https: are also accepted
83-
static HRN FromString(const std::string& input);
84-
85-
/// \brief constructs a HRN from its string form. Must start with "hrn:".
86-
/// As a special case to support existing command line clients, http: and
87-
/// https: are also accepted
88-
static std::unique_ptr<HRN> UniqueFromString(const std::string& input);
89-
90-
/// \brief The HRN class equality operator
91-
bool operator==(const HRN& other) const;
92-
93-
/// \brief The HRN class inequality operator
94-
bool operator!=(const HRN& other) const;
95-
96-
/// \brief returns true if HRN is null (all fields empty), false otherwise
97-
bool IsNull() const;
98154
};
155+
99156
} // namespace client
100157
} // namespace olp

0 commit comments

Comments
 (0)