MOTION  0.01
Framework for mixed-protocol multi-party computation
configuration.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Oleksandr Tkachenko
4 // Cryptography and Privacy Engineering Group (ENCRYPTO)
5 // TU Darmstadt, Germany
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 
25 #pragma once
26 
27 #include <boost/log/trivial.hpp>
28 #include <memory>
29 
30 namespace encrypto::motion {
31 
33  public:
34  Configuration(std::size_t my_id, std::size_t number_of_parties);
35 
36  ~Configuration() = default;
37 
38  std::size_t GetNumOfThreads() const noexcept { return number_of_threads_; }
39 
40  void SetNumOfThreads(std::size_t n) { number_of_threads_ = n; }
41 
42  void SetLoggingSeverityLevel(boost::log::trivial::severity_level severity_level) {
43  severity_level_ = severity_level;
44  }
45 
46  bool GetOnlineAfterSetup() const noexcept { return online_after_setup_; }
47 
48  void SetOnlineAfterSetup(bool value);
49 
50  void SetLoggingEnabled(bool value = true) { logging_enabled_ = value; }
51 
52  bool GetLoggingEnabled() const noexcept { return logging_enabled_; }
53 
54  std::size_t GetMyId() const { return my_id_; }
55 
56  std::size_t GetNumOfParties() const { return number_of_parties_; }
57 
58  boost::log::trivial::severity_level GetLoggingSeverityLevel() const noexcept {
59  return severity_level_;
60  }
61 
62  private:
63  std::size_t my_id_;
64  std::size_t number_of_parties_;
65 
66  boost::log::trivial::severity_level severity_level_ = boost::log::trivial::info;
67 
68  bool logging_enabled_ = true;
69 
72  bool online_after_setup_ = false;
73 
74  // determines how many worker threads are used in openmp, but not in
75  // communication handlers! the latter always use at least 2 threads for each
76  // communication channel to send and receive data to prevent the communication
77  // becoming a bottleneck, e.g., in 10 Gbps networks.
78  std::size_t number_of_threads_;
79 };
80 
81 using ConfigurationPointer = std::shared_ptr<Configuration>;
82 
83 } // namespace encrypto::motion
encrypto::motion::Configuration::GetLoggingEnabled
bool GetLoggingEnabled() const noexcept
Definition: configuration.h:52
encrypto::motion::Configuration::SetLoggingSeverityLevel
void SetLoggingSeverityLevel(boost::log::trivial::severity_level severity_level)
Definition: configuration.h:42
encrypto::motion::Configuration::GetNumOfThreads
std::size_t GetNumOfThreads() const noexcept
Definition: configuration.h:38
encrypto::motion::Configuration::~Configuration
~Configuration()=default
encrypto::motion::Configuration::GetOnlineAfterSetup
bool GetOnlineAfterSetup() const noexcept
Definition: configuration.h:46
configuration.h
encrypto::motion::Configuration::SetLoggingEnabled
void SetLoggingEnabled(bool value=true)
Definition: configuration.h:50
encrypto::motion::Configuration::SetOnlineAfterSetup
void SetOnlineAfterSetup(bool value)
Definition: configuration.cpp:44
encrypto::motion::Configuration::GetLoggingSeverityLevel
boost::log::trivial::severity_level GetLoggingSeverityLevel() const noexcept
Definition: configuration.h:58
encrypto::motion::Configuration::GetMyId
std::size_t GetMyId() const
Definition: configuration.h:54
encrypto::motion::ConfigurationPointer
std::shared_ptr< Configuration > ConfigurationPointer
Definition: backend.h:81
encrypto::motion::Configuration::Configuration
Configuration(std::size_t my_id, std::size_t number_of_parties)
Definition: configuration.cpp:33
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::Configuration::GetNumOfParties
std::size_t GetNumOfParties() const
Definition: configuration.h:56
encrypto::motion::Configuration::SetNumOfThreads
void SetNumOfThreads(std::size_t n)
Definition: configuration.h:40
encrypto::motion::kVerboseDebug
constexpr bool kVerboseDebug
Definition: constants.h:50
encrypto::motion::Configuration
Definition: configuration.h:32
constants.h
encrypto::motion::kDebug
constexpr bool kDebug
Definition: config.h:36