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

Commit

Permalink
Add listMappings command
Browse files Browse the repository at this point in the history
List all the mapping under a given path

Example with the MusicLibrary form the Getting Started wiki :

$ remote-process localhost 5000 listMappings /MusicLibrary/my_library/artists/IronMaiden

/MusicLibrary/my_library/artists/IronMaiden [Directory:/home/fponcabx/pfw/install-examples/libraries, File:ironMaiden, File:ironMaiden]

Signed-off-by: Florian Poncabaré <[email protected]>
  • Loading branch information
Florian Poncabaré committed May 2, 2016
1 parent 1d51444 commit f41401e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parameter/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ string CElement::listQualifiedPaths(bool bDive, size_t level) const
return strResult;
}

void CElement::getSubpaths(std::vector<string> &results) const
{
results.push_back(getPath());

for (CElement *pChild : _childArray) {
pChild->getSubpaths(results);
}
}

void CElement::listChildrenPaths(string &strChildList) const
{
// Get list of children paths
Expand Down
1 change: 1 addition & 0 deletions parameter/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PARAMETER_EXPORT CElement : public IXmlSink, public IXmlSource
void listChildren(std::string &strChildList) const;
std::string listQualifiedPaths(bool bDive, size_t level = 0) const;
void listChildrenPaths(std::string &strChildPathList) const;
void getSubpaths(std::vector<std::string> &results) const;

// Hierarchy query
size_t getNbChildren() const;
Expand Down
33 changes: 33 additions & 0 deletions parameter/ParameterMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa
"Set value for parameter at given path to configuration"},
{"showMapping", &CParameterMgr::showMappingCommandProcess, 1, "<elem path>",
"Show mapping for an element at given path"},
{"listMappings", &CParameterMgr::listMappingsCommandProcess, 1, "<elem path>|/",
"List mappings under element at given path or root"},

/// Browse
{"listAssociatedElements", &CParameterMgr::listAssociatedElementsCommandProcess, 0, "",
Expand Down Expand Up @@ -1820,6 +1822,37 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showMappingCommandP
return CCommandHandler::ESucceeded;
}

CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listMappingsCommandProcess(
const IRemoteCommand &remoteCommand, string &strResult)
{
CElementLocator elementLocator(getSystemClass(), false);

CElement *pLocatedElement = nullptr;

if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
return CCommandHandler::EFailed;
}

if (!pLocatedElement) {
// List from root folder
pLocatedElement = getSystemClass();
}

vector<string> paths;
pLocatedElement->getSubpaths(paths);

for (string path : paths) {
string mapping;
if (getParameterMapping(path, mapping)) {
strResult += path + " [" + mapping + "]\n";
} else {
strResult += path + "\n";
}
}

return CCommandHandler::ESucceeded;
}

/// Settings Import/Export
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportDomainsXMLCommandProcess(
const IRemoteCommand &remoteCommand, string &strResult)
Expand Down
2 changes: 2 additions & 0 deletions parameter/ParameterMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ class CParameterMgr : private CElement
const IRemoteCommand &remoteCommand, std::string &strResult);
CCommandHandler::CommandStatus showMappingCommandProcess(const IRemoteCommand &remoteCommand,
std::string &strResult);
CCommandHandler::CommandStatus listMappingsCommandProcess(const IRemoteCommand &remoteCommand,
std::string &strResult);
/// Browse
CCommandHandler::CommandStatus listAssociatedElementsCommandProcess(
const IRemoteCommand &remoteCommand, std::string &strResult);
Expand Down

0 comments on commit f41401e

Please sign in to comment.