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  static unsigned int get_app_version();
67  Unit(const UUID &uu);
68  UUID uuid;
69  std::string name;
70  std::string manufacturer;
71  std::map<UUID, Pin> pins;
72  FileVersion version;
73 
74  json serialize() const;
75  UUID get_uuid() const;
76 };
77 } // namespace horizon
Definition: file_version.hpp:8
A Pin represents a logical pin of a Unit.
Definition: unit.hpp:18
std::vector< std::string > names
The Pin's alternate names.
Definition: unit.hpp:50
unsigned int swap_group
Pins of the same swap_group can be pinswapped.
Definition: unit.hpp:46
std::string primary_name
The Pin's primary name.
Definition: unit.hpp:38
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
A Unit is the template for a Gate inside of an Entity.
Definition: unit.hpp:60
a class to store JSON values
Definition: json.hpp:166
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61