diff options
author | David Wagner <david.wagner@intel.com> | 2014-12-10 15:01:22 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2015-01-22 11:53:52 +0100 |
commit | fd21197b84f46ba53ace3a1b9d0c05596815dd51 (patch) | |
tree | 27864e4d136bf8e9b0aca22f96724ca23a9fa79c /parameter/ConfigurableDomains.cpp | |
parent | ed744eb61b3fced13193fb59f728f26847748179 (diff) | |
download | external_parameter-framework-fd21197b84f46ba53ace3a1b9d0c05596815dd51.zip external_parameter-framework-fd21197b84f46ba53ace3a1b9d0c05596815dd51.tar.gz external_parameter-framework-fd21197b84f46ba53ace3a1b9d0c05596815dd51.tar.bz2 |
New command for importing a single domain from a file
The command is used as follows:
importDomainWithSettingsXML <file path> [overwrite]
It reads the file given as first argument (path must be absolute) and imports
the domain found in it.
It does not check whether it overlaps with another domain (same elements in two
domains). It does, however, check if there is an existing domain with the same
name as the one being imported. If so and if the (optional) second argument
is "overwrite", it will first delete the existing domain; if not it will refuse
to import the new domain.
Change-Id: I7aaa225f2f1a296f52dc8a97f55e1ff70c06d567
Signed-off-by: David Wagner <david.wagner@intel.com>
Diffstat (limited to 'parameter/ConfigurableDomains.cpp')
-rw-r--r-- | parameter/ConfigurableDomains.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index 8dff45a..b77e2aa 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -127,26 +127,52 @@ bool CConfigurableDomains::createDomain(const string& strName, string& strError) return true; } -bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) +bool CConfigurableDomains::addDomain(CConfigurableDomain& domain, bool bOverwrite, + string& strError) { - CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); + string strErrorDrop; - if (!pConfigurableDomain) { + string strDomainName(domain.getName()); + CConfigurableDomain* pExistingDomain = findConfigurableDomain(strDomainName, strErrorDrop); - return false; - } + if (pExistingDomain) { + if (!bOverwrite) { + strError = "Can't add domain \"" + strDomainName + + "\" because it already exists and overwrite was not requested."; + return false; + } - log_info("Deleting configurable domain \"%s\"", strName.c_str()); + deleteDomain(*pExistingDomain); + } - // Hierarchy - removeChild(pConfigurableDomain); + log_info("Adding configurable domain \"" + strDomainName + "\""); - // Destroy - delete pConfigurableDomain; + addChild(&domain); return true; } +void CConfigurableDomains::deleteDomain(CConfigurableDomain& configurableDomain) +{ + log_info("Deleting configurable domain \"" + configurableDomain.getName() + "\""); + + removeChild(&configurableDomain); + + delete &configurableDomain; +} + +bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); + + if (pConfigurableDomain) { + deleteDomain(*pConfigurableDomain); + return true; + } + + return false; +} + void CConfigurableDomains::deleteAllDomains() { log_info("Deleting all configurable domains"); |