*
*/
-#include "ctf2-trace-class-visitor.hpp"
#include "clock-class.hpp"
+#include "ctf2-trace-class-visitor.hpp"
#include <common/exception.hpp>
#include <common/format.hpp>
#include <vendor/nlohmann/json.hpp>
#include <algorithm>
+#include <utility>
namespace lsc = lttng::sessiond::ctf2;
namespace lst = lttng::sessiond::trace;
json::json make_json_fragment(const char *type)
{
- return {{"type", type}};
+ return { { "type", type } };
}
-json::json to_json(const lst::field_location &location)
+json::json to_json(const lst::field_location& location)
{
json::json location_array;
break;
}
- std::copy(location.elements_.begin(), location.elements_.end(),
- std::back_inserter(location_array));
+ std::copy(location.elements_.begin(),
+ location.elements_.end(),
+ std::back_inserter(location_array));
return location_array;
}
namespace ctf2 {
class trace_environment_visitor : public lst::trace_class_environment_visitor {
public:
- trace_environment_visitor()
- {
- }
+ trace_environment_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move
+ constructor. */
- virtual void visit(const lst::environment_field<int64_t>& field) override
+ void visit(const lst::environment_field<int64_t>& field) override
{
_visit(field);
}
- virtual void visit(const lst::environment_field<const char *>& field) override
+ void visit(const lst::environment_field<const char *>& field) override
{
_visit(field);
}
class field_visitor : public lttng::sessiond::trace::field_visitor,
public lttng::sessiond::trace::type_visitor {
public:
- field_visitor()
- {
- }
+ field_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move constructor. */
/* Only call once. */
json::json move_fragment()
}
private:
- virtual void visit(const lst::field& field) override final
+ void visit(const lst::field& field) final
{
field_visitor field_type_visitor;
field.get_type().accept(field_type_visitor);
_fragment["field-class"] = field_type_visitor.move_fragment();
}
- virtual void visit(const lst::integer_type& type) override final
+ void visit(const lst::integer_type& type) final
{
_fragment["type"] = type.signedness_ == lst::integer_type::signedness::SIGNED ?
- "fixed-length-signed-integer" :
- "fixed-length-unsigned-integer";
+ "fixed-length-signed-integer" :
+ "fixed-length-unsigned-integer";
_fragment["length"] = type.size;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
}
}
- virtual void visit(const lst::floating_point_type& type) override final
+ void visit(const lst::floating_point_type& type) final
{
_fragment["type"] = "fixed-length-floating-point-number";
_fragment["length"] = type.exponent_digits + type.mantissa_digits;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
}
template <class EnumerationType>
void visit_enumeration(const EnumerationType& type)
{
- _fragment["type"] = std::is_signed<typename EnumerationType::mapping::range_t::range_integer_t>::value ?
- "fixed-length-signed-enumeration" :
- "fixed-length-unsigned-enumeration";
+ _fragment["type"] =
+ std::is_signed<
+ typename EnumerationType::mapping::range_t::range_integer_t>::value ?
+ "fixed-length-signed-enumeration" :
+ "fixed-length-unsigned-enumeration";
_fragment["length"] = type.size;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
if (type.roles_.size() > 0) {
if (std::is_signed<typename EnumerationType::mapping::range_t::
- range_integer_t>::value) {
- LTTNG_THROW_ERROR(fmt::format(
- "Failed to serialize {}: unexpected role",
- _fragment["type"]));
+ range_integer_t>::value) {
+ LTTNG_THROW_ERROR(
+ lttng::format("Failed to serialize {}: unexpected role",
+ _fragment["type"]));
}
auto role_array = json::json::array();
}
if (type.mappings_->size() < 1) {
- LTTNG_THROW_ERROR(fmt::format(
- "Failed to serialize {}: enumeration must have at least one mapping",
- _fragment["type"]));
+ LTTNG_THROW_ERROR(lttng::format(
+ "Failed to serialize {}: enumeration must have at least one mapping",
+ _fragment["type"]));
}
json::json mappings_value;
- for (const auto &mapping : *type.mappings_) {
- mappings_value[mapping.name] = {{mapping.range.begin, mapping.range.end}};
+ for (const auto& mapping : *type.mappings_) {
+ mappings_value[mapping.name] = { { mapping.range.begin,
+ mapping.range.end } };
}
_fragment["mappings"] = std::move(mappings_value);
}
- virtual void visit(const lst::signed_enumeration_type& type) override final
+ void visit(const lst::signed_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::unsigned_enumeration_type& type) override final
+ void visit(const lst::unsigned_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::static_length_array_type& type) override final
+ void visit(const lst::static_length_array_type& type) final
{
_fragment["type"] = "static-length-array";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_array_type& type) override final
+ void visit(const lst::dynamic_length_array_type& type) final
{
_fragment["type"] = "dynamic-length-array";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::static_length_blob_type& type) override final
+ void visit(const lst::static_length_blob_type& type) final
{
_fragment["type"] = "static-length-blob";
_fragment["length"] = type.length_bytes;
}
}
- virtual void visit(const lst::dynamic_length_blob_type& type) override final
+ void visit(const lst::dynamic_length_blob_type& type) final
{
_fragment["type"] = "dynamic-length-blob";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::null_terminated_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final
{
_fragment["type"] = "null-terminated-string";
}
- virtual void visit(const lst::structure_type& type) override final
+ void visit(const lst::structure_type& type) final
{
_fragment["type"] = "structure";
}
auto member_classes_value = json::json::array();
- for (const auto &field : type.fields_) {
+ for (const auto& field : type.fields_) {
::ctf2::field_visitor member_visitor;
json::json member_class;
json::json member_class;
/* TODO missing selector-field-range. */
- member_class["selector-field-ranges"] = {{option.first.range.begin, option.first.range.end}};
+ member_class["selector-field-ranges"] = { { option.first.range.begin,
+ option.first.range.end } };
option.second->accept(option_visitor);
member_class["field-class"] = option_visitor.move_fragment();
options_value.emplace_back(std::move(member_class));
_fragment["options"] = std::move(options_value);
}
- virtual void visit(const lst::variant_type<int64_t>& type) override final
+ void visit(const lst::variant_type<int64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<uint64_t>& type) override final
+ void visit(const lst::variant_type<uint64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::static_length_string_type& type) override final
+ void visit(const lst::static_length_string_type& type) final
{
_fragment["type"] = "static-length-string";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_string_type& type) override final
+ void visit(const lst::dynamic_length_string_type& type) final
{
_fragment["type"] = "dynamic-length-string";
_fragment["length-field-location"] = to_json(type.length_field_location);
}; /* namespace */
-lsc::trace_class_visitor::trace_class_visitor(const lst::abi& trace_abi,
- lsc::append_metadata_fragment_function append_metadata_fragment) :
- _trace_abi{trace_abi}, _append_metadata_fragment(append_metadata_fragment)
+lsc::trace_class_visitor::trace_class_visitor(
+ lsc::append_metadata_fragment_function append_metadata_fragment) :
+ _append_metadata_fragment(std::move(append_metadata_fragment))
{
}
void lsc::trace_class_visitor::visit(const lst::clock_class& clock_class)
{
- auto clock_class_fragment = make_json_fragment("clock-class");
+ auto clock_class_fragment = make_json_fragment("clock-class");
json::json offset;
- offset.update({{"seconds", clock_class.offset / clock_class.frequency},
- {"cycles", clock_class.offset % clock_class.frequency}});
+ offset.update({ { "seconds", clock_class.offset / clock_class.frequency },
+ { "cycles", clock_class.offset % clock_class.frequency } });
- clock_class_fragment.update({
- {"name", clock_class.name},
- {"description", clock_class.description},
- {"frequency", clock_class.frequency},
- {"offset", std::move(offset)}});
+ clock_class_fragment.update({ { "name", clock_class.name },
+ { "description", clock_class.description },
+ { "frequency", clock_class.frequency },
+ { "offset", std::move(offset) } });
if (clock_class.uuid) {
clock_class_fragment["uuid"] = *clock_class.uuid;
stream_class_fragment["id"] = stream_class.id;
if (stream_class.default_clock_class_name) {
stream_class_fragment["default-clock-class-name"] =
- *stream_class.default_clock_class_name;
+ *stream_class.default_clock_class_name;
}
const auto packet_context = stream_class.packet_context();
::ctf2::field_visitor visitor;
event_header->accept(visitor);
- stream_class_fragment["event-record-header-field-class"] =
- visitor.move_fragment();
+ stream_class_fragment["event-record-header-field-class"] = visitor.move_fragment();
}
const auto event_context = stream_class.event_context();
event_context->accept(visitor);
stream_class_fragment["event-record-common-context-field-class"] =
- visitor.move_fragment();
+ visitor.move_fragment();
}
append_metadata_fragment(stream_class_fragment);