1 #include "PinConnection.h"
4 namespace Odb::Lib::ProductModel
10 PinConnection::PinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin)
11 : PinConnection(pComponent, pPin, MakeName(pComponent, pPin))
15 PinConnection::PinConnection(std::shared_ptr<Component> pComponent, std::shared_ptr<Pin> pPin, std::string name)
17 , m_pComponent(pComponent)
22 std::string PinConnection::MakeName(std::shared_ptr<Odb::Lib::ProductModel::Component>& pComponent, std::shared_ptr<Odb::Lib::ProductModel::Pin>& pPin)
24 if (pComponent ==
nullptr || pPin ==
nullptr)
return "Pin::MakeName() FAILED";
25 return pComponent->GetRefDes() +
"-" + pPin->GetName();
28 std::shared_ptr<Pin> PinConnection::GetPin()
const
33 std::shared_ptr<Component> PinConnection::GetComponent()
const
38 std::unique_ptr<Odb::Lib::Protobuf::ProductModel::PinConnection> PinConnection::to_protobuf()
const
40 auto pPinConnectionMsg = std::make_unique<Odb::Lib::Protobuf::ProductModel::PinConnection>();
41 pPinConnectionMsg->set_name(m_name);
42 pPinConnectionMsg->mutable_component()->CopyFrom(*m_pComponent->to_protobuf());
43 pPinConnectionMsg->mutable_pin()->CopyFrom(*m_pPin->to_protobuf());
44 return pPinConnectionMsg;
47 void PinConnection::from_protobuf(
const Odb::Lib::Protobuf::ProductModel::PinConnection& message)
49 m_name = message.name();
50 m_pComponent = std::shared_ptr<Component>(Component::MakeEmpty());
51 m_pComponent->from_protobuf(message.component());
52 m_pPin = std::make_shared<Pin>(
"", -1);
53 m_pPin->from_protobuf(message.pin());