PythonBindingsInterface.h 6.0 KB

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