mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Map operations by ordinal
This commit is contained in:
parent
ee101f2c6b
commit
6b14ba6511
@ -179,10 +179,9 @@ message PbOperationMetaData {
|
||||
repeated PbOperationParameter parameters = 2;
|
||||
}
|
||||
|
||||
// Mapping of operation names to their meta data.
|
||||
// The names are the names at the time the server-side protobuf data were generated from the .proto interface file.
|
||||
// Mapping of operations to their ordinals
|
||||
message PbOperationInfo {
|
||||
map<string, PbOperationMetaData> operations = 1;
|
||||
map<int32, PbOperationMetaData> operations = 1;
|
||||
}
|
||||
|
||||
// The supported file extensions mapped to their respective device types
|
||||
|
@ -468,7 +468,8 @@ void RascsiResponse::CreateOperation(PbOperationInfo *operation_info, PbOperatio
|
||||
const PbOperation& operation, const string& description)
|
||||
{
|
||||
(*meta_data->mutable_description())["en"] = description;
|
||||
(*operation_info->mutable_operations())[PbOperation_Name(operation)] = *meta_data;
|
||||
int ordinal = PbOperation_descriptor()->FindValueByName(PbOperation_Name(operation))->index();
|
||||
(*operation_info->mutable_operations())[ordinal] = *meta_data;
|
||||
}
|
||||
|
||||
PbOperationParameter *RascsiResponse::AddOperationParameter(PbOperationMetaData *meta_data, const string& name,
|
||||
|
@ -277,11 +277,11 @@ void RasctlDisplay::DisplayMappingInfo(const PbMappingInfo& mapping_info)
|
||||
void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
||||
{
|
||||
// Creates a sorted map
|
||||
const map<string, PbOperationMetaData> operations = { operation_info.operations().begin(), operation_info.operations().end() };
|
||||
const map<int32_t, PbOperationMetaData> operations = { operation_info.operations().begin(), operation_info.operations().end() };
|
||||
|
||||
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
||||
for (const auto& operation : operations) {
|
||||
cout << " " << operation.first;
|
||||
cout << " " << PbOperation_Name(operation.first);
|
||||
if (!operation.second.description().empty()) {
|
||||
cout << " (" << operation.second.description().at("en") << ")";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user