7#include "PinConnection.h"
8#include "../Text/Utf8Sanitizer.h"
11namespace Odb::Lib::ProductModel
13 Net::Net(
const std::string& name,
unsigned int index)
21 m_pinConnections.clear();
24 std::string Net::GetName()
const
29 PinConnection::Vector& Net::GetPinConnections()
31 return m_pinConnections;
34 unsigned int Net::GetIndex()
const
39 bool Net::AddPinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin)
41 m_pinConnections.push_back(std::make_shared<PinConnection>(pComponent, pPin));
45 std::unique_ptr<Odb::Lib::Protobuf::ProductModel::Net> Odb::Lib::ProductModel::Net::to_protobuf()
const
47 auto pNetMsg = std::make_unique<Odb::Lib::Protobuf::ProductModel::Net>();
48 pNetMsg->set_name(Odb::Lib::Text::ToUtf8(m_name));
49 pNetMsg->set_index(m_index);
50 for (
auto& pPinConnection : m_pinConnections)
52 pNetMsg->add_pinconnections()->CopyFrom(*pPinConnection->to_protobuf());
57 void Odb::Lib::ProductModel::Net::from_protobuf(
const Odb::Lib::Protobuf::ProductModel::Net& message)
59 m_name = message.name();
60 m_index = message.index();
61 for (
auto& pinConnectionMsg : message.pinconnections())
63 auto pPinConnection = std::make_shared<PinConnection>(
nullptr,
nullptr,
"");
64 pPinConnection->from_protobuf(pinConnectionMsg);
65 m_pinConnections.push_back(pPinConnection);