5 #include "../ProtoBuf/net.pb.h"
7 #include "PinConnection.h"
10 namespace Odb::Lib::ProductModel
12 Net::Net(
const std::string& name,
unsigned int index)
20 m_pinConnections.clear();
23 std::string Net::GetName()
const
28 PinConnection::Vector& Net::GetPinConnections()
30 return m_pinConnections;
33 unsigned int Net::GetIndex()
const
38 bool Net::AddPinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin)
40 m_pinConnections.push_back(std::make_shared<PinConnection>(pComponent, pPin));
44 std::unique_ptr<Odb::Lib::Protobuf::ProductModel::Net> Odb::Lib::ProductModel::Net::to_protobuf()
const
46 auto pNetMsg = std::make_unique<Odb::Lib::Protobuf::ProductModel::Net>();
47 pNetMsg->set_name(m_name);
48 pNetMsg->set_index(m_index);
49 for (
auto& pPinConnection : m_pinConnections)
51 pNetMsg->add_pinconnections()->CopyFrom(*pPinConnection->to_protobuf());
56 void Odb::Lib::ProductModel::Net::from_protobuf(
const Odb::Lib::Protobuf::ProductModel::Net& message)
58 m_name = message.name();
59 m_index = message.index();
60 for (
auto& pinConnectionMsg : message.pinconnections())
62 auto pPinConnection = std::make_shared<PinConnection>(
nullptr,
nullptr,
"");
63 pPinConnection->from_protobuf(pinConnectionMsg);
64 m_pinConnections.push_back(pPinConnection);