1 #ifndef DALI_ADDON_MANAGER_IMPL_LINUX
2 #define DALI_ADDON_MANAGER_IMPL_LINUX
4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <dali/internal/addons/common/addon-manager-impl.h>
22 #include <dali/internal/addons/common/addon-manager.h>
25 #include <dali/public-api/common/vector-wrapper.h>
36 * Implementation of AddOnManager for Linux based platforms (ie. Tizen, Ubuntu)
38 class AddOnManagerLinux : public Internal::AddOnManager
43 * @copydoc Dali::Internal::AddOnManager()
48 * @copydoc Dali::Internal::~AddOnManager()
50 ~AddOnManagerLinux() override;
53 * @copydoc Dali::Internal::AddOnManager::RegisterAddOnDispatchTable()
55 void RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable ) override;
58 * @copydoc Dali::Internal::AddOnManager::EnumerateAddOns()
60 std::vector<std::string> EnumerateAddOns() override;
63 * @copydoc Dali::Internal::AddOnManager::GetAddOnInfo()
65 bool GetAddOnInfo(const std::string& name, AddOnInfo& info ) override;
68 * @copydoc Dali::Internal::AddOnManager::LoadAddOns()
70 std::vector<Dali::AddOnLibrary> LoadAddOns( const std::vector<std::string>& extensionNames ) override;
73 * @copydoc Dali::Internal::AddOnManager::GetGlobalProc()
75 void* GetGlobalProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
78 * @copydoc Dali::Internal::AddOnManager::GetInstanceProc()
80 void* GetInstanceProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
83 * @copydoc Dali::Internal::AddOnManager::Pause()
85 void Pause() override;
88 * @copydoc Dali::Internal::AddOnManager::Resume()
90 void Resume() override;
93 * @copydoc Dali::Internal::AddOnManager::Start()
95 void Start() override;
98 * @copydoc Dali::Internal::AddOnManager::Stop()
100 void Stop() override;
105 * @brief Invokes lifecycle event handling function based on incoming event
106 * @param[in] lifecycleEvent The lifecycle event
108 void InvokeLifecycleFunction( uint32_t lifecycleEvent );
111 * @struct Lifecycle callback structure
112 * The instance of the LifecycleCallback handles a single lifecycle
113 * event and is bound to an AddOn lifecycle function. The lifecycle
114 * function is optional and in case it doesn't exist, the event
117 struct LifecycleCallback
119 const static uint32_t EVENT_PAUSE = 0u; ///< pause event
120 const static uint32_t EVENT_RESUME = 1u; ///< resume event
121 const static uint32_t EVENT_START = 2u; ///< start event
122 const static uint32_t EVENT_STOP = 3u; ///< stop event
126 * @param[in] funcName name of the lifecycle function
128 explicit LifecycleCallback(const char* funcName)
130 functionName = funcName;
133 std::string functionName; ///< Name of lifecycle function
134 void(*function)() = nullptr; ///< Lifecycle function pointer
135 bool initialized { false }; ///< Flag indicates whether LifecycleCallback is initialized
139 * @struct AddOnCacheEntry
140 * @brief Instance of AddOnCacheEntry stores AddOn essential
141 * function pointers and library handle.
143 struct AddOnCacheEntry
145 std::string addOnLib{};
149 void* libHandle {nullptr};
151 // main function pointers
152 void(*GetAddOnInfo)(AddOnInfo& ) = nullptr; ///< Returns AddOnInfo structure
153 void*(*GetInstanceProc)( const char* ) = nullptr; ///< Returns pointer of instance function (member funtion)
154 void*(*GetGlobalProc)( const char* ) = nullptr; ///< Returns pointer of global function (non-member function)
156 // lifecycle functions
157 std::vector<LifecycleCallback> lifecycleCallbacks =
159 LifecycleCallback{ "OnPause" },
160 LifecycleCallback{ "OnResume" },
161 LifecycleCallback{ "OnStart" },
162 LifecycleCallback{ "OnStop" },
167 std::vector<AddOnCacheEntry> mAddOnCache;
168 std::vector<std::string> mAddOnNames;
174 #endif //DALI_CMAKE_EXTENSION_MANAGER_IMPL_UBUNTU