1 /* 2 * Copyright (C) 2024 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 #ifndef ANDROID_LIBPERFMGR_EVENTNODE_H_ 18 #define ANDROID_LIBPERFMGR_EVENTNODE_H_ 19 20 #include <cstddef> 21 #include <string> 22 #include <vector> 23 24 #include "perfmgr/Node.h" 25 26 namespace android { 27 namespace perfmgr { 28 29 // EventNode represents to handle events by callback function. 30 class EventNode : public Node { 31 public: 32 EventNode(std::string name, std::string node_path, std::vector<RequestGroup> req_sorted, 33 std::size_t default_val_index, bool reset_on_init, 34 std::function<void(const std::string &, const std::string &, const std::string &)> 35 update_callback); 36 37 std::chrono::milliseconds Update(bool log_error) override; 38 void DumpToFd(int fd) const override; 39 40 private: 41 EventNode(const Node &other) = delete; 42 EventNode &operator=(Node const &) = delete; 43 const std::function<void(const std::string &name, const std::string &path, 44 const std::string &value)> 45 update_callback_; 46 }; 47 48 } // namespace perfmgr 49 } // namespace android 50 51 #endif // ANDROID_LIBPERFMGR_EVENTNODE_H_ 52