Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 757ae75

Browse files
author
Florian Poncabaré
committed
Add listMappings command
List all the mapping under a given path Example : remote-process localhost 5000 listMappings / Signed-off-by: Florian Poncabaré <florianx.poncabare@intel.com>
1 parent 1d51444 commit 757ae75

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

parameter/Element.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ string CElement::listQualifiedPaths(bool bDive, size_t level) const
356356
return strResult;
357357
}
358358

359+
void CElement::getSubpaths(std::vector<string> &results) const
360+
{
361+
results.push_back(getPath());
362+
363+
for (CElement *pChild : _childArray) {
364+
pChild->getSubpaths(results);
365+
}
366+
}
367+
359368
void CElement::listChildrenPaths(string &strChildList) const
360369
{
361370
// Get list of children paths

parameter/Element.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class PARAMETER_EXPORT CElement : public IXmlSink, public IXmlSource
7272
void listChildren(std::string &strChildList) const;
7373
std::string listQualifiedPaths(bool bDive, size_t level = 0) const;
7474
void listChildrenPaths(std::string &strChildPathList) const;
75+
void getSubpaths(std::vector<std::string> &results) const;
7576

7677
// Hierarchy query
7778
size_t getNbChildren() const;

parameter/ParameterMgr.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa
269269
"Set value for parameter at given path to configuration"},
270270
{"showMapping", &CParameterMgr::showMappingCommandProcess, 1, "<elem path>",
271271
"Show mapping for an element at given path"},
272+
{"listMappings", &CParameterMgr::listMappingsCommandProcess, 1, "<elem path>|/",
273+
"List mappings under element at given path or root"},
272274

273275
/// Browse
274276
{"listAssociatedElements", &CParameterMgr::listAssociatedElementsCommandProcess, 0, "",
@@ -1820,6 +1822,37 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showMappingCommandP
18201822
return CCommandHandler::ESucceeded;
18211823
}
18221824

1825+
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listMappingsCommandProcess(
1826+
const IRemoteCommand &remoteCommand, string &strResult)
1827+
{
1828+
CElementLocator elementLocator(getSystemClass(), false);
1829+
1830+
CElement *pLocatedElement = nullptr;
1831+
1832+
if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1833+
return CCommandHandler::EFailed;
1834+
}
1835+
1836+
if (!pLocatedElement) {
1837+
// List from root folder
1838+
pLocatedElement = getSystemClass();
1839+
}
1840+
1841+
vector<string> paths;
1842+
pLocatedElement->getSubpaths(paths);
1843+
1844+
for (string path : paths) {
1845+
string mapping;
1846+
if (getParameterMapping(path, mapping)) {
1847+
strResult += path + " [" + mapping + "]\n";
1848+
} else {
1849+
strResult += path + "\n";
1850+
}
1851+
}
1852+
1853+
return CCommandHandler::ESucceeded;
1854+
}
1855+
18231856
/// Settings Import/Export
18241857
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportDomainsXMLCommandProcess(
18251858
const IRemoteCommand &remoteCommand, string &strResult)

parameter/ParameterMgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ class CParameterMgr : private CElement
533533
const IRemoteCommand &remoteCommand, std::string &strResult);
534534
CCommandHandler::CommandStatus showMappingCommandProcess(const IRemoteCommand &remoteCommand,
535535
std::string &strResult);
536+
CCommandHandler::CommandStatus listMappingsCommandProcess(const IRemoteCommand &remoteCommand,
537+
std::string &strResult);
536538
/// Browse
537539
CCommandHandler::CommandStatus listAssociatedElementsCommandProcess(
538540
const IRemoteCommand &remoteCommand, std::string &strResult);

0 commit comments

Comments
 (0)