* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* openUBMC is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#include <devmon-common/csr_utils.h>
#include <devmon-common/object_group_interface.h>
#include <mc/log.h>
namespace devmon {
void object_group_interface::init(std::string position, uint64_t online_timestamp, uint8_t slot)
{
Position = position;
Owners = object_group_data::get_instance().get_owners(position);
OnlineTimestamp = online_timestamp;
Slot = slot;
}
object_group_tuple_t object_group_interface::GetObjects(std::string_view owner)
{
auto object_group = object_group_data::get_instance().get_objects(Position, std::string(owner));
nlog("position: ${pos}, get objects count: ${count}, owner: ${owner}",
("pos", Position)("count", object_group.Objects.size())("owner", owner));
std::vector<object_tuple_t> object_tuples;
for (auto& object : object_group.Objects) {
object_tuples.push_back(
std::make_tuple(object.ClassName, object.ObjectName, object.ObjectProps(), object.ObjectExtends()));
}
return std::make_tuple(object_group.Position, object_tuples, object_group.LifeCycleId);
}
std::string object_group_interface::GetTopology()
{
auto topology = object_group_data::get_instance().get_topology(Position);
return mc::json::json_encode(topology);
}
}
MC_REFLECT(devmon::object_group_interface,
((Position, "Position"))((Owners, "Owners"))((OnlineTimestamp, "OnlineTimestamp"))((Slot, "Slot"))(
(GetObjects, "GetObjects"))((GetTopology, "GetTopology")))