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