xref: /openbmc/phosphor-dbus-monitor/src/propertywatch.cpp (revision 1abcb06bedadfbd40b4ec6f7e5f6a95021df3c96)
14b916f13SBrad Bishop /**
24b916f13SBrad Bishop  * Copyright © 2017 IBM Corporation
34b916f13SBrad Bishop  *
44b916f13SBrad Bishop  * Licensed under the Apache License, Version 2.0 (the "License");
54b916f13SBrad Bishop  * you may not use this file except in compliance with the License.
64b916f13SBrad Bishop  * You may obtain a copy of the License at
74b916f13SBrad Bishop  *
84b916f13SBrad Bishop  *     http://www.apache.org/licenses/LICENSE-2.0
94b916f13SBrad Bishop  *
104b916f13SBrad Bishop  * Unless required by applicable law or agreed to in writing, software
114b916f13SBrad Bishop  * distributed under the License is distributed on an "AS IS" BASIS,
124b916f13SBrad Bishop  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134b916f13SBrad Bishop  * See the License for the specific language governing permissions and
144b916f13SBrad Bishop  * limitations under the License.
154b916f13SBrad Bishop  */
164b916f13SBrad Bishop #include "propertywatchimpl.hpp"
174b916f13SBrad Bishop 
184b916f13SBrad Bishop namespace phosphor
194b916f13SBrad Bishop {
204b916f13SBrad Bishop namespace dbus
214b916f13SBrad Bishop {
224b916f13SBrad Bishop namespace monitoring
234b916f13SBrad Bishop {
244b916f13SBrad Bishop 
254b916f13SBrad Bishop /** @brief convert index.
264b916f13SBrad Bishop  *
274b916f13SBrad Bishop  *  An optimal start implementation requires objects organized in the
284b916f13SBrad Bishop  *  same structure as the mapper response.  The convert method reorganizes
294b916f13SBrad Bishop  *  the flat structure of the index to match.
304b916f13SBrad Bishop  *
314b916f13SBrad Bishop  *  @param[in] index - The index to be converted.
324b916f13SBrad Bishop  */
convert(const PropertyIndex & index)334b916f13SBrad Bishop MappedPropertyIndex convert(const PropertyIndex& index)
344b916f13SBrad Bishop {
354b916f13SBrad Bishop     MappedPropertyIndex m;
364b916f13SBrad Bishop 
374b916f13SBrad Bishop     for (const auto& i : index)
384b916f13SBrad Bishop     {
39*1abcb06bSMatt Spinler         const auto& path = std::get<pathIndex>(i.first);
40*1abcb06bSMatt Spinler         const auto& interface = std::get<interfaceIndex>(i.first);
41*1abcb06bSMatt Spinler         const auto& property = std::get<propertyIndex>(i.first);
424b916f13SBrad Bishop         m[path][interface].push_back(property);
434b916f13SBrad Bishop     }
444b916f13SBrad Bishop 
454b916f13SBrad Bishop     return m;
464b916f13SBrad Bishop }
474b916f13SBrad Bishop } // namespace monitoring
484b916f13SBrad Bishop } // namespace dbus
494b916f13SBrad Bishop } // namespace phosphor
50