blob: efc69da15e9e173de0be9e82f19c79e276a6d05e [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
François Gaffief19cf792018-05-30 17:22:17 +020022namespace android {
23namespace audio_policy {
François Gaffie20f06f92015-03-24 09:01:14 +010024
25class Engine;
26
27class EngineInstance
28{
29protected:
30 EngineInstance();
31
32public:
33 virtual ~EngineInstance();
34
35 /**
36 * Get Audio Policy Engine instance.
37 *
38 * @return pointer to Route Manager Instance object.
39 */
40 static EngineInstance *getInstance();
41
42 /**
43 * Interface query.
44 * The first client of an interface of the policy engine will start the singleton.
45 *
46 * @tparam RequestedInterface: interface that the client is wishing to retrieve.
47 *
48 * @return interface handle.
49 */
50 template <class RequestedInterface>
51 RequestedInterface *queryInterface() const;
52
53protected:
54 /**
55 * Get Audio Policy Engine instance.
56 *
57 * @return Audio Policy Engine singleton.
58 */
59 Engine *getEngine() const;
60
61private:
62 /* Copy facilities are put private to disable copy. */
63 EngineInstance(const EngineInstance &object);
64 EngineInstance &operator=(const EngineInstance &object);
65};
66
67/**
68 * Limit template instantation to supported type interfaces.
69 * Compile time error will claim if invalid interface is requested.
70 */
71template <>
72AudioPolicyManagerInterface *EngineInstance::queryInterface() const;
73
74template <>
75AudioPolicyPluginInterface *EngineInstance::queryInterface() const;
76
Mikhail Naganov1b2a7942017-12-08 10:18:09 -080077} // namespace audio_policy
François Gaffie20f06f92015-03-24 09:01:14 +010078
Mikhail Naganov1b2a7942017-12-08 10:18:09 -080079} // namespace android