1*c33452fbSAndroid Build Coastguard Worker /* 2*c33452fbSAndroid Build Coastguard Worker * Copyright (c) 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 // The generated python module will be named "PyPfw" 31*c33452fbSAndroid Build Coastguard Worker // the "directors" feature is used to derive Python classes and make them look 32*c33452fbSAndroid Build Coastguard Worker // like derived C++ classes (calls to virtual methods will be properly 33*c33452fbSAndroid Build Coastguard Worker // forwarded to Python) - only on classes for which is it specified, see 34*c33452fbSAndroid Build Coastguard Worker // ILogger below.. 35*c33452fbSAndroid Build Coastguard Worker %module(directors="1", threads="1") PyPfw 36*c33452fbSAndroid Build Coastguard Worker 37*c33452fbSAndroid Build Coastguard Worker %feature("director:except") { 38*c33452fbSAndroid Build Coastguard Worker if ($error != NULL) { 39*c33452fbSAndroid Build Coastguard Worker throw Swig::DirectorMethodException(); 40*c33452fbSAndroid Build Coastguard Worker } 41*c33452fbSAndroid Build Coastguard Worker } 42*c33452fbSAndroid Build Coastguard Worker %exception { 43*c33452fbSAndroid Build Coastguard Worker try { $action } catch(Swig::DirectorException & e)44*c33452fbSAndroid Build Coastguard Worker catch (Swig::DirectorException &e) { SWIG_fail; } 45*c33452fbSAndroid Build Coastguard Worker } 46*c33452fbSAndroid Build Coastguard Worker 47*c33452fbSAndroid Build Coastguard Worker %include "std_string.i" 48*c33452fbSAndroid Build Coastguard Worker %include "std_vector.i" 49*c33452fbSAndroid Build Coastguard Worker %include "typemaps.i" 50*c33452fbSAndroid Build Coastguard Worker 51*c33452fbSAndroid Build Coastguard Worker // We need to tell SWIG that std::vector<std::string> is a vector of strings 52*c33452fbSAndroid Build Coastguard Worker namespace std { 53*c33452fbSAndroid Build Coastguard Worker %template(StringVector) vector<string>; 54*c33452fbSAndroid Build Coastguard Worker } 55*c33452fbSAndroid Build Coastguard Worker 56*c33452fbSAndroid Build Coastguard Worker // Tells swig that 'std::string& strError' must be treated as output parameters 57*c33452fbSAndroid Build Coastguard Worker // TODO: make it return a tuple instead of a list 58*c33452fbSAndroid Build Coastguard Worker %apply std::string &OUTPUT { std::string& strError }; 59*c33452fbSAndroid Build Coastguard Worker 60*c33452fbSAndroid Build Coastguard Worker // Automatic python docstring generation 61*c33452fbSAndroid Build Coastguard Worker // FIXME: because of the typemap above, the output type is wrong for methods 62*c33452fbSAndroid Build Coastguard Worker // that can return an error string. 63*c33452fbSAndroid Build Coastguard Worker // TODO: document each function manually ? 64*c33452fbSAndroid Build Coastguard Worker %feature("autodoc", "1"); 65*c33452fbSAndroid Build Coastguard Worker 66*c33452fbSAndroid Build Coastguard Worker 67*c33452fbSAndroid Build Coastguard Worker // rename "CParameterMgrFullConnector" into the nicer "ParameterFramework" name 68*c33452fbSAndroid Build Coastguard Worker %rename(ParameterFramework) CParameterMgrFullConnector; 69*c33452fbSAndroid Build Coastguard Worker class CParameterMgrFullConnector 70*c33452fbSAndroid Build Coastguard Worker { 71*c33452fbSAndroid Build Coastguard Worker 72*c33452fbSAndroid Build Coastguard Worker %{ 73*c33452fbSAndroid Build Coastguard Worker #include "ParameterMgrFullConnector.h" 74*c33452fbSAndroid Build Coastguard Worker %} 75*c33452fbSAndroid Build Coastguard Worker 76*c33452fbSAndroid Build Coastguard Worker public: 77*c33452fbSAndroid Build Coastguard Worker CParameterMgrFullConnector(const std::string& strConfigurationFilePath); 78*c33452fbSAndroid Build Coastguard Worker 79*c33452fbSAndroid Build Coastguard Worker bool start(std::string& strError); 80*c33452fbSAndroid Build Coastguard Worker 81*c33452fbSAndroid Build Coastguard Worker void setLogger(ILogger* pLogger); 82*c33452fbSAndroid Build Coastguard Worker 83*c33452fbSAndroid Build Coastguard Worker ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive); 84*c33452fbSAndroid Build Coastguard Worker ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, 85*c33452fbSAndroid Build Coastguard Worker const ISelectionCriterionTypeInterface* pSelectionCriterionType); 86*c33452fbSAndroid Build Coastguard Worker ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName); 87*c33452fbSAndroid Build Coastguard Worker 88*c33452fbSAndroid Build Coastguard Worker // Configuration application 89*c33452fbSAndroid Build Coastguard Worker void applyConfigurations(); 90*c33452fbSAndroid Build Coastguard Worker 91*c33452fbSAndroid Build Coastguard Worker bool getForceNoRemoteInterface() const; 92*c33452fbSAndroid Build Coastguard Worker void setForceNoRemoteInterface(bool bForceNoRemoteInterface); 93*c33452fbSAndroid Build Coastguard Worker 94*c33452fbSAndroid Build Coastguard Worker bool setFailureOnMissingSubsystem(bool bFail, std::string& strError); 95*c33452fbSAndroid Build Coastguard Worker bool getFailureOnMissingSubsystem() const; 96*c33452fbSAndroid Build Coastguard Worker 97*c33452fbSAndroid Build Coastguard Worker bool setFailureOnFailedSettingsLoad(bool bFail, std::string& strError); 98*c33452fbSAndroid Build Coastguard Worker bool getFailureOnFailedSettingsLoad() const; 99*c33452fbSAndroid Build Coastguard Worker 100*c33452fbSAndroid Build Coastguard Worker void setSchemaUri(const std::string& schemaUri); 101*c33452fbSAndroid Build Coastguard Worker const std::string& getSchemaUri() const; 102*c33452fbSAndroid Build Coastguard Worker 103*c33452fbSAndroid Build Coastguard Worker bool setValidateSchemasOnStart(bool bValidate, std::string &strError); 104*c33452fbSAndroid Build Coastguard Worker bool getValidateSchemasOnStart() const; 105*c33452fbSAndroid Build Coastguard Worker 106*c33452fbSAndroid Build Coastguard Worker // Tuning mode 107*c33452fbSAndroid Build Coastguard Worker bool setTuningMode(bool bOn, std::string& strError); 108*c33452fbSAndroid Build Coastguard Worker bool isTuningModeOn() const; 109*c33452fbSAndroid Build Coastguard Worker 110*c33452fbSAndroid Build Coastguard Worker // Current value space for user set/get value interpretation 111*c33452fbSAndroid Build Coastguard Worker void setValueSpace(bool bIsRaw); 112*c33452fbSAndroid Build Coastguard Worker bool isValueSpaceRaw() const; 113*c33452fbSAndroid Build Coastguard Worker 114*c33452fbSAndroid Build Coastguard Worker // Current Output Raw Format for user get value interpretation 115*c33452fbSAndroid Build Coastguard Worker void setOutputRawFormat(bool bIsHex); 116*c33452fbSAndroid Build Coastguard Worker bool isOutputRawFormatHex() const; 117*c33452fbSAndroid Build Coastguard Worker 118*c33452fbSAndroid Build Coastguard Worker // Automatic hardware synchronization control (during tuning session) 119*c33452fbSAndroid Build Coastguard Worker bool setAutoSync(bool bAutoSyncOn, std::string& strError); 120*c33452fbSAndroid Build Coastguard Worker bool isAutoSyncOn() const; 121*c33452fbSAndroid Build Coastguard Worker bool sync(std::string& strError); 122*c33452fbSAndroid Build Coastguard Worker 123*c33452fbSAndroid Build Coastguard Worker // User set/get parameters 124*c33452fbSAndroid Build Coastguard Worker %apply std::string &INOUT { std::string& strValue }; 125*c33452fbSAndroid Build Coastguard Worker bool accessParameterValue(const std::string& strPath, std::string& strValue, bool bSet, std::string& strError); 126*c33452fbSAndroid Build Coastguard Worker bool accessConfigurationValue(const std::string &strDomain, const std::string &strConfiguration, const std::string& strPath, std::string& strValue, bool bSet, std::string& strError); 127*c33452fbSAndroid Build Coastguard Worker %clear std::string& strValue; 128*c33452fbSAndroid Build Coastguard Worker 129*c33452fbSAndroid Build Coastguard Worker bool getParameterMapping(const std::string& strPath, std::string& strValue) const; 130*c33452fbSAndroid Build Coastguard Worker 131*c33452fbSAndroid Build Coastguard Worker // Creation/Deletion 132*c33452fbSAndroid Build Coastguard Worker bool createDomain(const std::string& strName, std::string& strError); 133*c33452fbSAndroid Build Coastguard Worker bool deleteDomain(const std::string& strName, std::string& strError); 134*c33452fbSAndroid Build Coastguard Worker bool renameDomain(const std::string& strName, const std::string& strNewName, std::string& strError); 135*c33452fbSAndroid Build Coastguard Worker bool deleteAllDomains(std::string& strError); 136*c33452fbSAndroid Build Coastguard Worker %apply std::string &OUTPUT { std::string& strResult } 137*c33452fbSAndroid Build Coastguard Worker bool setSequenceAwareness(const std::string& strName, bool bSequenceAware, std::string& strResult); 138*c33452fbSAndroid Build Coastguard Worker bool getSequenceAwareness(const std::string& strName, bool& bSequenceAware, std::string& strResult); 139*c33452fbSAndroid Build Coastguard Worker %clear std::string& strResult; 140*c33452fbSAndroid Build Coastguard Worker bool createConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 141*c33452fbSAndroid Build Coastguard Worker bool deleteConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 142*c33452fbSAndroid Build Coastguard Worker bool renameConfiguration(const std::string& strDomain, const std::string& strConfiguration, const std::string& strNewConfiguration, std::string& strError); 143*c33452fbSAndroid Build Coastguard Worker 144*c33452fbSAndroid Build Coastguard Worker // Save/Restore 145*c33452fbSAndroid Build Coastguard Worker bool restoreConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::list<std::string>& strError); 146*c33452fbSAndroid Build Coastguard Worker bool saveConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 147*c33452fbSAndroid Build Coastguard Worker 148*c33452fbSAndroid Build Coastguard Worker // Configurable element - domain association 149*c33452fbSAndroid Build Coastguard Worker bool addConfigurableElementToDomain(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 150*c33452fbSAndroid Build Coastguard Worker bool removeConfigurableElementFromDomain(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 151*c33452fbSAndroid Build Coastguard Worker bool split(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 152*c33452fbSAndroid Build Coastguard Worker bool setElementSequence(const std::string& strDomain, const std::string& strConfiguration, const std::vector<std::string>& astrNewElementSequence, std::string& strError); 153*c33452fbSAndroid Build Coastguard Worker 154*c33452fbSAndroid Build Coastguard Worker bool setApplicationRule(const std::string& strDomain, const std::string& strConfiguration, const std::string& strApplicationRule, std::string& strError); 155*c33452fbSAndroid Build Coastguard Worker %apply std::string &OUTPUT { std::string& strResult } 156*c33452fbSAndroid Build Coastguard Worker bool getApplicationRule(const std::string& strDomain, const std::string& strConfiguration, std::string& strResult); 157*c33452fbSAndroid Build Coastguard Worker %clear std::string& strResult; 158*c33452fbSAndroid Build Coastguard Worker bool clearApplicationRule(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 159*c33452fbSAndroid Build Coastguard Worker 160*c33452fbSAndroid Build Coastguard Worker bool importDomainsXml(const std::string& strXmlSource, bool bWithSettings, bool bFromFile, 161*c33452fbSAndroid Build Coastguard Worker std::string& strError); 162*c33452fbSAndroid Build Coastguard Worker bool importSingleDomainXml(const std::string& strXmlSource, bool bOverwrite, 163*c33452fbSAndroid Build Coastguard Worker std::string& strError); 164*c33452fbSAndroid Build Coastguard Worker bool importSingleDomainXml(const std::string& xmlSource, bool overwrite, bool withSettings, 165*c33452fbSAndroid Build Coastguard Worker bool fromFile, std::string& strError); 166*c33452fbSAndroid Build Coastguard Worker 167*c33452fbSAndroid Build Coastguard Worker // Tells swig that "strXmlDest" in the two following methods are "inout" 168*c33452fbSAndroid Build Coastguard Worker // parameters 169*c33452fbSAndroid Build Coastguard Worker %apply std::string &INOUT { std::string& strXmlDest }; 170*c33452fbSAndroid Build Coastguard Worker bool exportDomainsXml(std::string& strXmlDest, bool bWithSettings, bool bToFile, 171*c33452fbSAndroid Build Coastguard Worker std::string& strError) const; 172*c33452fbSAndroid Build Coastguard Worker 173*c33452fbSAndroid Build Coastguard Worker bool exportSingleDomainXml(std::string& strXmlDest, const std::string& strDomainName, bool bWithSettings, 174*c33452fbSAndroid Build Coastguard Worker bool bToFile, std::string& strError) const; 175*c33452fbSAndroid Build Coastguard Worker %clear std::string& strXmlDest; 176*c33452fbSAndroid Build Coastguard Worker }; 177*c33452fbSAndroid Build Coastguard Worker 178*c33452fbSAndroid Build Coastguard Worker // SWIG nested class support is not complete - cf. 179*c33452fbSAndroid Build Coastguard Worker // http://swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_nested_classes 180*c33452fbSAndroid Build Coastguard Worker // This link also explains how to trick SWIG and pretend that 181*c33452fbSAndroid Build Coastguard Worker // ILogger is a toplevel class (whereas it actually is an inner class of 182*c33452fbSAndroid Build Coastguard Worker // CParameterMgrFullConnector 183*c33452fbSAndroid Build Coastguard Worker // Logger interface 184*c33452fbSAndroid Build Coastguard Worker %feature("director") ILogger; 185*c33452fbSAndroid Build Coastguard Worker // The nested workaround is used to tell swig to ignore the 186*c33452fbSAndroid Build Coastguard Worker // inner class definition that would be redundant with the fake outer class. 187*c33452fbSAndroid Build Coastguard Worker // It would have been useful if ParameterMgrFullConnector.h was included 188*c33452fbSAndroid Build Coastguard Worker // (as opposed to copying the class definition in this .i). 189*c33452fbSAndroid Build Coastguard Worker // As their is no conflicting ILogger definition, this workaround is useless. 190*c33452fbSAndroid Build Coastguard Worker class ILogger 191*c33452fbSAndroid Build Coastguard Worker { 192*c33452fbSAndroid Build Coastguard Worker public: 193*c33452fbSAndroid Build Coastguard Worker virtual void info(const std::string& log) = 0; 194*c33452fbSAndroid Build Coastguard Worker virtual void warning(const std::string& log) = 0; 195*c33452fbSAndroid Build Coastguard Worker protected: ~ILogger()196*c33452fbSAndroid Build Coastguard Worker virtual ~ILogger() {} 197*c33452fbSAndroid Build Coastguard Worker }; 198*c33452fbSAndroid Build Coastguard Worker %{ 199*c33452fbSAndroid Build Coastguard Worker typedef CParameterMgrFullConnector::ILogger ILogger; 200*c33452fbSAndroid Build Coastguard Worker %} 201*c33452fbSAndroid Build Coastguard Worker 202*c33452fbSAndroid Build Coastguard Worker class ISelectionCriterionTypeInterface 203*c33452fbSAndroid Build Coastguard Worker { 204*c33452fbSAndroid Build Coastguard Worker %{ 205*c33452fbSAndroid Build Coastguard Worker #include "SelectionCriterionTypeInterface.h" 206*c33452fbSAndroid Build Coastguard Worker %} 207*c33452fbSAndroid Build Coastguard Worker 208*c33452fbSAndroid Build Coastguard Worker public: 209*c33452fbSAndroid Build Coastguard Worker virtual bool addValuePair(uint64_t iValue, const std::string& strValue, 210*c33452fbSAndroid Build Coastguard Worker std::string& strError) = 0; 211*c33452fbSAndroid Build Coastguard Worker virtual bool getNumericalValue(const std::string& strValue, uint64_t& iValue) const = 0; 212*c33452fbSAndroid Build Coastguard Worker virtual bool getLiteralValue(uint64_t iValue, std::string& strValue) const = 0; 213*c33452fbSAndroid Build Coastguard Worker virtual bool isTypeInclusive() const = 0; 214*c33452fbSAndroid Build Coastguard Worker virtual std::string getFormattedState(uint64_t iValue) const = 0; 215*c33452fbSAndroid Build Coastguard Worker 216*c33452fbSAndroid Build Coastguard Worker protected: ~ISelectionCriterionTypeInterface()217*c33452fbSAndroid Build Coastguard Worker virtual ~ISelectionCriterionTypeInterface() {} 218*c33452fbSAndroid Build Coastguard Worker }; 219*c33452fbSAndroid Build Coastguard Worker 220*c33452fbSAndroid Build Coastguard Worker class ISelectionCriterionInterface 221*c33452fbSAndroid Build Coastguard Worker { 222*c33452fbSAndroid Build Coastguard Worker %{ 223*c33452fbSAndroid Build Coastguard Worker #include "SelectionCriterionInterface.h" 224*c33452fbSAndroid Build Coastguard Worker %} 225*c33452fbSAndroid Build Coastguard Worker 226*c33452fbSAndroid Build Coastguard Worker public: 227*c33452fbSAndroid Build Coastguard Worker virtual void setCriterionState(uint64_t iState) = 0; 228*c33452fbSAndroid Build Coastguard Worker virtual uint64_t getCriterionState() const = 0; 229*c33452fbSAndroid Build Coastguard Worker virtual std::string getCriterionName() const = 0; 230*c33452fbSAndroid Build Coastguard Worker virtual const ISelectionCriterionTypeInterface* getCriterionType() const = 0; 231*c33452fbSAndroid Build Coastguard Worker 232*c33452fbSAndroid Build Coastguard Worker protected: ~ISelectionCriterionInterface()233*c33452fbSAndroid Build Coastguard Worker virtual ~ISelectionCriterionInterface() {} 234*c33452fbSAndroid Build Coastguard Worker }; 235