/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // AZ #include #include #include // Graph Model #include #include #include namespace GraphModel { Connection::Connection(GraphPtr graph, SlotPtr sourceSlot, SlotPtr targetSlot) : GraphElement(graph) , m_sourceSlot(sourceSlot) , m_targetSlot(targetSlot) { AZ_Assert(sourceSlot->SupportsConnections(), "sourceSlot type does not support connections to other slots"); AZ_Assert(targetSlot->SupportsConnections(), "targetSlot type does not support connections to other slots"); const NodeId sourceNodeId = sourceSlot->GetParentNode()->GetId(); const NodeId targetNodeId = targetSlot->GetParentNode()->GetId(); m_sourceEndpoint = AZStd::make_pair(sourceNodeId, sourceSlot->GetSlotId()); m_targetEndpoint = AZStd::make_pair(targetNodeId, targetSlot->GetSlotId()); } void Connection::PostLoadSetup(GraphPtr graph) { m_graph = graph; m_sourceSlot = azrtti_cast(graph->FindSlot(m_sourceEndpoint)); m_targetSlot = azrtti_cast(graph->FindSlot(m_targetEndpoint)); } void Connection::Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serializeContext = azrtti_cast(context); if (serializeContext) { serializeContext->Class() ->Version(0) ->Field("m_sourceEndpoint", &Connection::m_sourceEndpoint) ->Field("m_targetEndpoint", &Connection::m_targetEndpoint) ; } } NodePtr Connection::GetSourceNode() const { if (GetSourceSlot()) { return GetSourceSlot()->GetParentNode(); } return nullptr; } NodePtr Connection::GetTargetNode() const { if (GetTargetSlot()) { return GetTargetSlot()->GetParentNode(); } return nullptr; } SlotPtr Connection::GetSourceSlot() const { return m_sourceSlot.lock(); } SlotPtr Connection::GetTargetSlot() const { return m_targetSlot.lock(); } const Endpoint& Connection::GetSourceEndpoint() const { return m_sourceEndpoint; } const Endpoint& Connection::GetTargetEndpoint() const { return m_targetEndpoint; } } // namespace GraphModel