Horizon
unit.hpp
1 #pragma once
2 #include "nlohmann/json_fwd.hpp"
3 #include "util/uuid.hpp"
4 #include "common/lut.hpp"
5 #include <fstream>
6 #include <map>
7 #include <set>
8 #include <vector>
9 #include "util/file_version.hpp"
10 
11 namespace horizon {
12 using json = nlohmann::json;
13 
18 class Pin {
19 public:
20  enum class Direction {
21  INPUT,
22  OUTPUT,
23  BIDIRECTIONAL,
24  OPEN_COLLECTOR,
25  POWER_INPUT,
26  POWER_OUTPUT,
27  PASSIVE,
28  NOT_CONNECTED
29  };
30 
31  Pin(const UUID &uu, const json &j);
32  Pin(const UUID &uu);
33 
34  const UUID uuid;
38  std::string primary_name;
39  Direction direction = Direction::INPUT;
40  static const LutEnumStr<Pin::Direction> direction_lut;
41  static const std::vector<std::pair<Pin::Direction, std::string>> direction_names;
46  unsigned int swap_group = 0;
50  std::vector<std::string> names;
51 
52  json serialize() const;
53  UUID get_uuid() const;
54 };
60 class Unit {
61 private:
62  Unit(const UUID &uu, const json &j);
63 
64 public:
65  static Unit new_from_file(const std::string &filename);
66  Unit(const UUID &uu);
67  UUID uuid;
68  std::string name;
69  std::string manufacturer;
70  std::map<UUID, Pin> pins;
71  FileVersion version;
72 
73  json serialize() const;
74  UUID get_uuid() const;
75 };
76 } // namespace horizon
horizon::Pin::primary_name
std::string primary_name
The Pin's primary name.
Definition: unit.hpp:38
horizon::Pin::names
std::vector< std::string > names
The Pin's alternate names.
Definition: unit.hpp:50
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Pin::swap_group
unsigned int swap_group
Pins of the same swap_group can be pinswapped.
Definition: unit.hpp:46