RuleContainer.inl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <SceneAPI/SceneCore/Containers/RuleContainer.h>
  9. namespace AZ
  10. {
  11. namespace SceneAPI
  12. {
  13. namespace Containers
  14. {
  15. template<typename T>
  16. AZStd::shared_ptr<T> RuleContainer::FindFirstByType() const
  17. {
  18. static_assert(AZStd::is_base_of<DataTypes::IRule, T>::value, "Specified type T is not derived from IRule.");
  19. for (const AZStd::shared_ptr<DataTypes::IRule>& rule : m_rules)
  20. {
  21. if (rule && rule->RTTI_IsTypeOf(T::TYPEINFO_Uuid()))
  22. {
  23. return AZStd::static_pointer_cast<T>(rule);
  24. }
  25. }
  26. return AZStd::shared_ptr<T>();
  27. }
  28. template<typename T>
  29. bool RuleContainer::ContainsRuleOfType() const
  30. {
  31. static_assert(AZStd::is_base_of<DataTypes::IRule, T>::value, "Specified type T is not derived from IRule.");
  32. for (const AZStd::shared_ptr<DataTypes::IRule>& rule : m_rules)
  33. {
  34. if (rule && rule->RTTI_IsTypeOf(T::TYPEINFO_Uuid()))
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. } // Containers
  42. } // SceneAPI
  43. } // AZ