1 /* 2 * Copyright (C) 2018 Google, Inc. 3 * 4 * This software is licensed under the terms of the GNU General Public 5 * License version 2, as published by the Free Software Foundation, and 6 * may be copied, distributed, and modified under those terms. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 */ 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 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