PythonBindingsInterface.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #pragma once
  8. #include <AzCore/EBus/EBus.h>
  9. #include <AzCore/Interface/Interface.h>
  10. #include <AzCore/std/string/string.h>
  11. #include <AzCore/std/containers/vector.h>
  12. #include <AzCore/Outcome/Outcome.h>
  13. #include <EngineInfo.h>
  14. #include <GemCatalog/GemInfo.h>
  15. #include <ProjectInfo.h>
  16. #include <ProjectTemplateInfo.h>
  17. namespace O3DE::ProjectManager
  18. {
  19. //! Interface used to interact with the o3de cli python functions
  20. class IPythonBindings
  21. {
  22. public:
  23. AZ_RTTI(O3DE::ProjectManager::IPythonBindings, "{C2B72CA4-56A9-4601-A584-3B40E83AA17C}");
  24. AZ_DISABLE_COPY_MOVE(IPythonBindings);
  25. IPythonBindings() = default;
  26. virtual ~IPythonBindings() = default;
  27. /**
  28. * Get whether Python was started or not. All Python functionality will fail if Python
  29. * failed to start.
  30. * @return true if Python was started successfully, false on failure
  31. */
  32. virtual bool PythonStarted() = 0;
  33. // Engine
  34. /**
  35. * Get info about the engine
  36. * @return an outcome with EngineInfo on success
  37. */
  38. virtual AZ::Outcome<EngineInfo> GetEngineInfo() = 0;
  39. /**
  40. * Set info about the engine
  41. * @param engineInfo an EngineInfo object
  42. */
  43. virtual bool SetEngineInfo(const EngineInfo& engineInfo) = 0;
  44. // Gems
  45. /**
  46. * Get info about a Gem
  47. * @param path the absolute path to the Gem
  48. * @return an outcome with GemInfo on success
  49. */
  50. virtual AZ::Outcome<GemInfo> GetGemInfo(const QString& path, const QString& projectPath = {}) = 0;
  51. /**
  52. * Get all available gem infos. This concatenates gems registered by the engine and the project.
  53. * @param path The absolute path to the project.
  54. * @return A list of gem infos.
  55. */
  56. virtual AZ::Outcome<QVector<GemInfo>, AZStd::string> GetAllGemInfos(const QString& projectPath) = 0;
  57. /**
  58. * Get engine gem infos.
  59. * @return A list of all registered gem infos.
  60. */
  61. virtual AZ::Outcome<QVector<GemInfo>, AZStd::string> GetEngineGemInfos() = 0;
  62. /**
  63. * Get a list of all enabled gem names for a given project.
  64. * @param[in] projectPath Absolute file path to the project.
  65. * @return A list of gem names of all the enabled gems for a given project or a error message on failure.
  66. */
  67. virtual AZ::Outcome<QVector<AZStd::string>, AZStd::string> GetEnabledGemNames(const QString& projectPath) = 0;
  68. // Projects
  69. /**
  70. * Create a project
  71. * @param projectTemplatePath the path to the project template to use
  72. * @param projectInfo the project info to use
  73. * @return an outcome with ProjectInfo on success
  74. */
  75. virtual AZ::Outcome<ProjectInfo> CreateProject(const QString& projectTemplatePath, const ProjectInfo& projectInfo) = 0;
  76. /**
  77. * Get info about a project
  78. * @param path the absolute path to the project
  79. * @return an outcome with ProjectInfo on success
  80. */
  81. virtual AZ::Outcome<ProjectInfo> GetProject(const QString& path) = 0;
  82. /**
  83. * Get info about all known projects
  84. * @return an outcome with ProjectInfos on success
  85. */
  86. virtual AZ::Outcome<QVector<ProjectInfo>> GetProjects() = 0;
  87. /**
  88. * Adds existing project on disk
  89. * @param path the absolute path to the project
  90. * @return true on success, false on failure
  91. */
  92. virtual bool AddProject(const QString& path) = 0;
  93. /**
  94. * Adds existing project on disk
  95. * @param path the absolute path to the project
  96. * @return true on success, false on failure
  97. */
  98. virtual bool RemoveProject(const QString& path) = 0;
  99. /**
  100. * Update a project
  101. * @param projectInfo the info to use to update the project
  102. * @return true on success, false on failure
  103. */
  104. virtual AZ::Outcome<void, AZStd::string> UpdateProject(const ProjectInfo& projectInfo) = 0;
  105. /**
  106. * Add a gem to a project
  107. * @param gemPath the absolute path to the gem
  108. * @param projectPath the absolute path to the project
  109. * @return An outcome with the success flag as well as an error message in case of a failure.
  110. */
  111. virtual AZ::Outcome<void, AZStd::string> AddGemToProject(const QString& gemPath, const QString& projectPath) = 0;
  112. /**
  113. * Remove gem to a project
  114. * @param gemPath the absolute path to the gem
  115. * @param projectPath the absolute path to the project
  116. * @return An outcome with the success flag as well as an error message in case of a failure.
  117. */
  118. virtual AZ::Outcome<void, AZStd::string> RemoveGemFromProject(const QString& gemPath, const QString& projectPath) = 0;
  119. /**
  120. * Removes invalid projects from the manifest
  121. */
  122. virtual bool RemoveInvalidProjects() = 0;
  123. // Project Templates
  124. /**
  125. * Get info about all known project templates
  126. * @return an outcome with ProjectTemplateInfos on success
  127. */
  128. virtual AZ::Outcome<QVector<ProjectTemplateInfo>> GetProjectTemplates(const QString& projectPath = {}) = 0;
  129. };
  130. using PythonBindingsInterface = AZ::Interface<IPythonBindings>;
  131. } // namespace O3DE::ProjectManager