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