blob: 21a60f3447a1df9cf8309f4546e4c869bb4ab37b [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/connectivity/bluetooth/core/bt-host/public/pw_bluetooth_sapphire/internal/host/common/bounded_inspect_list_node.h"
#include "src/connectivity/bluetooth/lib/cpp-string/string_printf.h"
namespace bt {
void BoundedInspectListNode::AttachInspect(inspect::Node& parent,
std::string name) {
list_node_ = parent.CreateChild(name);
}
BoundedInspectListNode::Item& BoundedInspectListNode::CreateItem() {
if (items_.size() == capacity_) {
items_.pop();
}
std::string index = bt_lib_cpp_string::StringPrintf("%zu", next_index_);
next_index_++;
items_.push({.node = list_node_.CreateChild(index)});
return items_.back();
}
} // namespace bt