1*c33452fbSAndroid Build Coastguard Worker /* 2*c33452fbSAndroid Build Coastguard Worker * Copyright (c) 2011-2015, Intel Corporation 3*c33452fbSAndroid Build Coastguard Worker * All rights reserved. 4*c33452fbSAndroid Build Coastguard Worker * 5*c33452fbSAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without modification, 6*c33452fbSAndroid Build Coastguard Worker * are permitted provided that the following conditions are met: 7*c33452fbSAndroid Build Coastguard Worker * 8*c33452fbSAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright notice, this 9*c33452fbSAndroid Build Coastguard Worker * list of conditions and the following disclaimer. 10*c33452fbSAndroid Build Coastguard Worker * 11*c33452fbSAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright notice, 12*c33452fbSAndroid Build Coastguard Worker * this list of conditions and the following disclaimer in the documentation and/or 13*c33452fbSAndroid Build Coastguard Worker * other materials provided with the distribution. 14*c33452fbSAndroid Build Coastguard Worker * 15*c33452fbSAndroid Build Coastguard Worker * 3. Neither the name of the copyright holder nor the names of its contributors 16*c33452fbSAndroid Build Coastguard Worker * may be used to endorse or promote products derived from this software without 17*c33452fbSAndroid Build Coastguard Worker * specific prior written permission. 18*c33452fbSAndroid Build Coastguard Worker * 19*c33452fbSAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20*c33452fbSAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21*c33452fbSAndroid Build Coastguard Worker * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22*c33452fbSAndroid Build Coastguard Worker * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23*c33452fbSAndroid Build Coastguard Worker * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24*c33452fbSAndroid Build Coastguard Worker * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25*c33452fbSAndroid Build Coastguard Worker * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26*c33452fbSAndroid Build Coastguard Worker * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27*c33452fbSAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28*c33452fbSAndroid Build Coastguard Worker * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*c33452fbSAndroid Build Coastguard Worker */ 30*c33452fbSAndroid Build Coastguard Worker #pragma once 31*c33452fbSAndroid Build Coastguard Worker 32*c33452fbSAndroid Build Coastguard Worker #include "Element.h" 33*c33452fbSAndroid Build Coastguard Worker #include "Results.h" 34*c33452fbSAndroid Build Coastguard Worker #include <set> 35*c33452fbSAndroid Build Coastguard Worker #include <string> 36*c33452fbSAndroid Build Coastguard Worker 37*c33452fbSAndroid Build Coastguard Worker class CParameterBlackboard; 38*c33452fbSAndroid Build Coastguard Worker class CConfigurableElement; 39*c33452fbSAndroid Build Coastguard Worker class CSyncerSet; 40*c33452fbSAndroid Build Coastguard Worker class CConfigurableDomain; 41*c33452fbSAndroid Build Coastguard Worker class CSelectionCriteriaDefinition; 42*c33452fbSAndroid Build Coastguard Worker 43*c33452fbSAndroid Build Coastguard Worker class CConfigurableDomains : public CElement 44*c33452fbSAndroid Build Coastguard Worker { 45*c33452fbSAndroid Build Coastguard Worker public: 46*c33452fbSAndroid Build Coastguard Worker // Configuration/Domains handling 47*c33452fbSAndroid Build Coastguard Worker /// Domains 48*c33452fbSAndroid Build Coastguard Worker bool createDomain(const std::string &strName, std::string &strError); 49*c33452fbSAndroid Build Coastguard Worker 50*c33452fbSAndroid Build Coastguard Worker /* 51*c33452fbSAndroid Build Coastguard Worker * Adds a domain object to configurable domains. The ConfigurableDomains 52*c33452fbSAndroid Build Coastguard Worker * object takes ownership of the ConfigurableDomain object. 53*c33452fbSAndroid Build Coastguard Worker * 54*c33452fbSAndroid Build Coastguard Worker * @param[in] pDomain the domain object. 55*c33452fbSAndroid Build Coastguard Worker * @param[in] bOverwrite if false, will refuse to overwrite an existing 56*c33452fbSAndroid Build Coastguard Worker * domain, otherwise, an existing domain with the same name will first be 57*c33452fbSAndroid Build Coastguard Worker * removed. 58*c33452fbSAndroid Build Coastguard Worker * @param[in,out] strError error message 59*c33452fbSAndroid Build Coastguard Worker * 60*c33452fbSAndroid Build Coastguard Worker * @returns true if the domain was successfully added 61*c33452fbSAndroid Build Coastguard Worker */ 62*c33452fbSAndroid Build Coastguard Worker bool addDomain(CConfigurableDomain &domain, bool bOverwrite, std::string &strError); 63*c33452fbSAndroid Build Coastguard Worker 64*c33452fbSAndroid Build Coastguard Worker /** 65*c33452fbSAndroid Build Coastguard Worker * Delete a domain by name 66*c33452fbSAndroid Build Coastguard Worker * 67*c33452fbSAndroid Build Coastguard Worker * @param[in] strName name of the domain to be deleted 68*c33452fbSAndroid Build Coastguard Worker * @param[in,out] strError error message 69*c33452fbSAndroid Build Coastguard Worker * 70*c33452fbSAndroid Build Coastguard Worker * @returns true of the domain was sucessfully deleted, false otherwise (i.e. 71*c33452fbSAndroid Build Coastguard Worker * the domain didn't exist). 72*c33452fbSAndroid Build Coastguard Worker */ 73*c33452fbSAndroid Build Coastguard Worker bool deleteDomain(const std::string &strName, std::string &strError); 74*c33452fbSAndroid Build Coastguard Worker void deleteAllDomains(); 75*c33452fbSAndroid Build Coastguard Worker bool renameDomain(const std::string &strName, const std::string &strNewName, 76*c33452fbSAndroid Build Coastguard Worker std::string &strError); 77*c33452fbSAndroid Build Coastguard Worker bool setSequenceAwareness(const std::string &strDomain, bool bSequenceAware, 78*c33452fbSAndroid Build Coastguard Worker std::string &strError); 79*c33452fbSAndroid Build Coastguard Worker bool getSequenceAwareness(const std::string &strDomain, bool &bSequenceAware, 80*c33452fbSAndroid Build Coastguard Worker std::string &strError) const; 81*c33452fbSAndroid Build Coastguard Worker bool listDomainElements(const std::string &strDomain, std::string &strResult) const; 82*c33452fbSAndroid Build Coastguard Worker 83*c33452fbSAndroid Build Coastguard Worker /** Split a domain in two. 84*c33452fbSAndroid Build Coastguard Worker * Remove an element of a domain and create a new domain which owns the element. 85*c33452fbSAndroid Build Coastguard Worker * 86*c33452fbSAndroid Build Coastguard Worker * @param[in] domainName the domain name 87*c33452fbSAndroid Build Coastguard Worker * @param[in] element pointer to the element to remove 88*c33452fbSAndroid Build Coastguard Worker * @param[out] infos useful information we can provide to client 89*c33452fbSAndroid Build Coastguard Worker * @return true if succeed false otherwise 90*c33452fbSAndroid Build Coastguard Worker */ 91*c33452fbSAndroid Build Coastguard Worker bool split(const std::string &domainName, CConfigurableElement *element, core::Results &infos); 92*c33452fbSAndroid Build Coastguard Worker 93*c33452fbSAndroid Build Coastguard Worker void listAssociatedElements(std::string &strResult) const; 94*c33452fbSAndroid Build Coastguard Worker void listConflictingElements(std::string &strResult) const; 95*c33452fbSAndroid Build Coastguard Worker void listDomains(std::string &strResult) const; 96*c33452fbSAndroid Build Coastguard Worker /// Configurations 97*c33452fbSAndroid Build Coastguard Worker bool listConfigurations(const std::string &strDomain, std::string &strResult) const; 98*c33452fbSAndroid Build Coastguard Worker bool createConfiguration(const std::string &strDomain, const std::string &strConfiguration, 99*c33452fbSAndroid Build Coastguard Worker const CParameterBlackboard *pMainBlackboard, std::string &strError); 100*c33452fbSAndroid Build Coastguard Worker bool deleteConfiguration(const std::string &strDomain, const std::string &strConfiguration, 101*c33452fbSAndroid Build Coastguard Worker std::string &strError); 102*c33452fbSAndroid Build Coastguard Worker bool renameConfiguration(const std::string &strDomain, const std::string &strConfigurationName, 103*c33452fbSAndroid Build Coastguard Worker const std::string &strNewConfigurationName, std::string &strError); 104*c33452fbSAndroid Build Coastguard Worker 105*c33452fbSAndroid Build Coastguard Worker /** Restore a configuration 106*c33452fbSAndroid Build Coastguard Worker * 107*c33452fbSAndroid Build Coastguard Worker * @param[in] strDomain the domain name 108*c33452fbSAndroid Build Coastguard Worker * @param[in] strConfiguration the configuration name 109*c33452fbSAndroid Build Coastguard Worker * @param[in] pMainBlackboard the application main blackboard 110*c33452fbSAndroid Build Coastguard Worker * @param[in] bAutoSync boolean which indicates if auto sync mechanism is on 111*c33452fbSAndroid Build Coastguard Worker * @param[out] errors, errors encountered during restoration 112*c33452fbSAndroid Build Coastguard Worker * @return true if success false otherwise 113*c33452fbSAndroid Build Coastguard Worker */ 114*c33452fbSAndroid Build Coastguard Worker bool restoreConfiguration(const std::string &strDomain, const std::string &strConfiguration, 115*c33452fbSAndroid Build Coastguard Worker CParameterBlackboard *pMainBlackboard, bool bAutoSync, 116*c33452fbSAndroid Build Coastguard Worker core::Results &errors) const; 117*c33452fbSAndroid Build Coastguard Worker 118*c33452fbSAndroid Build Coastguard Worker bool saveConfiguration(const std::string &strDomain, const std::string &strConfiguration, 119*c33452fbSAndroid Build Coastguard Worker const CParameterBlackboard *pMainBlackboard, std::string &strError); 120*c33452fbSAndroid Build Coastguard Worker bool setElementSequence(const std::string &strDomain, const std::string &strConfiguration, 121*c33452fbSAndroid Build Coastguard Worker const std::vector<std::string> &astrNewElementSequence, 122*c33452fbSAndroid Build Coastguard Worker std::string &strError); 123*c33452fbSAndroid Build Coastguard Worker bool getElementSequence(const std::string &strDomain, const std::string &strConfiguration, 124*c33452fbSAndroid Build Coastguard Worker std::string &strResult) const; 125*c33452fbSAndroid Build Coastguard Worker bool setApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 126*c33452fbSAndroid Build Coastguard Worker const std::string &strApplicationRule, 127*c33452fbSAndroid Build Coastguard Worker const CSelectionCriteriaDefinition *pSelectionCriteriaDefinition, 128*c33452fbSAndroid Build Coastguard Worker std::string &strError); 129*c33452fbSAndroid Build Coastguard Worker bool clearApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 130*c33452fbSAndroid Build Coastguard Worker std::string &strError); 131*c33452fbSAndroid Build Coastguard Worker bool getApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 132*c33452fbSAndroid Build Coastguard Worker std::string &strResult) const; 133*c33452fbSAndroid Build Coastguard Worker 134*c33452fbSAndroid Build Coastguard Worker // Last applied configurations 135*c33452fbSAndroid Build Coastguard Worker void listLastAppliedConfigurations(std::string &strResult) const; 136*c33452fbSAndroid Build Coastguard Worker 137*c33452fbSAndroid Build Coastguard Worker /** Associate a configurable element to a domain 138*c33452fbSAndroid Build Coastguard Worker * 139*c33452fbSAndroid Build Coastguard Worker * @param[in] domainName the domain name 140*c33452fbSAndroid Build Coastguard Worker * @param[in] element pointer to the element to add 141*c33452fbSAndroid Build Coastguard Worker * @param[in] mainBlackboard pointer to the application main blackboard 142*c33452fbSAndroid Build Coastguard Worker * @param[out] infos useful information we can provide to client 143*c33452fbSAndroid Build Coastguard Worker * @return true if succeed false otherwise 144*c33452fbSAndroid Build Coastguard Worker */ 145*c33452fbSAndroid Build Coastguard Worker bool addConfigurableElementToDomain(const std::string &domainName, 146*c33452fbSAndroid Build Coastguard Worker CConfigurableElement *element, 147*c33452fbSAndroid Build Coastguard Worker const CParameterBlackboard *mainBlackboard, 148*c33452fbSAndroid Build Coastguard Worker core::Results &infos); 149*c33452fbSAndroid Build Coastguard Worker 150*c33452fbSAndroid Build Coastguard Worker bool removeConfigurableElementFromDomain(const std::string &strDomain, 151*c33452fbSAndroid Build Coastguard Worker CConfigurableElement *pConfigurableElement, 152*c33452fbSAndroid Build Coastguard Worker std::string &strError); 153*c33452fbSAndroid Build Coastguard Worker 154*c33452fbSAndroid Build Coastguard Worker // Configuration Blackboard for element 155*c33452fbSAndroid Build Coastguard Worker CParameterBlackboard *findConfigurationBlackboard( 156*c33452fbSAndroid Build Coastguard Worker const std::string &strDomain, const std::string &strConfiguration, 157*c33452fbSAndroid Build Coastguard Worker const CConfigurableElement *pConfigurableElement, size_t &baseOffset, bool &bIsLastApplied, 158*c33452fbSAndroid Build Coastguard Worker std::string &strError) const; 159*c33452fbSAndroid Build Coastguard Worker 160*c33452fbSAndroid Build Coastguard Worker const CConfigurableDomain *findConfigurableDomain(const std::string &strDomain, 161*c33452fbSAndroid Build Coastguard Worker std::string &strError) const; 162*c33452fbSAndroid Build Coastguard Worker 163*c33452fbSAndroid Build Coastguard Worker // From IXmlSource 164*c33452fbSAndroid Build Coastguard Worker void toXml(CXmlElement &xmlElement, CXmlSerializingContext &serializingContext) const override; 165*c33452fbSAndroid Build Coastguard Worker 166*c33452fbSAndroid Build Coastguard Worker // Ensure validity on whole domains from main blackboard 167*c33452fbSAndroid Build Coastguard Worker void validate(const CParameterBlackboard *pMainBlackboard); 168*c33452fbSAndroid Build Coastguard Worker 169*c33452fbSAndroid Build Coastguard Worker /** Apply the configuration if required 170*c33452fbSAndroid Build Coastguard Worker * 171*c33452fbSAndroid Build Coastguard Worker * @param[in] pParameterBlackboard the blackboard to synchronize 172*c33452fbSAndroid Build Coastguard Worker * @param[in] syncerSet the set containing application syncers 173*c33452fbSAndroid Build Coastguard Worker * @param[in] bForce boolean used to force configuration application 174*c33452fbSAndroid Build Coastguard Worker * @param[out] infos useful information we can provide to client 175*c33452fbSAndroid Build Coastguard Worker */ 176*c33452fbSAndroid Build Coastguard Worker void apply(CParameterBlackboard *pParameterBlackboard, CSyncerSet &syncerSet, bool bForce, 177*c33452fbSAndroid Build Coastguard Worker core::Results &infos) const; 178*c33452fbSAndroid Build Coastguard Worker 179*c33452fbSAndroid Build Coastguard Worker // Class kind 180*c33452fbSAndroid Build Coastguard Worker std::string getKind() const override; 181*c33452fbSAndroid Build Coastguard Worker 182*c33452fbSAndroid Build Coastguard Worker private: 183*c33452fbSAndroid Build Coastguard Worker /** Delete a domain 184*c33452fbSAndroid Build Coastguard Worker * 185*c33452fbSAndroid Build Coastguard Worker * @param(in] configurableDomain domain to be deleted 186*c33452fbSAndroid Build Coastguard Worker * @param[in,out] strError error message 187*c33452fbSAndroid Build Coastguard Worker * @returns true of the domain was sucessfully deleted, false otherwise (i.e. 188*c33452fbSAndroid Build Coastguard Worker * the domain didn't exist). 189*c33452fbSAndroid Build Coastguard Worker */ 190*c33452fbSAndroid Build Coastguard Worker void deleteDomain(CConfigurableDomain &configurableDomain); 191*c33452fbSAndroid Build Coastguard Worker // Returns true if children dynamic creation is to be dealt with 192*c33452fbSAndroid Build Coastguard Worker bool childrenAreDynamic() const override; 193*c33452fbSAndroid Build Coastguard Worker // Gather owned configurable elements owned by any domain 194*c33452fbSAndroid Build Coastguard Worker void gatherAllOwnedConfigurableElements( 195*c33452fbSAndroid Build Coastguard Worker std::set<const CConfigurableElement *> &configurableElementSet) const; 196*c33452fbSAndroid Build Coastguard Worker // Domain retrieval 197*c33452fbSAndroid Build Coastguard Worker CConfigurableDomain *findConfigurableDomain(const std::string &strDomain, 198*c33452fbSAndroid Build Coastguard Worker std::string &strError); 199*c33452fbSAndroid Build Coastguard Worker }; 200