blob: 6c4be2ca6438e9482c9eee69fa85950727f6a4a0 [file] [log] [blame]
François Gaffie20f06f92015-03-24 09:01:14 +01001/*
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
19class AudioPolicyManagerInterface;
20class AudioPolicyPluginInterface;
21
22namespace android
23{
24namespace audio_policy
25{
26
27class Engine;
28
29class EngineInstance
30{
31protected:
32 EngineInstance();
33
34public:
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
55protected:
56 /**
57 * Get Audio Policy Engine instance.
58 *
59 * @return Audio Policy Engine singleton.
60 */
61 Engine *getEngine() const;
62
63private:
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 */
73template <>
74AudioPolicyManagerInterface *EngineInstance::queryInterface() const;
75
76template <>
77AudioPolicyPluginInterface *EngineInstance::queryInterface() const;
78
79}; // namespace audio_policy
80
81}; // namespace android