1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16// Autogenerated file -- DO NOT EDIT! 17 18#ifndef PANDA_<%= Common::module.name.upcase %>_EVENTS_GEN_H_ 19#define PANDA_<%= Common::module.name.upcase %>_EVENTS_GEN_H_ 20 21#include <fstream> 22 23namespace <%= Common::module.namespace %> { 24 25class Graph; 26 27class EventWriter { 28public: 29 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) 30 EventWriter(std::string_view class_name, std::string_view method_name) { 31 std::copy(class_name.begin(), class_name.begin() + std::min(class_name.size(), BUF_SIZE - 1) + 1, 32 class_name_.data()); 33 std::copy(method_name.begin(), method_name.begin() + std::min(method_name.size(), BUF_SIZE - 1) + 1, 34 method_name_.data()); 35 } 36 37 static void Init(const std::string& file_path) { 38 EventWriter::events_file.open(file_path, std::ios::out); 39 } 40 41% Common::events.each do |op| 42 void <%= op.method_name %>(<%= op.args_list %>) { 43 events_file << class_name_.data() << "::" << method_name_.data() << ',' << "<%= op.name %>" << ','; 44 <%= op.print_line %>; 45 events_file << std::endl; 46 } 47% end 48 49public: 50 // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) 51 static inline std::ofstream events_file; 52 53private: 54 static constexpr size_t BUF_SIZE = 512; 55 std::array<char, BUF_SIZE> class_name_; 56 std::array<char, BUF_SIZE> method_name_; 57}; 58 59} // namespace <%= Common::module.namespace %> 60 61#endif // PANDA_<%= Common::module.name.upcase %>_EVENTS_GEN_H_ 62