summaryrefslogtreecommitdiffstats
path: root/parameter/include/ParameterMgrPlatformConnector.h
blob: cd99215501eecbb48cf3314c4e5ed6632d584dac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright (c) 2011-2014, Intel Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation and/or
 * other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors
 * may be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#pragma once

#include "SelectionCriterionTypeInterface.h"
#include "SelectionCriterionInterface.h"
#include "ParameterHandle.h"
#include "ParameterMgrLoggerForward.h"

class CParameterMgr;

class CParameterMgrPlatformConnector
{
    friend class CParameterMgrLogger<CParameterMgrPlatformConnector>;
public:
    // Logger interface
    class ILogger
    {
    public:
        virtual void log(bool bIsWarning, const std::string& strLog) = 0;
    protected:
        virtual ~ILogger() {}
    };

    // Construction
    CParameterMgrPlatformConnector(const std::string& strConfigurationFilePath);
    ~CParameterMgrPlatformConnector(); // Not virtual since not supposed to be derived!

    // Selection Criteria interface. Beware returned objects are lent, clients shall not delete them!
    // Should be called before start
    ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive = false);
    ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType);
    // Selection criterion retrieval
    ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName) const;

    // Logging
    // Should be called before start
    void setLogger(ILogger* pLogger);

    // Start
    bool start(std::string& strError);

    // Started state
    bool isStarted() const;

    // Configuration application
    void applyConfigurations();

    // Dynamic parameter handling
    // Returned objects are owned by clients
    // Must be cassed after successfull start
    CParameterHandle* createParameterHandle(const std::string& strPath, std::string& strError) const;

    /** Is the remote interface forcefully disabled ?
     */
    bool getForceNoRemoteInterface() const;

    /**
     * Forcefully disable the remote interface or cancel this policy.
     *
     * Has no effect if called after calling start().
     *
     * @param[in] bForceNoRemoteInterface disable the remote interface if true.
     */
    void setForceNoRemoteInterface(bool bForceNoRemoteInterface);

    /** Should start fail in case of missing subsystems.
      *
      * Will fail if called on started instance.
      *
      * @param[in] bFail: If set to true,  parameterMgr start will fail on missing subsystems
      *                   If set to false, missing subsystems will fallbacks on virtual subsystem
      * @param[out] strError a string describing the error if the function failed,
                             unmodified otherwise.
      *
      * @return false if unable to set, true otherwise.
      */
    bool setFailureOnMissingSubsystem(bool bFail, std::string& strError);

    /** Would start fail in case of missing subsystems.
      *
      * @return if the subsystem load will fail on missing subsystem.
      */
    bool getFailureOnMissingSubsystem();

    /** Should start fail in failed settings load.
      *
      * Will fail if called on started instance.
      *
      * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load.
      *                   If set to false, failed settings load will be ignored.
      * @param[out] strResult a string containing the result of the command.
      *
      * @return false if unable to set, true otherwise.
      */
    bool setFailureOnFailedSettingsLoad(bool bFail, std::string& strError);
    /** Would start fail in case of failed settings load.
      *
      * @return failure on failed settings load policy state.
      */
    bool getFailureOnFailedSettingsLoad();

    /** Get the path to the directory containing the XML Schemas
     *
     * @returns the directory containing the XML Schemas
     */
    const std::string& getSchemaFolderLocation() const;

    /** Override the directory containing the XML Schemas
     *
     * @param[in] strSchemaFolderLocation directory containing the XML Schemas
     */
    void setSchemaFolderLocation(const std::string& strSchemaFolderLocation);

    /** Should .xml files be validated on start ?
     *
     * @param[in] bValidate:
     *     If set to true, parameterMgr will abort when being unable to validate .xml files
     *     If set to false, no .xml/xsd validation will happen (default behaviour)
     * @param[out] strResult a string containing the result of the command.
     *
     * @return false if unable to set, true otherwise.
     */
    bool setValidateSchemasOnStart(bool bValidate, std::string &strError);

    /** Would .xml files be validated on start?
     *
     * @return areSchemasValidated
     */
    bool getValidateSchemasOnStart();

private:
    CParameterMgrPlatformConnector(const CParameterMgrPlatformConnector&);
    CParameterMgrPlatformConnector& operator=(const CParameterMgrPlatformConnector&);
    // Private logging
    void doLog(bool bIsWarning, const std::string& strLog);

    // Implementation
    CParameterMgr* _pParameterMgr;
    // State
    bool _bStarted;
    // Logging
    ILogger* _pLogger;
    // Private logging
    CParameterMgrLogger<CParameterMgrPlatformConnector>* _pParameterMgrLogger;
};