1 // Copyright (C) 2019 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef COMPUTEPIPE_RUNNER_ENGINE_H 16 #define COMPUTEPIPE_RUNNER_ENGINE_H 17 18 #include <memory> 19 #include <string> 20 21 #include "ClientInterface.h" 22 #include "PrebuiltGraph.h" 23 #include "types/Status.h" 24 25 namespace android { 26 namespace automotive { 27 namespace computepipe { 28 namespace runner { 29 namespace engine { 30 31 /** 32 * Class that offers an interface into an engine. It derives from the client, 33 * prebuilt -> engine interfaces to enforce that any instantiation of an engine 34 * needs to provide an implementation for those interfaces. 35 */ 36 class RunnerEngine : public client_interface::ClientEngineInterface, 37 public graph::PrebuiltEngineInterface { 38 public: 39 /** 40 * Any args that a given engine instance needs in order to configure itself. 41 */ 42 virtual Status setArgs(std::string engine_args) = 0; 43 /** 44 * Set the client and the prebuilt graph instances 45 */ 46 virtual void setClientInterface(std::unique_ptr<client_interface::ClientInterface>&& client) = 0; 47 48 virtual void setPrebuiltGraph(std::unique_ptr<graph::PrebuiltGraph>&& graph) = 0; 49 /** 50 * Activates the client interface and advertises to the rest of the world 51 * that the runner is online 52 */ 53 virtual Status activate() = 0; 54 }; 55 56 class RunnerEngineFactory { 57 public: 58 static constexpr char kDefault[] = "default_engine"; 59 std::unique_ptr<RunnerEngine> createRunnerEngine(std::string engine, std::string engine_args); 60 RunnerEngineFactory(const RunnerEngineFactory&) = delete; 61 RunnerEngineFactory& operator=(const RunnerEngineFactory&) = delete; 62 RunnerEngineFactory() = default; 63 }; 64 65 } // namespace engine 66 } // namespace runner 67 } // namespace computepipe 68 } // namespace automotive 69 } // namespace android 70 71 #endif 72