blob: a4fdd39b311151c1a454277b89288be6d7007279 [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
19#include "Element.h"
20#include "EngineDefinition.h"
François Gaffie20f06f92015-03-24 09:01:14 +010021#include <map>
22
François Gaffief19cf792018-05-30 17:22:17 +020023namespace android {
24namespace audio_policy {
25
François Gaffie20f06f92015-03-24 09:01:14 +010026/**
François Gaffie6054a772018-11-06 13:10:58 +010027 * @tparam product_strategy_t: Applicable strategy for this stream.
François Gaffie20f06f92015-03-24 09:01:14 +010028 */
29template <>
30class Element<audio_stream_type_t>
31{
François Gaffie20f06f92015-03-24 09:01:14 +010032public:
33 Element(const std::string &name)
François Gaffie6054a772018-11-06 13:10:58 +010034 : mName(name)
François Gaffie20f06f92015-03-24 09:01:14 +010035 {}
36 ~Element() {}
37
38 /**
39 * Returns identifier of this policy element
40 *
41 * @returns string representing the name of this policy element
42 */
43 const std::string &getName() const { return mName; }
44
45 /**
46 * Set the unique identifier for this policy element.
47 *
48 * @tparam Key type of the unique identifier.
49 * @param[in] identifier to be set.
50 *
51 * @return NO_ERROR if the identifier is valid and set correctly, error code otherwise.
52 */
53 status_t setIdentifier(audio_stream_type_t identifier);
54
55 /**
56 * @return the unique identifier of this policy element.
57 */
58 audio_stream_type_t getIdentifier() const { return mIdentifier; }
59
60 /**
61 * A Policy element may implement getter/setter function for a given property.
François Gaffie6054a772018-11-06 13:10:58 +010062 * Property may be audio_stream_type_t, audio_usage_t, audio_source_t
François Gaffie20f06f92015-03-24 09:01:14 +010063 * or a string.
64 */
65 template <typename Property>
66 Property get() const;
67
68 template <typename Property>
69 status_t set(Property property);
70
François Gaffie20f06f92015-03-24 09:01:14 +010071private:
72 /* Copy facilities are put private to disable copy. */
73 Element(const Element &object);
74 Element &operator=(const Element &object);
75
76 std::string mName; /**< Unique literal Identifier of a policy base element*/
77 audio_stream_type_t mIdentifier; /**< Unique numerical Identifier of a policy base element*/
78
François Gaffied1ab2bd2015-12-02 18:20:06 +010079 audio_stream_type_t mVolumeProfile; /**< Volume Profile followed by this stream. */
François Gaffie20f06f92015-03-24 09:01:14 +010080};
81
82typedef Element<audio_stream_type_t> Stream;
83
84} // namespace audio_policy
85} // namespace android
86
87