SpawnEntityServiceHandler.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/std/string/regex.h>
  10. #include <AzCore/std/string/string_view.h>
  11. #include <Interfaces/ISimulationFeaturesBase.h>
  12. #include <ROS2/Handlers/ROS2ServiceBase.h>
  13. #include <simulation_interfaces/srv/spawn_entity.hpp>
  14. namespace ROS2SimulationInterfaces
  15. {
  16. class SpawnEntityServiceHandler
  17. : public ROS2::ROS2ServiceBase<simulation_interfaces::srv::SpawnEntity>
  18. , public ISimulationFeaturesBase
  19. {
  20. public:
  21. AZStd::string_view GetTypeName() const override
  22. {
  23. return "SpawnEntity";
  24. }
  25. AZStd::string_view GetDefaultName() const override
  26. {
  27. return "spawn_entity";
  28. }
  29. AZStd::unordered_set<SimulationFeatureType> GetProvidedFeatures() override;
  30. AZStd::optional<Response> HandleServiceRequest(const std::shared_ptr<rmw_request_id_t> header, const Request& request) override;
  31. private:
  32. bool ValidateEntityName(const AZStd::string& entityName);
  33. bool ValidateNamespaceName(const AZStd::string& namespaceName);
  34. };
  35. } // namespace ROS2SimulationInterfaces