olp-cpp-sdk  1.22.0
Messages.h
1 /*
2  * Copyright (C) 2020-2021 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 <string>
23 #include <vector>
24 #include <utility>
25 
26 #include <boost/optional.hpp>
27 
28 #include <olp/dataservice/read/DataServiceReadApi.h>
29 #include <olp/dataservice/read/model/Data.h>
30 #include <olp/dataservice/read/model/StreamOffsets.h>
31 
32 namespace olp {
33 namespace dataservice {
34 namespace read {
35 namespace model {
36 
40 class DATASERVICE_READ_API Metadata final {
41  public:
51  const std::string& GetPartition() const { return partition_; }
57  void SetPartition(std::string value) { partition_ = std::move(value); }
58 
69  const boost::optional<std::string>& GetChecksum() const { return checksum_; }
77  void SetChecksum(boost::optional<std::string> value) {
78  checksum_ = std::move(value);
79  }
80 
90  const boost::optional<int64_t>& GetCompressedDataSize() const {
91  return compressed_data_size_;
92  }
101  void SetCompressedDataSize(boost::optional<int64_t> value) {
102  compressed_data_size_ = value;
103  }
104 
115  const boost::optional<int64_t>& GetDataSize() const { return data_size_; }
123  void SetDataSize(boost::optional<int64_t> value) { data_size_ = value; }
124 
134  const Data& GetData() const { return data_; }
140  void SetData(Data value) { data_ = std::move(value); }
141 
156  const boost::optional<std::string>& GetDataHandle() const {
157  return data_handle_;
158  }
159 
167  void SetDataHandle(boost::optional<std::string> value) {
168  data_handle_ = std::move(value);
169  }
170 
179  const boost::optional<int64_t>& GetTimestamp() const { return timestamp_; }
187  void SetTimestamp(boost::optional<int64_t> value) { timestamp_ = value; }
188 
189  private:
190  Data data_;
191  std::string partition_;
192  boost::optional<int64_t> compressed_data_size_;
193  boost::optional<int64_t> data_size_;
194  boost::optional<int64_t> timestamp_;
195  boost::optional<std::string> checksum_;
196  boost::optional<std::string> data_handle_;
197 };
198 
202 class DATASERVICE_READ_API Message final {
203  public:
209  const Metadata& GetMetaData() const { return meta_data_; }
215  void SetMetaData(Metadata value) { meta_data_ = std::move(value); }
216 
222  const StreamOffset& GetOffset() const { return offset_; }
228  void SetOffset(StreamOffset value) { offset_ = std::move(value); }
229 
235  const Data& GetData() const { return meta_data_.GetData(); }
236 
237  private:
238  Metadata meta_data_;
239  StreamOffset offset_;
240 };
241 
245 class DATASERVICE_READ_API Messages final {
246  public:
252  const std::vector<Message>& GetMessages() const { return messages_; }
258  void SetMessages(std::vector<Message> value) { messages_ = std::move(value); }
259 
260  private:
261  std::vector<Message> messages_;
262 };
263 
264 } // namespace model
265 } // namespace read
266 } // namespace dataservice
267 } // namespace olp
Represents a message read from a stream layer.
Definition: Messages.h:202
const Data & GetData() const
Gets the actual content of this message.
Definition: Messages.h:235
void SetMetaData(Metadata value)
Sets the Metadata instance of this message.
Definition: Messages.h:215
const StreamOffset & GetOffset() const
Gets the offset in a specific partition of the stream layer.
Definition: Messages.h:222
const Metadata & GetMetaData() const
Gets the Metadata instance of this message.
Definition: Messages.h:209
void SetOffset(StreamOffset value)
Sets the StreamOffset instance of this message.
Definition: Messages.h:228
Represents a vector of messages consumed from a stream layer.
Definition: Messages.h:245
const std::vector< Message > & GetMessages() const
Gets the vector of messages.
Definition: Messages.h:252
void SetMessages(std::vector< Message > value)
Sets the vector of messages.
Definition: Messages.h:258
Encapsulates information about actual data content.
Definition: Messages.h:40
void SetDataSize(boost::optional< int64_t > value)
(Optional) Sets the nominal size of the content.
Definition: Messages.h:123
void SetTimestamp(boost::optional< int64_t > value)
(Optional) Sets the timestamp of the content.
Definition: Messages.h:187
const std::string & GetPartition() const
Gets the partition of this metadata.
Definition: Messages.h:51
void SetCompressedDataSize(boost::optional< int64_t > value)
(Optional) Sets the compressed size of the content.
Definition: Messages.h:101
void SetData(Data value)
Sets the data of this content.
Definition: Messages.h:140
void SetPartition(std::string value)
Sets the partition ID of this metadata content.
Definition: Messages.h:57
void SetDataHandle(boost::optional< std::string > value)
(Optional) Sets the data handle of this content.
Definition: Messages.h:167
const boost::optional< std::string > & GetChecksum() const
(Optional) Gets the checksum of this metadata.
Definition: Messages.h:69
const boost::optional< std::string > & GetDataHandle() const
(Optional) Gets the data handle created when the content was uploaded.
Definition: Messages.h:156
const boost::optional< int64_t > & GetCompressedDataSize() const
(Optional) Gets the compressed size of the content (in bytes).
Definition: Messages.h:90
const boost::optional< int64_t > & GetDataSize() const
(Optional) Gets the nominal size (in bytes) of the content.
Definition: Messages.h:115
void SetChecksum(boost::optional< std::string > value)
(Optional) Sets the checksum of this metadata content.
Definition: Messages.h:77
const boost::optional< int64_t > & GetTimestamp() const
(Optional) Get the timestamp of the content.
Definition: Messages.h:179
const Data & GetData() const
Gets the data of this Metadata instance.
Definition: Messages.h:134
An offset in a specific partition of a stream layer.
Definition: StreamOffsets.h:35
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24