Wayverb
capsule.h
1 #pragma once
2 
3 #include "combined/model/hrtf.h"
4 #include "combined/model/microphone.h"
5 #include "combined/model/vector.h"
6 
7 #include "cereal/types/base_class.hpp"
8 
9 namespace wayverb {
10 namespace combined {
11 namespace model {
12 
13 class capsule final : public owning_member<capsule, microphone, hrtf> {
14 public:
15  enum class mode { microphone = 1, hrtf };
16 
17  using microphone_t = class microphone;
18  using hrtf_t = class hrtf;
19 
20  explicit capsule(std::string name = "new capsule",
21  mode mode = mode::microphone,
22  microphone_t microphone = microphone_t{},
23  hrtf_t hrtf = hrtf_t{});
24  capsule(std::string name, microphone_t);
25  capsule(std::string name, hrtf_t);
26 
27  void set_name(std::string name);
28  std::string get_name() const;
29 
30  void set_mode(mode mode);
31  mode get_mode() const;
32 
33  template <typename Archive>
34  void serialize(Archive& archive) {
35  archive(cereal::base_class<base_type>(this), name_, mode_);
36  }
37 
38  const auto& microphone() const { return get<0>(); }
39  auto& microphone() { return get<0>(); }
40 
41  const auto& hrtf() const { return get<1>(); }
42  auto& hrtf() { return get<1>(); }
43 
44  NOTIFYING_COPY_ASSIGN_DECLARATION(capsule)
45 private:
46  void swap(capsule& other) noexcept {
47  using std::swap;
48  swap(name_, other.name_);
49  swap(mode_, other.mode_);
50  }
51 
52  std::string name_;
53  mode mode_;
54 };
55 
56 bool operator==(const capsule& a, const capsule& b);
57 bool operator!=(const capsule& a, const capsule& b);
58 
59 core::orientation get_orientation(const capsule& capsule);
60 
61 } // namespace model
62 } // namespace combined
63 } // namespace wayverb
Definition: capsule.h:13
Definition: hrtf.h:12
Definition: microphone.h:12
Definition: capsule_base.h:9
Invariant: pointing_ is a unit vector.
Definition: orientation.h:15