1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_AUTOMOTIVE_COMPUTEPIPE_ROUTER_V1_0_PIPERUNNER
18 #define ANDROID_AUTOMOTIVE_COMPUTEPIPE_ROUTER_V1_0_PIPERUNNER
19 #include <aidl/android/automotive/computepipe/runner/IPipeRunner.h>
20 
21 #include <functional>
22 #include <memory>
23 #include <mutex>
24 
25 #include "PipeHandle.h"
26 #include "RemoteState.h"
27 
28 namespace android {
29 namespace automotive {
30 namespace computepipe {
31 namespace router {
32 namespace V1_0 {
33 namespace implementation {
34 
35 /**
36  * Wrapper for IPC handle
37  */
38 struct PipeRunner {
39     explicit PipeRunner(
40         const std::shared_ptr<aidl::android::automotive::computepipe::runner::IPipeRunner>&
41             graphRunner);
42     std::shared_ptr<aidl::android::automotive::computepipe::runner::IPipeRunner> runner;
43 };
44 
45 /**
46  * Runner Handle to be stored with registry.
47  *
48  * This is used to represent a runner at the time of registration as well as for
49  * query purposes
50  */
51 class RunnerHandle : public android::automotive::computepipe::router::PipeHandle<PipeRunner> {
52   public:
53     explicit RunnerHandle(
54         const std::shared_ptr<aidl::android::automotive::computepipe::runner::IPipeRunner>& r);
55     /**
56      * override registry pipehandle methods
57      */
58     bool isAlive() override;
59     bool startPipeMonitor() override;
60     PipeHandle<PipeRunner>* clone() const override;
61     ~RunnerHandle();
62 
63   private:
64     std::shared_ptr<RemoteState> mState;
65     ndk::ScopedAIBinder_DeathRecipient mDeathMonitor;
66 };
67 
68 }  // namespace implementation
69 }  // namespace V1_0
70 }  // namespace router
71 }  // namespace computepipe
72 }  // namespace automotive
73 }  // namespace android
74 #endif
75