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

Add listMappings command #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if you can dump only the terminal element. Today you are listing the full list of element. So to many element without control are listed. See under:

/Audio/REALTEK/SOUND_CARD/OUTPUT/HEADPHONE/ANALOG/VOLUME => Card:bytcrrt5640, Debug:, Amend1:HP, Volume:'%1 Playback Volume', Volume:HP Playback Volume
/Audio/REALTEK/SOUND_CARD/OUTPUT/HEADPHONE/ANALOG/VOLUME/0 => Card:bytcrrt5640, Debug:, Amend1:HP, Volume:'%1 Playback Volume', Volume:'%1 Playback Volume'

/Audio/REALTEK/SOUND_CARD/OUTPUT/EARPIECE/ANALOG => Card:bytcrrt5640, Debug:
/Audio/REALTEK/SOUND_CARD/OUTPUT/EARPIECE/ANALOG/SWITCH => Card:bytcrrt5640, Debug:, Control:'Mono Playback Switch', Control:Mono Playback Switch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you seem to want isn't the terminal element (i.e. leaves, i.e. parameters) but the SubsystemObjects (the elements with an instantiation 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