RuleContainer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #pragma once
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/std/containers/vector.h>
  11. #include <AzCore/std/smart_ptr/shared_ptr.h>
  12. #include <SceneAPI/SceneCore/DataTypes/Rules/IRule.h>
  13. #include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
  14. namespace AZ
  15. {
  16. class ReflectContext;
  17. namespace SceneAPI
  18. {
  19. namespace Containers
  20. {
  21. class RuleContainer
  22. {
  23. public:
  24. AZ_RTTI(RuleContainer, "{2C20D3DF-57FF-4A31-8680-A4D45302B9CF}");
  25. virtual ~RuleContainer() {}
  26. SCENE_CORE_API size_t GetRuleCount() const;
  27. SCENE_CORE_API AZStd::shared_ptr<DataTypes::IRule> GetRule(size_t index) const;
  28. /**
  29. * Find the first rule of the template type.
  30. * @result The first rule of the template type. nullptr if not found.
  31. */
  32. template<typename T>
  33. AZStd::shared_ptr<T> FindFirstByType() const;
  34. /**
  35. * Check if there is a rule of the given template type.
  36. * @result True in case a rule of the given template type got found, false if not.
  37. */
  38. template<typename T>
  39. bool ContainsRuleOfType() const;
  40. SCENE_CORE_API void AddRule(const AZStd::shared_ptr<DataTypes::IRule>& rule);
  41. SCENE_CORE_API void AddRule(AZStd::shared_ptr<DataTypes::IRule>&& rule);
  42. SCENE_CORE_API void InsertRule(const AZStd::shared_ptr<DataTypes::IRule>& rule, size_t position);
  43. SCENE_CORE_API void RemoveRule(size_t index);
  44. SCENE_CORE_API void RemoveRule(const AZStd::shared_ptr<DataTypes::IRule>& rule);
  45. static void Reflect(ReflectContext* context);
  46. static SCENE_CORE_API bool VectorToRuleContainerConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement);
  47. private:
  48. AZStd::vector<AZStd::shared_ptr<DataTypes::IRule>> m_rules;
  49. };
  50. } // Containers
  51. } // SceneAPI
  52. } // AZ
  53. #include <SceneAPI/SceneCore/Containers/RuleContainer.inl>