1 #ifndef ANDROID_AUDIO_POLICY_CAPENGINE_CONFIGURATION_H 2 #define ANDROID_AUDIO_POLICY_CAPENGINE_CONFIGURATION_H 3 4 #include <array> 5 #include <map> 6 #include <optional> 7 #include <string> 8 #include <vector> 9 #include <sstream> 10 11 #if __has_include(<libxml/parser.h>) 12 #include <libxml/parser.h> 13 #include <libxml/xinclude.h> 14 #else 15 #error Require libxml2 library. Please add libxml2 to shared_libs or static_libs 16 #endif 17 18 #include "android_audio_policy_capengine_configuration_enums.h" 19 20 namespace android { 21 namespace audio { 22 namespace policy { 23 namespace capengine { 24 namespace configuration { 25 class BooleanParameterType; 26 class IntegerParameterType; 27 class EnumParameterType; 28 class PointParameterType; 29 class BitParameterBlockType; 30 class StringParameterType; 31 class ParameterBlockType; 32 class SelectionCriterionRuleType; 33 class CompoundRuleType; 34 class ConfigurationsType; 35 class ComponentType; 36 class ConfigurableElementsType; 37 class ConfigurableElementSettingsType; 38 class SettingsType; 39 class ConfigurableDomainType; 40 class ConfigurableDomains; 41 std::optional<ConfigurableDomains> readConfigurableDomains(const char* configFile); 42 43 std::optional<ConfigurableDomains> parseConfigurableDomains(const char* xml); 44 45 class BooleanParameterType { 46 private: 47 const ParameterNameEnumType name_; 48 const std::optional<std::string> value_; 49 public: 50 BooleanParameterType(ParameterNameEnumType name, std::string value); 51 const ParameterNameEnumType& getName() const; 52 bool hasName() const; 53 const std::string& getValue() const; 54 bool hasValue() const; 55 static BooleanParameterType read(xmlNode *root); 56 }; 57 58 class IntegerParameterType { 59 private: 60 const ParameterNameEnumType name_; 61 const std::optional<std::string> value_; 62 public: 63 IntegerParameterType(ParameterNameEnumType name, std::string value); 64 const ParameterNameEnumType& getName() const; 65 bool hasName() const; 66 const std::string& getValue() const; 67 bool hasValue() const; 68 static IntegerParameterType read(xmlNode *root); 69 }; 70 71 class EnumParameterType { 72 private: 73 const ParameterNameEnumType name_; 74 const std::optional<std::string> value_; 75 public: 76 EnumParameterType(ParameterNameEnumType name, std::string value); 77 const ParameterNameEnumType& getName() const; 78 bool hasName() const; 79 const std::string& getValue() const; 80 bool hasValue() const; 81 static EnumParameterType read(xmlNode *root); 82 }; 83 84 class PointParameterType { 85 private: 86 const ParameterNameEnumType name_; 87 const std::optional<std::string> value_; 88 public: 89 PointParameterType(ParameterNameEnumType name, std::string value); 90 const ParameterNameEnumType& getName() const; 91 bool hasName() const; 92 const std::string& getValue() const; 93 bool hasValue() const; 94 static PointParameterType read(xmlNode *root); 95 }; 96 97 class BitParameterBlockType { 98 private: 99 const std::vector<IntegerParameterType> bitParameter_; 100 const ParameterNameEnumType name_; 101 public: 102 BitParameterBlockType(std::vector<IntegerParameterType> bitParameter, ParameterNameEnumType name); 103 const std::vector<IntegerParameterType>& getBitParameter() const; 104 bool hasBitParameter() const; 105 const IntegerParameterType* getFirstBitParameter() const; 106 const ParameterNameEnumType& getName() const; 107 bool hasName() const; 108 static BitParameterBlockType read(xmlNode *root); 109 }; 110 111 class StringParameterType { 112 private: 113 const ParameterNameEnumType name_; 114 const std::optional<std::string> value_; 115 public: 116 StringParameterType(ParameterNameEnumType name, std::string value); 117 const ParameterNameEnumType& getName() const; 118 bool hasName() const; 119 const std::string& getValue() const; 120 bool hasValue() const; 121 static StringParameterType read(xmlNode *root); 122 }; 123 124 class ParameterBlockType { 125 private: 126 const std::vector<BooleanParameterType> booleanParameter_optional_; 127 const std::vector<IntegerParameterType> integerParameter_optional_; 128 const std::vector<EnumParameterType> enumParameter_optional_; 129 const std::vector<PointParameterType> fixedPointParameter_optional_; 130 const std::vector<PointParameterType> floatingPointParameter_optional_; 131 const std::vector<BitParameterBlockType> bitParameterBlock_optional_; 132 const std::vector<StringParameterType> stringParameter_optional_; 133 const std::vector<ParameterBlockType> parameterBlock_optional_; 134 const std::string name_; 135 public: 136 ParameterBlockType(std::vector<BooleanParameterType> booleanParameter_optional, std::vector<IntegerParameterType> integerParameter_optional, std::vector<EnumParameterType> enumParameter_optional, std::vector<PointParameterType> fixedPointParameter_optional, std::vector<PointParameterType> floatingPointParameter_optional, std::vector<BitParameterBlockType> bitParameterBlock_optional, std::vector<StringParameterType> stringParameter_optional, std::vector<ParameterBlockType> parameterBlock_optional, std::string name); 137 const std::vector<BooleanParameterType>& getBooleanParameter_optional() const; 138 bool hasBooleanParameter_optional() const; 139 const BooleanParameterType* getFirstBooleanParameter_optional() const; 140 const std::vector<IntegerParameterType>& getIntegerParameter_optional() const; 141 bool hasIntegerParameter_optional() const; 142 const IntegerParameterType* getFirstIntegerParameter_optional() const; 143 const std::vector<EnumParameterType>& getEnumParameter_optional() const; 144 bool hasEnumParameter_optional() const; 145 const EnumParameterType* getFirstEnumParameter_optional() const; 146 const std::vector<PointParameterType>& getFixedPointParameter_optional() const; 147 bool hasFixedPointParameter_optional() const; 148 const PointParameterType* getFirstFixedPointParameter_optional() const; 149 const std::vector<PointParameterType>& getFloatingPointParameter_optional() const; 150 bool hasFloatingPointParameter_optional() const; 151 const PointParameterType* getFirstFloatingPointParameter_optional() const; 152 const std::vector<BitParameterBlockType>& getBitParameterBlock_optional() const; 153 bool hasBitParameterBlock_optional() const; 154 const BitParameterBlockType* getFirstBitParameterBlock_optional() const; 155 const std::vector<StringParameterType>& getStringParameter_optional() const; 156 bool hasStringParameter_optional() const; 157 const StringParameterType* getFirstStringParameter_optional() const; 158 const std::vector<ParameterBlockType>& getParameterBlock_optional() const; 159 bool hasParameterBlock_optional() const; 160 const ParameterBlockType* getFirstParameterBlock_optional() const; 161 const std::string& getName() const; 162 bool hasName() const; 163 static ParameterBlockType read(xmlNode *root); 164 }; 165 166 class SelectionCriterionRuleType { 167 private: 168 const std::string selectionCriterion_; 169 const MatchesWhenEnum matchesWhen_; 170 const std::string value_; 171 public: 172 SelectionCriterionRuleType(std::string selectionCriterion, MatchesWhenEnum matchesWhen, std::string value); 173 const std::string& getSelectionCriterion() const; 174 bool hasSelectionCriterion() const; 175 const MatchesWhenEnum& getMatchesWhen() const; 176 bool hasMatchesWhen() const; 177 const std::string& getValue() const; 178 bool hasValue() const; 179 static SelectionCriterionRuleType read(xmlNode *root); 180 }; 181 182 class CompoundRuleType { 183 private: 184 const std::vector<CompoundRuleType> compoundRule_optional_; 185 const std::vector<SelectionCriterionRuleType> selectionCriterionRule_optional_; 186 const std::optional<TypeEnum> type_; 187 public: 188 CompoundRuleType(std::vector<CompoundRuleType> compoundRule_optional, std::vector<SelectionCriterionRuleType> selectionCriterionRule_optional, std::optional<TypeEnum> type); 189 const std::vector<CompoundRuleType>& getCompoundRule_optional() const; 190 bool hasCompoundRule_optional() const; 191 const CompoundRuleType* getFirstCompoundRule_optional() const; 192 const std::vector<SelectionCriterionRuleType>& getSelectionCriterionRule_optional() const; 193 bool hasSelectionCriterionRule_optional() const; 194 const SelectionCriterionRuleType* getFirstSelectionCriterionRule_optional() const; 195 const TypeEnum& getType() const; 196 bool hasType() const; 197 static CompoundRuleType read(xmlNode *root); 198 }; 199 200 class ConfigurationsType { 201 public: 202 class Configuration { 203 private: 204 const std::vector<CompoundRuleType> compoundRule_; 205 const std::string name_; 206 public: 207 Configuration(std::vector<CompoundRuleType> compoundRule, std::string name); 208 const std::vector<CompoundRuleType>& getCompoundRule() const; 209 bool hasCompoundRule() const; 210 const CompoundRuleType* getFirstCompoundRule() const; 211 const std::string& getName() const; 212 bool hasName() const; 213 static ConfigurationsType::Configuration read(xmlNode *root); 214 }; 215 216 217 private: 218 const std::vector<ConfigurationsType::Configuration> configuration_; 219 public: 220 explicit ConfigurationsType(std::vector<Configuration> configuration); 221 const std::vector<ConfigurationsType::Configuration>& getConfiguration() const; 222 bool hasConfiguration() const; 223 const ConfigurationsType::Configuration* getFirstConfiguration() const; 224 static ConfigurationsType read(xmlNode *root); 225 }; 226 227 class ComponentType { 228 private: 229 const std::vector<ComponentType> subsystem_optional_; 230 const std::string name_; 231 public: 232 ComponentType(std::vector<ComponentType> subsystem_optional, std::string name); 233 const std::vector<ComponentType>& getSubsystem_optional() const; 234 bool hasSubsystem_optional() const; 235 const ComponentType* getFirstSubsystem_optional() const; 236 const std::string& getName() const; 237 bool hasName() const; 238 static ComponentType read(xmlNode *root); 239 }; 240 241 class ConfigurableElementsType { 242 public: 243 class ConfigurableElement { 244 private: 245 const std::string path_; 246 public: 247 explicit ConfigurableElement(std::string path); 248 const std::string& getPath() const; 249 bool hasPath() const; 250 static ConfigurableElementsType::ConfigurableElement read(xmlNode *root); 251 }; 252 253 254 private: 255 const std::vector<ConfigurableElementsType::ConfigurableElement> configurableElement_; 256 public: 257 explicit ConfigurableElementsType(std::vector<ConfigurableElement> configurableElement); 258 const std::vector<ConfigurableElementsType::ConfigurableElement>& getConfigurableElement() const; 259 bool hasConfigurableElement() const; 260 const ConfigurableElementsType::ConfigurableElement* getFirstConfigurableElement() const; 261 static ConfigurableElementsType read(xmlNode *root); 262 }; 263 264 class ConfigurableElementSettingsType { 265 private: 266 const std::vector<BooleanParameterType> booleanParameter_optional_; 267 const std::vector<IntegerParameterType> integerParameter_optional_; 268 const std::vector<EnumParameterType> enumParameter_optional_; 269 const std::vector<PointParameterType> fixedPointParameter_optional_; 270 const std::vector<PointParameterType> floatingPointParameter_optional_; 271 const std::vector<IntegerParameterType> bitParameter_optional_; 272 const std::vector<BitParameterBlockType> bitParameterBlock_optional_; 273 const std::vector<StringParameterType> stringParameter_optional_; 274 const std::vector<ParameterBlockType> parameterBlock_optional_; 275 const std::string path_; 276 public: 277 ConfigurableElementSettingsType(std::vector<BooleanParameterType> booleanParameter_optional, std::vector<IntegerParameterType> integerParameter_optional, std::vector<EnumParameterType> enumParameter_optional, std::vector<PointParameterType> fixedPointParameter_optional, std::vector<PointParameterType> floatingPointParameter_optional, std::vector<IntegerParameterType> bitParameter_optional, std::vector<BitParameterBlockType> bitParameterBlock_optional, std::vector<StringParameterType> stringParameter_optional, std::vector<ParameterBlockType> parameterBlock_optional, std::string path); 278 const std::vector<BooleanParameterType>& getBooleanParameter_optional() const; 279 bool hasBooleanParameter_optional() const; 280 const BooleanParameterType* getFirstBooleanParameter_optional() const; 281 const std::vector<IntegerParameterType>& getIntegerParameter_optional() const; 282 bool hasIntegerParameter_optional() const; 283 const IntegerParameterType* getFirstIntegerParameter_optional() const; 284 const std::vector<EnumParameterType>& getEnumParameter_optional() const; 285 bool hasEnumParameter_optional() const; 286 const EnumParameterType* getFirstEnumParameter_optional() const; 287 const std::vector<PointParameterType>& getFixedPointParameter_optional() const; 288 bool hasFixedPointParameter_optional() const; 289 const PointParameterType* getFirstFixedPointParameter_optional() const; 290 const std::vector<PointParameterType>& getFloatingPointParameter_optional() const; 291 bool hasFloatingPointParameter_optional() const; 292 const PointParameterType* getFirstFloatingPointParameter_optional() const; 293 const std::vector<IntegerParameterType>& getBitParameter_optional() const; 294 bool hasBitParameter_optional() const; 295 const IntegerParameterType* getFirstBitParameter_optional() const; 296 const std::vector<BitParameterBlockType>& getBitParameterBlock_optional() const; 297 bool hasBitParameterBlock_optional() const; 298 const BitParameterBlockType* getFirstBitParameterBlock_optional() const; 299 const std::vector<StringParameterType>& getStringParameter_optional() const; 300 bool hasStringParameter_optional() const; 301 const StringParameterType* getFirstStringParameter_optional() const; 302 const std::vector<ParameterBlockType>& getParameterBlock_optional() const; 303 bool hasParameterBlock_optional() const; 304 const ParameterBlockType* getFirstParameterBlock_optional() const; 305 const std::string& getPath() const; 306 bool hasPath() const; 307 static ConfigurableElementSettingsType read(xmlNode *root); 308 }; 309 310 class SettingsType { 311 public: 312 class Configuration { 313 private: 314 const std::vector<ConfigurableElementSettingsType> configurableElement_; 315 const std::string name_; 316 public: 317 Configuration(std::vector<ConfigurableElementSettingsType> configurableElement, std::string name); 318 const std::vector<ConfigurableElementSettingsType>& getConfigurableElement() const; 319 bool hasConfigurableElement() const; 320 const ConfigurableElementSettingsType* getFirstConfigurableElement() const; 321 const std::string& getName() const; 322 bool hasName() const; 323 static SettingsType::Configuration read(xmlNode *root); 324 }; 325 326 327 private: 328 const std::vector<SettingsType::Configuration> configuration_; 329 public: 330 explicit SettingsType(std::vector<Configuration> configuration); 331 const std::vector<SettingsType::Configuration>& getConfiguration() const; 332 bool hasConfiguration() const; 333 const SettingsType::Configuration* getFirstConfiguration() const; 334 static SettingsType read(xmlNode *root); 335 }; 336 337 class ConfigurableDomainType { 338 private: 339 const std::vector<ConfigurationsType> configurations_; 340 const std::vector<ConfigurableElementsType> configurableElements_; 341 const std::vector<SettingsType> settings_; 342 const std::string name_; 343 const std::optional<bool> sequenceAware_; 344 public: 345 ConfigurableDomainType(std::vector<ConfigurationsType> configurations, std::vector<ConfigurableElementsType> configurableElements, std::vector<SettingsType> settings, std::string name, std::optional<bool> sequenceAware); 346 const std::vector<ConfigurationsType>& getConfigurations() const; 347 bool hasConfigurations() const; 348 const ConfigurationsType* getFirstConfigurations() const; 349 const std::vector<ConfigurableElementsType>& getConfigurableElements() const; 350 bool hasConfigurableElements() const; 351 const ConfigurableElementsType* getFirstConfigurableElements() const; 352 const std::vector<SettingsType>& getSettings() const; 353 bool hasSettings() const; 354 const SettingsType* getFirstSettings() const; 355 const std::string& getName() const; 356 bool hasName() const; 357 const bool& getSequenceAware() const; 358 bool hasSequenceAware() const; 359 static ConfigurableDomainType read(xmlNode *root); 360 }; 361 362 class ConfigurableDomains { 363 private: 364 const std::vector<ConfigurableDomainType> configurableDomain_; 365 const std::string systemClassName_; 366 public: 367 ConfigurableDomains(std::vector<ConfigurableDomainType> configurableDomain, std::string systemClassName); 368 const std::vector<ConfigurableDomainType>& getConfigurableDomain() const; 369 bool hasConfigurableDomain() const; 370 const ConfigurableDomainType* getFirstConfigurableDomain() const; 371 const std::string& getSystemClassName() const; 372 bool hasSystemClassName() const; 373 static ConfigurableDomains read(xmlNode *root); 374 }; 375 376 } // configuration 377 } // capengine 378 } // policy 379 } // audio 380 } // android 381 #endif // ANDROID_AUDIO_POLICY_CAPENGINE_CONFIGURATION_H 382