1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
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 * \author Dianzhang.Chen
17 * \date Mar 2021
18 * \brief Interface of lsn context format
19 */
20
21#pragma once
22
23#include "common_types.h"
24
25namespace proxima {
26namespace be {
27namespace repository {
28
29/*! Lsn Context Format
30 */
31class LsnContextFormat {
32 public:
33 //! Constructor
34 LsnContextFormat() = default;
35
36 //! Constructor
37 LsnContextFormat(const std::string &name, uint64_t pos, uint64_t id,
38 const ScanMode &scan_mode)
39 : file_name_(name), position_(pos), seq_id_(id), mode_(scan_mode) {}
40
41 //! Destructor
42 ~LsnContextFormat() = default;
43
44 //! Copy constructor
45 LsnContextFormat(const LsnContextFormat &);
46
47 //! Assignment constructor
48 LsnContextFormat &operator=(const LsnContextFormat &);
49
50 //! Parse lsn context from string
51 int parse_from_string(const std::string &lsn_context);
52
53 //! Convert lsn context store to string
54 std::string convert_to_string() const;
55
56 //! Get binlog file name
57 const std::string &file_name() const;
58
59 //! Get binlog position
60 uint64_t position() const;
61
62 //! Get sequence id
63 uint64_t seq_id() const;
64
65 //! Get scan mode
66 const ScanMode &mode() const;
67
68 private:
69 std::string file_name_{};
70 uint64_t position_{0};
71 uint64_t seq_id_{0};
72 ScanMode mode_{ScanMode::FULL};
73};
74
75} // end namespace repository
76} // namespace be
77} // end namespace proxima
78