common.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2024, The University of Memphis
4  *
5  * This file is part of PSync.
6  * See AUTHORS.md for complete list of PSync authors and contributors.
7  *
8  * PSync is free software: you can redistribute it and/or modify it under the terms
9  * of the GNU Lesser General Public License as published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option) any later version.
11  *
12  * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE. See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PSYNC_COMMON_HPP
21 #define PSYNC_COMMON_HPP
22 
23 #include "PSync/detail/config.hpp"
24 
25 #include <ndn-cxx/name.hpp>
26 #include <ndn-cxx/util/time.hpp>
27 
28 #include <cstddef>
29 #include <cstdint>
30 #include <functional>
31 #include <stdexcept>
32 #include <vector>
33 
34 namespace psync {
35 
36 using namespace ndn::time_literals;
37 
38 inline constexpr ndn::time::milliseconds HELLO_INTEREST_LIFETIME = 1_s;
39 inline constexpr ndn::time::milliseconds HELLO_REPLY_FRESHNESS = 1_s;
40 inline constexpr ndn::time::milliseconds SYNC_INTEREST_LIFETIME = 1_s;
41 inline constexpr ndn::time::milliseconds SYNC_REPLY_FRESHNESS = 1_s;
42 
43 enum class CompressionScheme {
44  NONE,
45  ZLIB,
46  GZIP,
47  BZIP2,
48  LZMA,
49  ZSTD,
50 #ifdef PSYNC_HAVE_ZLIB
51  DEFAULT = ZLIB
52 #else
53  DEFAULT = NONE
54 #endif
55 };
56 
57 class CompressionError : public std::runtime_error
58 {
59 public:
60  using std::runtime_error::runtime_error;
61 };
62 
64 {
65  ndn::Name prefix;
66  uint64_t lowSeq;
67  uint64_t highSeq;
68  uint64_t incomingFace;
69 };
70 
71 using UpdateCallback = std::function<void(const std::vector<MissingDataInfo>&)>;
72 
73 } // namespace psync
74 
75 #endif // PSYNC_COMMON_HPP
Definition: common.hpp:34
constexpr ndn::time::milliseconds HELLO_REPLY_FRESHNESS
Definition: common.hpp:39
CompressionScheme
Definition: common.hpp:43
constexpr ndn::time::milliseconds SYNC_INTEREST_LIFETIME
Definition: common.hpp:40
constexpr ndn::time::milliseconds HELLO_INTEREST_LIFETIME
Definition: common.hpp:38
constexpr ndn::time::milliseconds SYNC_REPLY_FRESHNESS
Definition: common.hpp:41
std::function< void(const std::vector< MissingDataInfo > &)> UpdateCallback
Definition: common.hpp:71
uint64_t incomingFace
Definition: common.hpp:68