1 /* 2 * Copyright 2023 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 #include <base/callback.h> 18 #include <base/functional/bind.h> 19 #include <base/location.h> 20 21 #include <string> 22 23 #include "module.h" 24 #include "module_mainloop.h" 25 26 using namespace bluetooth; 27 28 void external_function(int /* a */, double /* b */, char /* c */); 29 30 class TestModule : public Module, public ModuleMainloop { 31 public: 32 void call_on_handler_protected_method(pid_t tid, int a, int b, int c); 33 void call_on_main_external_function(pid_t tid, int a, double b, char c); 34 void call_on_main(pid_t tid, int a, int b, int c); 35 void call_on_main_repost(pid_t tid, int a, int b, int c); 36 void call_on_main_recurse(pid_t tid, int a, int b, int c); 37 38 static const bluetooth::ModuleFactory Factory; 39 40 protected: 41 void protected_method(int a, int b, int c); 42 void call_on_main_internal(int a, int b, int c); 43 bool IsStarted() const; 44 ListDependencies(bluetooth::ModuleList *)45 void ListDependencies(bluetooth::ModuleList* /* list */) const override {} 46 void Start() override; 47 void Stop() override; 48 std::string ToString() const override; 49 50 private: 51 struct PrivateImpl; 52 std::shared_ptr<TestModule::PrivateImpl> pimpl_; 53 54 bool started_ = false; 55 56 friend bluetooth::ModuleRegistry; 57 }; 58