OdbDesignLib
OdbDesign ODB++ Parsing Library
NetlistFile.h
1 #pragma once
2 
3 #include <map>
4 #include <vector>
5 #include <string>
6 #include <memory>
7 #include <filesystem>
8 #include "../../odbdesign_export.h"
9 #include "../../IProtoBuffable.h"
10 #include "../../ProtoBuf/netlistfile.pb.h"
11 
12 
13 namespace Odb::Lib::FileModel::Design
14 {
15  class ODBDESIGN_EXPORT NetlistFile : public IProtoBuffable<Odb::Lib::Protobuf::NetlistFile>
16  {
17  public:
18  struct ODBDESIGN_EXPORT NetRecord : public IProtoBuffable<Odb::Lib::Protobuf::NetlistFile::NetRecord>
19  {
20  unsigned int serialNumber;
21  std::string netName;
22 
23  // Inherited via IProtoBuffable
24  std::unique_ptr<Odb::Lib::Protobuf::NetlistFile::NetRecord> to_protobuf() const override;
25  void from_protobuf(const Odb::Lib::Protobuf::NetlistFile::NetRecord& message) override;
26 
27  typedef std::vector<std::shared_ptr<NetRecord>> Vector;
28  typedef std::map<std::string, std::shared_ptr<NetRecord>> StringMap;
29 
30  inline constexpr static const char* FIELD_TOKEN = "$";
31  };
32 
33  struct ODBDESIGN_EXPORT NetPointRecord : public IProtoBuffable<Odb::Lib::Protobuf::NetlistFile::NetPointRecord>
34  {
35  enum AccessSide
36  {
37  Top,
38  Down,
39  Both,
40  Inner
41  };
42 
43  unsigned int netNumber;
44  float radius;
45  float x;
46  float y;
47  AccessSide side;
48  float width;
49  float height;
50  char epoint;
51  char exp;
52  bool commentPoint;
53  float staggeredX;
54  float staggeredY;
55  float staggeredRadius;
56  float viaPoint;
57  float fiducialPoint;
58  float testPoint;
59  // ...
60  char testExecutionSide;
61 
62  // Inherited via IProtoBuffable
63  std::unique_ptr<Odb::Lib::Protobuf::NetlistFile::NetPointRecord> to_protobuf() const override;
64  void from_protobuf(const Odb::Lib::Protobuf::NetlistFile::NetPointRecord& message) override;
65 
66  typedef std::vector<std::shared_ptr<NetPointRecord>> Vector;
67  }; // NetPointRecord
68 
69  enum class Staggered
70  {
71  Yes,
72  No,
73  Unknown
74  };
75 
76  NetlistFile(std::filesystem::path path);
77  ~NetlistFile();
78 
79  std::filesystem::path GetPath() const;
80  std::string GetName() const;
81  std::string GetUnits() const;
82 
83  bool GetOptimized() const;
84  Staggered GetStaggered() const;
85 
86  const NetRecord::Vector& GetNetRecords() const;
87  const NetRecord::StringMap& GetNetRecordsByName() const;
88  const NetPointRecord::Vector& GetNetPointRecords() const;
89 
90  bool Parse();
91 
92  // Inherited via IProtoBuffable
93  std::unique_ptr<Odb::Lib::Protobuf::NetlistFile> to_protobuf() const override;
94  void from_protobuf(const Odb::Lib::Protobuf::NetlistFile& message) override;
95 
96  typedef std::vector<std::shared_ptr<NetlistFile>> Vector;
97  typedef std::map<std::string, std::shared_ptr<NetlistFile>> StringMap;
98 
99  private:
100  std::filesystem::path m_path;
101  std::string m_name;
102  std::string m_units;
103  bool m_optimized;
104  Staggered m_staggered;
105 
106  NetRecord::Vector m_netRecords;
107  NetRecord::StringMap m_netRecordsByName;
108  NetPointRecord::Vector m_netPointRecords;
109 
110  inline constexpr static const char* UNITS_TOKEN = "UNITS";
111  inline constexpr static const char* COMMENT_TOKEN = "#";
112  inline constexpr static const char* HEADER_TOKEN = "H";
113 
114  }; // NetlistFile
115 }