MachineLearningSystemComponent.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "MachineLearningSystemComponent.h"
  9. #include <MachineLearning/MachineLearningTypeIds.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/RTTI/BehaviorContext.h>
  12. #include <Models/Layer.h>
  13. #include <Models/MultilayerPerceptron.h>
  14. #include <AutoGenNodeableRegistry.generated.h>
  15. static ScriptCanvas::MachineLearningPrivateObjectNodeableRegistry s_MachineLearningPrivateObjectNodeableRegistry;
  16. namespace MachineLearning
  17. {
  18. AZ_COMPONENT_IMPL(MachineLearningSystemComponent, "MachineLearningSystemComponent", MachineLearningSystemComponentTypeId);
  19. void MachineLearningSystemComponent::Reflect(AZ::ReflectContext* context)
  20. {
  21. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  22. {
  23. serializeContext->Class<MachineLearningSystemComponent, AZ::Component>()->Version(0);
  24. serializeContext->Class<Layer>()->Version(0);
  25. serializeContext->Class<MultilayerPerceptron>()->Version(0);
  26. }
  27. if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  28. {
  29. behaviorContext->Class<MachineLearningSystemComponent>();
  30. behaviorContext->Class<Layer>();
  31. behaviorContext->Class<MultilayerPerceptron>();
  32. }
  33. }
  34. void MachineLearningSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  35. {
  36. provided.push_back(AZ_CRC_CE("MachineLearningService"));
  37. }
  38. void MachineLearningSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  39. {
  40. incompatible.push_back(AZ_CRC_CE("MachineLearningService"));
  41. }
  42. void MachineLearningSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  43. {
  44. }
  45. void MachineLearningSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  46. {
  47. }
  48. MachineLearningSystemComponent::MachineLearningSystemComponent()
  49. {
  50. if (MachineLearningInterface::Get() == nullptr)
  51. {
  52. MachineLearningInterface::Register(this);
  53. }
  54. }
  55. MachineLearningSystemComponent::~MachineLearningSystemComponent()
  56. {
  57. if (MachineLearningInterface::Get() == this)
  58. {
  59. MachineLearningInterface::Unregister(this);
  60. }
  61. }
  62. void MachineLearningSystemComponent::Init()
  63. {
  64. }
  65. void MachineLearningSystemComponent::Activate()
  66. {
  67. MachineLearningRequestBus::Handler::BusConnect();
  68. }
  69. void MachineLearningSystemComponent::Deactivate()
  70. {
  71. MachineLearningRequestBus::Handler::BusDisconnect();
  72. }
  73. } // namespace MachineLearning