UnloadWorldServiceHandler.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 "UnloadWorldServiceHandler.h"
  9. #include <AzCore/std/string/string.h>
  10. #include <SimulationInterfaces/LevelManagerRequestBus.h>
  11. namespace ROS2SimulationInterfaces
  12. {
  13. AZStd::unordered_set<SimulationFeatureType> UnloadWorldServiceHandler::GetProvidedFeatures()
  14. {
  15. return AZStd::unordered_set<SimulationFeatureType>{ SimulationFeatures::WORLD_UNLOADING };
  16. }
  17. AZStd::optional<UnloadWorldServiceHandler::Response> UnloadWorldServiceHandler::HandleServiceRequest(
  18. const std::shared_ptr<rmw_request_id_t> header, const Request& request)
  19. {
  20. AZ::Outcome<void, SimulationInterfaces::FailedResult> unloadWorld;
  21. SimulationInterfaces::LevelManagerRequestBus::BroadcastResult(
  22. unloadWorld, &SimulationInterfaces::LevelManagerRequests::UnloadWorld);
  23. Response response;
  24. if (!unloadWorld.IsSuccess())
  25. {
  26. response.result.result = unloadWorld.GetError().m_errorCode;
  27. response.result.error_message = unloadWorld.GetError().m_errorString.c_str();
  28. }
  29. else
  30. {
  31. response.result.result = simulation_interfaces::msg::Result::RESULT_OK;
  32. }
  33. return response;
  34. }
  35. } // namespace ROS2SimulationInterfaces