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.py
     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 void FtraceConfig::FromProto(const perfetto::protos::FtraceConfig& proto) {
     42   ftrace_events_.clear();
     43   for (const auto& field : proto.ftrace_events()) {
     44     ftrace_events_.emplace_back();
     45     static_assert(
     46         sizeof(ftrace_events_.back()) == sizeof(proto.ftrace_events(0)),
     47         "size mismatch");
     48     ftrace_events_.back() =
     49         static_cast<decltype(ftrace_events_)::value_type>(field);
     50   }
     51 
     52   atrace_categories_.clear();
     53   for (const auto& field : proto.atrace_categories()) {
     54     atrace_categories_.emplace_back();
     55     static_assert(
     56         sizeof(atrace_categories_.back()) == sizeof(proto.atrace_categories(0)),
     57         "size mismatch");
     58     atrace_categories_.back() =
     59         static_cast<decltype(atrace_categories_)::value_type>(field);
     60   }
     61 
     62   atrace_apps_.clear();
     63   for (const auto& field : proto.atrace_apps()) {
     64     atrace_apps_.emplace_back();
     65     static_assert(sizeof(atrace_apps_.back()) == sizeof(proto.atrace_apps(0)),
     66                   "size mismatch");
     67     atrace_apps_.back() =
     68         static_cast<decltype(atrace_apps_)::value_type>(field);
     69   }
     70 
     71   static_assert(sizeof(buffer_size_kb_) == sizeof(proto.buffer_size_kb()),
     72                 "size mismatch");
     73   buffer_size_kb_ =
     74       static_cast<decltype(buffer_size_kb_)>(proto.buffer_size_kb());
     75 
     76   static_assert(sizeof(drain_period_ms_) == sizeof(proto.drain_period_ms()),
     77                 "size mismatch");
     78   drain_period_ms_ =
     79       static_cast<decltype(drain_period_ms_)>(proto.drain_period_ms());
     80   unknown_fields_ = proto.unknown_fields();
     81 }
     82 
     83 void FtraceConfig::ToProto(perfetto::protos::FtraceConfig* proto) const {
     84   proto->Clear();
     85 
     86   for (const auto& it : ftrace_events_) {
     87     proto->add_ftrace_events(
     88         static_cast<decltype(proto->ftrace_events(0))>(it));
     89     static_assert(sizeof(it) == sizeof(proto->ftrace_events(0)),
     90                   "size mismatch");
     91   }
     92 
     93   for (const auto& it : atrace_categories_) {
     94     proto->add_atrace_categories(
     95         static_cast<decltype(proto->atrace_categories(0))>(it));
     96     static_assert(sizeof(it) == sizeof(proto->atrace_categories(0)),
     97                   "size mismatch");
     98   }
     99 
    100   for (const auto& it : atrace_apps_) {
    101     proto->add_atrace_apps(static_cast<decltype(proto->atrace_apps(0))>(it));
    102     static_assert(sizeof(it) == sizeof(proto->atrace_apps(0)), "size mismatch");
    103   }
    104 
    105   static_assert(sizeof(buffer_size_kb_) == sizeof(proto->buffer_size_kb()),
    106                 "size mismatch");
    107   proto->set_buffer_size_kb(
    108       static_cast<decltype(proto->buffer_size_kb())>(buffer_size_kb_));
    109 
    110   static_assert(sizeof(drain_period_ms_) == sizeof(proto->drain_period_ms()),
    111                 "size mismatch");
    112   proto->set_drain_period_ms(
    113       static_cast<decltype(proto->drain_period_ms())>(drain_period_ms_));
    114   *(proto->mutable_unknown_fields()) = unknown_fields_;
    115 }
    116 
    117 }  // namespace perfetto
    118