PythonBindingsInterface.h 5.8 KB

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