1 // Copyright 2018 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 ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
16 #define ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
17 
18 #include <inttypes.h>
19 #include "goldfish_dma.h"
20 
21 // A C++ wrapper for goldfish_dma_context that releases resources in dctor.
22 class AutoGoldfishDmaContext {
23 public:
24     AutoGoldfishDmaContext();
25     explicit AutoGoldfishDmaContext(goldfish_dma_context *ctx);
26     ~AutoGoldfishDmaContext();
27 
get()28     const goldfish_dma_context &get() const { return m_ctx; }
29     void reset(goldfish_dma_context *ctx);
30     goldfish_dma_context release();
31 
32 private:
33     AutoGoldfishDmaContext(const AutoGoldfishDmaContext &rhs);
34     AutoGoldfishDmaContext& operator=(const AutoGoldfishDmaContext &rhs);
35 
36     goldfish_dma_context m_ctx;
37 };
38 
39 #endif  // ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
40