OdbDesignLib
OdbDesign ODB++ Parsing Library
 
Loading...
Searching...
No Matches
Design.h
1#pragma once
2
3#include "../odbdesign_export.h"
4#include <string>
5#include <memory>
6#include "Net.h"
7#include "Component.h"
8#include "Package.h"
9#include "Part.h"
10#include "design.pb.h"
11#include "../IProtoBuffable.h"
12#include <map>
13#include <vector>
14#include "../FileModel/Design/StepDirectory.h"
15#include "../FileModel/Design/EdaDataFile.h"
16#include "../FileModel/Design/ComponentsFile.h"
17#include "../FileModel/Design/FileArchive.h"
18
19
20namespace Odb::Lib::ProductModel
21{
22 class ODBDESIGN_EXPORT Design : public IProtoBuffable<Protobuf::ProductModel::Design>
23 {
24 public:
25 Design();
26 ~Design();
27
28 const std::string& GetName() const;
29 const std::string& GetProductModel() const;
30
31 const Net::Vector& GetNets() const;
32 const Net::StringMap GetNetsByName() const;
33 std::shared_ptr<Net> GetNet(const std::string& name) const;
34
35 const Package::Vector& GetPackages() const;
36 const Package::StringMap& GetPackagesByName() const;
37
38 const Component::Vector& GetComponents() const;
39 const Component::StringMap& GetComponentsByName() const;
40 std::shared_ptr<Component> GetComponent(const std::string& refDes) const;
41
42 const Part::Vector& GetParts() const;
43 const Part::StringMap& GetPartsByName() const;
44
45 std::shared_ptr<Net> GetNoneNet() const;
46
47 bool Build(std::string path);
48 bool Build(std::shared_ptr<FileModel::Design::FileArchive> pFileModel);
49
50 std::shared_ptr<FileModel::Design::FileArchive> GetFileModel() const;
51 void ClipFileModel();
52
53 // Inherited via IProtoBuffable
54 std::unique_ptr<Protobuf::ProductModel::Design> to_protobuf() const override;
55 void from_protobuf(const Protobuf::ProductModel::Design& message) override;
56
57 typedef std::vector<std::shared_ptr<Design>> Vector;
58 typedef std::map<std::string, std::shared_ptr<Design>> StringMap;
59
60 private:
61 std::string m_productModel;
62 std::string m_name;
63
64 std::shared_ptr<FileModel::Design::FileArchive> m_pFileModel;
65
66 Net::Vector m_nets;
67 Net::StringMap m_netsByName;
68
69 Package::Vector m_packages;
70 Package::StringMap m_packagesByName;
71
72 Component::Vector m_components;
73 Component::StringMap m_componentsByName;
74
75 Part::Vector m_parts;
76 Part::StringMap m_partsByName;
77
78 bool BuildNets();
79 bool BuildPackages();
80 bool BuildAllParts();
81 bool BuildParts(const FileModel::Design::ComponentsFile* pComponentsFile);
82 bool BuildAllComponents();
83 bool BuildComponents(const FileModel::Design::ComponentsFile* pComponentsFile);
84 bool BuildVias();
85
86 bool BuildPlacementsFromComponentsFiles();
87 bool BuildPlacementsFromComponentsFile(const FileModel::Design::ComponentsFile* pComponentsFile);
88
89 bool BuildPlacementsFromEdaDataFile();
90
91 bool BuildNoneNet();
92 bool BreakSinglePinNets();
93
94 // helper convienience methods
95 bool CreatePinConnection(const std::string& refDes, unsigned int netNumber, unsigned int pinNumber, const std::string& pinName);
96 bool CreateNetConnections(const std::shared_ptr<FileModel::Design::EdaDataFile::NetRecord>& pNetRecord, const std::shared_ptr<FileModel::Design::StepDirectory>& pStepDirectory);
97
98 constexpr inline static const char* NONE_NET_NAME = "$NONE$";
99
100 constexpr inline static bool CLIP_FILEMODEL_AFTER_BUILD = false;
101
102 };
103}