1/* 2 * Copyright (c) 2021-2022 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#include <array> 23 24namespace <%= Common::module.namespace %> { 25 26class Graph; 27 28class EventWriter { 29public: 30 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) 31 EventWriter(std::string_view class_name, std::string_view method_name) { 32 std::copy(class_name.begin(), class_name.begin() + std::min(class_name.size(), BUF_SIZE - 1) + 1, 33 class_name_.data()); 34 std::copy(method_name.begin(), method_name.begin() + std::min(method_name.size(), BUF_SIZE - 1) + 1, 35 method_name_.data()); 36 } 37 38 static void Init(const std::string& file_path) { 39 EventWriter::events_file.open(file_path, std::ios::out); 40 } 41 42% Common::events.each do |op| 43 void <%= op.method_name %>(<%= op.args_list %>) { 44 events_file << class_name_.data() << "::" << method_name_.data() << ',' << "<%= op.name %>" << ','; 45 <%= op.print_line %>; 46 events_file << std::endl; 47 } 48% end 49 50public: 51 // TODO (a.popov) synchronize object in multithreaded mode 52 // NOLINTNEXTLINE(cert-err58-cpp,fuchsia-statically-constructed-objects) 53 static inline std::ofstream events_file; 54 55private: 56 static constexpr size_t BUF_SIZE = 512; 57 std::array<char, BUF_SIZE> class_name_; 58 std::array<char, BUF_SIZE> method_name_; 59}; 60 61} // namespace <%= Common::module.namespace %> 62 63#endif // PANDA_<%= Common::module.name.upcase %>_EVENTS_GEN_H_ 64