1/* 2 * Copyright (c) 2021-2024 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 className, std::string_view methodName) { 31 std::copy(className.begin(), className.begin() + std::min(className.size(), BUF_SIZE - 1) + 1, 32 className_.data()); 33 std::copy(methodName.begin(), methodName.begin() + std::min(methodName.size(), BUF_SIZE - 1) + 1, 34 methodName_.data()); 35 } 36 37 static void Init(const std::string& filePath) { 38 EventWriter::events_file_.open(filePath, std::ios::out); 39 } 40 41 // NOLINTBEGIN(readability-identifier-naming) 42% Common::events.each do |op| 43 void <%= op.method_name %>(<%= op.args_list %>) { 44 events_file_ << className_.data() << "::" << methodName_.data() << ',' << "<%= op.name %>" << ','; 45 <%= op.print_line %>; 46 events_file_ << std::endl; 47 } 48% end 49 // NOLINTEND(readability-identifier-naming) 50 51public: 52 // TODO (a.popov) synchronize object in multithreaded mode 53 // NOLINTNEXTLINE(cert-err58-cpp,fuchsia-statically-constructed-objects,readability-identifier-naming) 54 static inline std::ofstream events_file_; 55 56private: 57 static constexpr size_t BUF_SIZE = 512; 58 std::array<char, BUF_SIZE> className_; 59 std::array<char, BUF_SIZE> methodName_; 60}; 61 62} // namespace <%= Common::module.namespace %> 63 64#endif // PANDA_<%= Common::module.name.upcase %>_EVENTS_GEN_H 65