1 /* 2 * Copyright (C) 2015 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 #pragma once 18 19 class AudioPolicyManagerInterface; 20 class AudioPolicyPluginInterface; 21 22 namespace android 23 { 24 namespace audio_policy 25 { 26 27 class Engine; 28 29 class EngineInstance 30 { 31 protected: 32 EngineInstance(); 33 34 public: 35 virtual ~EngineInstance(); 36 37 /** 38 * Get Audio Policy Engine instance. 39 * 40 * @return pointer to Route Manager Instance object. 41 */ 42 static EngineInstance *getInstance(); 43 44 /** 45 * Interface query. 46 * The first client of an interface of the policy engine will start the singleton. 47 * 48 * @tparam RequestedInterface: interface that the client is wishing to retrieve. 49 * 50 * @return interface handle. 51 */ 52 template <class RequestedInterface> 53 RequestedInterface *queryInterface() const; 54 55 protected: 56 /** 57 * Get Audio Policy Engine instance. 58 * 59 * @return Audio Policy Engine singleton. 60 */ 61 Engine *getEngine() const; 62 63 private: 64 /* Copy facilities are put private to disable copy. */ 65 EngineInstance(const EngineInstance &object); 66 EngineInstance &operator=(const EngineInstance &object); 67 }; 68 69 /** 70 * Limit template instantation to supported type interfaces. 71 * Compile time error will claim if invalid interface is requested. 72 */ 73 template <> 74 AudioPolicyManagerInterface *EngineInstance::queryInterface() const; 75 76 template <> 77 AudioPolicyPluginInterface *EngineInstance::queryInterface() const; 78 79 }; // namespace audio_policy 80 81 }; // namespace android 82