1 #include "PinConnection.h"
6 #include "../ProtoBuf/pinconnection.pb.h"
9 namespace Odb::Lib::ProductModel
15 PinConnection::PinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin)
16 : PinConnection(pComponent, pPin, MakeName(*pComponent, *pPin))
20 PinConnection::PinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin,
const std::string& name)
22 , m_pComponent(pComponent)
27 std::string PinConnection::MakeName(
const Component& component,
const Pin& pin)
31 return component.GetRefDes() +
"-" + pin.GetName();
34 std::shared_ptr<Pin> PinConnection::GetPin()
const
39 std::shared_ptr<Component> PinConnection::GetComponent()
const
44 std::unique_ptr<Protobuf::ProductModel::PinConnection> PinConnection::to_protobuf()
const
46 auto pPinConnectionMsg = std::make_unique<Protobuf::ProductModel::PinConnection>();
47 pPinConnectionMsg->set_name(m_name);
48 pPinConnectionMsg->mutable_component()->CopyFrom(*m_pComponent->to_protobuf());
49 pPinConnectionMsg->mutable_pin()->CopyFrom(*m_pPin->to_protobuf());
50 return pPinConnectionMsg;
53 void PinConnection::from_protobuf(
const Protobuf::ProductModel::PinConnection& message)
55 m_name = message.name();
56 m_pComponent = std::make_shared<Component>();
57 m_pComponent->from_protobuf(message.component());
58 m_pPin = std::make_shared<Pin>(
"", -1);
59 m_pPin->from_protobuf(message.pin());