/* * 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. * */ #pragma once #include #include #include namespace AzToolsFramework { class SliceDependencyBrowserComponent; class SliceRelationshipNode { public: friend class SliceDependencyBrowserComponent; ////////////////////////////////////////////////////////////////////////// /*! * Hashing and comparison functions for unordered sets of Slice relationship nodes */ struct HashSliceRelationshipNodeKey { AZStd::size_t operator()(const AZStd::shared_ptr& node) const { return static_cast(node->m_relativePathCrc); } }; struct HashSliceRelationshipNodeComparator { bool operator()(const AZStd::shared_ptr& left, const AZStd::shared_ptr& right) const { return (left->m_relativePathCrc == right->m_relativePathCrc); } }; using SliceRelationshipNodeSet = AZStd::unordered_set, HashSliceRelationshipNodeKey, HashSliceRelationshipNodeComparator>; SliceRelationshipNode(const AZStd::string& sliceRelativePath); SliceRelationshipNode(const AZStd::string& sliceRelativePath, AZ::Crc32 relativePathCrc); /** * \brief Adds a dependent to this Relationship node * \param AZStd::shared_ptr dependent The dependent node * \return bool true if a dependent was added false otherwise */ bool AddDependent(const AZStd::shared_ptr& dependent); /** * \brief Adds a dependency to this Relationship node * \param AZStd::shared_ptr dependency The dependency node * \return bool true if a dependency was added false otherwise */ bool AddDependency(const AZStd::shared_ptr& dependency); /** * \brief Returns the set of all dependent slice relationship nodes * \return const AzToolsFramework::SliceRelationshipNode::SliceRelationshipNodeSet& The set of all dependent slice relationship nodes */ const SliceRelationshipNodeSet& GetDependents() const; /** * \brief Returns the set of all slice relationship nodes that this one depends on * \return const AzToolsFramework::SliceRelationshipNode::SliceRelationshipNodeSet& The set of all slice relationship nodes that this one depends on */ const SliceRelationshipNodeSet& GetDependencies() const; /** * \brief Returns the relative path of this slice * \return const AZStd::string& Relative path of this slice */ const AZStd::string& GetSliceRelativePath() const; /** * \brief Returns a Crc to the relative path of this slice * \return const AzToolsFramework::AZ::Crc32& */ const AZ::Crc32& GetRelativePathCrc() const; private: //! Relative path to this slice AZStd::string m_sliceRelativePath; //! Crc32 of m_sliceRelativePath AZ::Crc32 m_relativePathCrc; //! Pointers to dependents and dependencies SliceRelationshipNodeSet m_dependents; SliceRelationshipNodeSet m_dependencies; }; }