olp-cpp-sdk  1.22.0
ConsumerProperties.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 <initializer_list>
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 #include <olp/dataservice/read/DataServiceReadApi.h>
28 #include <boost/optional.hpp>
29 
30 namespace olp {
31 namespace dataservice {
32 namespace read {
33 
39 class DATASERVICE_READ_API ConsumerOption final {
40  public:
47  ConsumerOption(std::string key, std::string value)
48  : key_{std::move(key)}, value_{std::move(value)} {}
49 
56  ConsumerOption(std::string key, const char* value)
57  : key_{std::move(key)}, value_{value} {}
58 
65  ConsumerOption(std::string key, int32_t value)
66  : key_{std::move(key)}, value_{std::to_string(value)} {}
67 
74  ConsumerOption(std::string key, bool value)
75  : key_{std::move(key)}, value_{std::to_string(value)} {}
76 
82  const std::string& GetKey() const { return key_; }
88  const std::string& GetValue() const { return value_; }
89 
90  private:
91  std::string key_;
92  std::string value_;
93 };
94 
95 using ConsumerOptions = std::vector<ConsumerOption>;
96 
101 class DATASERVICE_READ_API ConsumerProperties final {
102  public:
108  explicit ConsumerProperties(ConsumerOptions properties)
109  : properties_{std::move(properties)} {}
110 
116  ConsumerProperties(std::initializer_list<ConsumerOption> properties)
117  : properties_{std::move(properties)} {}
118 
124  const ConsumerOptions& GetProperties() const { return properties_; }
125 
126  private:
127  ConsumerOptions properties_;
128 };
129 
130 } // namespace read
131 } // namespace dataservice
132 } // namespace olp
Represents a consumer configuration entry of one stream layer.
Definition: ConsumerProperties.h:39
ConsumerOption(std::string key, int32_t value)
Creates the ConsumerOption instance.
Definition: ConsumerProperties.h:65
ConsumerOption(std::string key, std::string value)
Creates the ConsumerOption instance.
Definition: ConsumerProperties.h:47
ConsumerOption(std::string key, const char *value)
Creates the ConsumerOption instance.
Definition: ConsumerProperties.h:56
const std::string & GetKey() const
Gets the key of the consumer configuration entry.
Definition: ConsumerProperties.h:82
ConsumerOption(std::string key, bool value)
Creates the ConsumerOption instance.
Definition: ConsumerProperties.h:74
const std::string & GetValue() const
Gets the value of the consumer configuration entry.
Definition: ConsumerProperties.h:88
Holds all Kafka consumer properties that should be passed to the Stream API.
Definition: ConsumerProperties.h:101
ConsumerProperties(ConsumerOptions properties)
Creates the ConsumerProperties instance.
Definition: ConsumerProperties.h:108
const ConsumerOptions & GetProperties() const
Gets the ConsumerProperties instance.
Definition: ConsumerProperties.h:124
ConsumerProperties(std::initializer_list< ConsumerOption > properties)
Creates the ConsumerProperties instance.
Definition: ConsumerProperties.h:116
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24