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>
diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp
index 8dff45a..b77e2aa 100644
--- a/parameter/ConfigurableDomains.cpp
+++ b/parameter/ConfigurableDomains.cpp
@@ -127,24 +127,50 @@
return true;
}
+bool CConfigurableDomains::addDomain(CConfigurableDomain& domain, bool bOverwrite,
+ string& strError)
+{
+ string strErrorDrop;
+
+ string strDomainName(domain.getName());
+ CConfigurableDomain* pExistingDomain = findConfigurableDomain(strDomainName, strErrorDrop);
+
+ if (pExistingDomain) {
+ if (!bOverwrite) {
+ strError = "Can't add domain \"" + strDomainName +
+ "\" because it already exists and overwrite was not requested.";
+ return false;
+ }
+
+ deleteDomain(*pExistingDomain);
+ }
+
+ log_info("Adding configurable domain \"" + strDomainName + "\"");
+
+ 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) {
-
- return false;
+ if (pConfigurableDomain) {
+ deleteDomain(*pConfigurableDomain);
+ return true;
}
- log_info("Deleting configurable domain \"%s\"", strName.c_str());
-
- // Hierarchy
- removeChild(pConfigurableDomain);
-
- // Destroy
- delete pConfigurableDomain;
-
- return true;
+ return false;
}
void CConfigurableDomains::deleteAllDomains()