Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*******************************************************************************
     18  * AUTOGENERATED - DO NOT EDIT
     19  *******************************************************************************
     20  * This file has been generated from the protobuf message
     21  * perfetto/config/ftrace/ftrace_config.proto
     22  * by
     23  * ../../tools/proto_to_cpp/proto_to_cpp.cc.
     24  * If you need to make changes here, change the .proto file and then run
     25  * ./tools/gen_tracing_cpp_headers_from_protos
     26  */
     27 
     28 #include "perfetto/tracing/core/ftrace_config.h"
     29 
     30 #include "perfetto/config/ftrace/ftrace_config.pb.h"
     31 
     32 namespace perfetto {
     33 
     34 FtraceConfig::FtraceConfig() = default;
     35 FtraceConfig::~FtraceConfig() = default;
     36 FtraceConfig::FtraceConfig(const FtraceConfig&) = default;
     37 FtraceConfig& FtraceConfig::operator=(const FtraceConfig&) = default;
     38 FtraceConfig::FtraceConfig(FtraceConfig&&) noexcept = default;
     39 FtraceConfig& FtraceConfig::operator=(FtraceConfig&&) = default;
     40 
     41 #pragma GCC diagnostic push
     42 #pragma GCC diagnostic ignored "-Wfloat-equal"
     43 bool FtraceConfig::operator==(const FtraceConfig& other) const {
     44   return (ftrace_events_ == other.ftrace_events_) &&
     45          (atrace_categories_ == other.atrace_categories_) &&
     46          (atrace_apps_ == other.atrace_apps_) &&
     47          (buffer_size_kb_ == other.buffer_size_kb_) &&
     48          (drain_period_ms_ == other.drain_period_ms_);
     49 }
     50 #pragma GCC diagnostic pop
     51 
     52 void FtraceConfig::FromProto(const perfetto::protos::FtraceConfig& proto) {
     53   ftrace_events_.clear();
     54   for (const auto& field : proto.ftrace_events()) {
     55     ftrace_events_.emplace_back();
     56     static_assert(
     57         sizeof(ftrace_events_.back()) == sizeof(proto.ftrace_events(0)),
     58         "size mismatch");
     59     ftrace_events_.back() =
     60         static_cast<decltype(ftrace_events_)::value_type>(field);
     61   }
     62 
     63   atrace_categories_.clear();
     64   for (const auto& field : proto.atrace_categories()) {
     65     atrace_categories_.emplace_back();
     66     static_assert(
     67         sizeof(atrace_categories_.back()) == sizeof(proto.atrace_categories(0)),
     68         "size mismatch");
     69     atrace_categories_.back() =
     70         static_cast<decltype(atrace_categories_)::value_type>(field);
     71   }
     72 
     73   atrace_apps_.clear();
     74   for (const auto& field : proto.atrace_apps()) {
     75     atrace_apps_.emplace_back();
     76     static_assert(sizeof(atrace_apps_.back()) == sizeof(proto.atrace_apps(0)),
     77                   "size mismatch");
     78     atrace_apps_.back() =
     79         static_cast<decltype(atrace_apps_)::value_type>(field);
     80   }
     81 
     82   static_assert(sizeof(buffer_size_kb_) == sizeof(proto.buffer_size_kb()),
     83                 "size mismatch");
     84   buffer_size_kb_ =
     85       static_cast<decltype(buffer_size_kb_)>(proto.buffer_size_kb());
     86 
     87   static_assert(sizeof(drain_period_ms_) == sizeof(proto.drain_period_ms()),
     88                 "size mismatch");
     89   drain_period_ms_ =
     90       static_cast<decltype(drain_period_ms_)>(proto.drain_period_ms());
     91   unknown_fields_ = proto.unknown_fields();
     92 }
     93 
     94 void FtraceConfig::ToProto(perfetto::protos::FtraceConfig* proto) const {
     95   proto->Clear();
     96 
     97   for (const auto& it : ftrace_events_) {
     98     proto->add_ftrace_events(
     99         static_cast<decltype(proto->ftrace_events(0))>(it));
    100     static_assert(sizeof(it) == sizeof(proto->ftrace_events(0)),
    101                   "size mismatch");
    102   }
    103 
    104   for (const auto& it : atrace_categories_) {
    105     proto->add_atrace_categories(
    106         static_cast<decltype(proto->atrace_categories(0))>(it));
    107     static_assert(sizeof(it) == sizeof(proto->atrace_categories(0)),
    108                   "size mismatch");
    109   }
    110 
    111   for (const auto& it : atrace_apps_) {
    112     proto->add_atrace_apps(static_cast<decltype(proto->atrace_apps(0))>(it));
    113     static_assert(sizeof(it) == sizeof(proto->atrace_apps(0)), "size mismatch");
    114   }
    115 
    116   static_assert(sizeof(buffer_size_kb_) == sizeof(proto->buffer_size_kb()),
    117                 "size mismatch");
    118   proto->set_buffer_size_kb(
    119       static_cast<decltype(proto->buffer_size_kb())>(buffer_size_kb_));
    120 
    121   static_assert(sizeof(drain_period_ms_) == sizeof(proto->drain_period_ms()),
    122                 "size mismatch");
    123   proto->set_drain_period_ms(
    124       static_cast<decltype(proto->drain_period_ms())>(drain_period_ms_));
    125   *(proto->mutable_unknown_fields()) = unknown_fields_;
    126 }
    127 
    128 }  // namespace perfetto
    129