├── .gitattributes ├── .gitignore ├── Application ├── CMakeLists.txt └── main.cpp ├── CMakeLists.txt ├── Interface ├── CMakeLists.txt ├── common.hpp ├── plugin.cpp ├── plugin.hpp ├── plugininterface.cpp ├── plugininterface.hpp ├── pluginmanager.cpp ├── pluginmanager.hpp └── third-party │ └── json │ └── json.hpp ├── LICENSE ├── Plugins ├── PluginOne │ ├── CMakeLists.txt │ ├── common.hpp │ ├── interface.cpp │ ├── interface.hpp │ ├── pluginone.cpp │ └── pluginone.hpp └── PluginTwo │ ├── CMakeLists.txt │ ├── common.hpp │ ├── interface.cpp │ ├── interface.hpp │ ├── plugintwo.cpp │ └── plugintwo.hpp └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /Application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(Application LANGUAGES CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 20) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | set(PREFIX_HPPHEADER *.hpp) 9 | set(PREFIX_SOURCE *.cpp) 10 | 11 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 12 | 13 | file(GLOB SOURCESFILE 14 | ${PREFIX_HPPHEADER} 15 | ${PREFIX_SOURCE} 16 | ) 17 | 18 | 19 | include_directories(${PROJECT_SOURCE_DIR}/../Interface/) 20 | 21 | add_executable(${PROJECT_NAME} ${SOURCESFILE}) 22 | 23 | 24 | target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/../Interface/) 25 | target_link_libraries(${PROJECT_NAME} PRIVATE PluginInterface) 26 | 27 | install(TARGETS ${PROJECT_NAME} DESTINATION build/bin) 28 | -------------------------------------------------------------------------------- /Application/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "pluginmanager.hpp" 8 | 9 | 10 | int main() 11 | { 12 | std::cout << "Hello World!" << std::endl; 13 | 14 | std::vector plugins; 15 | plugins.push_back("libPluginOne.dylib"); 16 | plugins.push_back("libPluginTwo.dylib"); 17 | 18 | Plugin* plugin = nullptr; 19 | //Plugin* plugin2 = nullptr; 20 | 21 | for(const auto& c : plugins) { 22 | std::cout << "C: " << c << std::endl; 23 | 24 | plugin = PluginManager::instance().load("plugins/"+c); 25 | //plugin2 = PluginManager::Instance().load("plugins/libPluginTwo.dylib"); 26 | 27 | // plugin1->doAction(); 28 | // plugin2->doAction(); 29 | 30 | plugin->doAction(); 31 | 32 | switch (plugin->type()) { 33 | case PluginType::Theme: 34 | std::cout << "1\n"; 35 | break; 36 | case PluginType::Admin: 37 | std::cout << "2\n"; 38 | break; 39 | case PluginType::Core: 40 | std::cout << "3\n"; 41 | break; 42 | default: 43 | break; 44 | } 45 | 46 | // std::vector v1 = {"A", "B", "C"}; 47 | // std::vector v2 = {1, 2, 3}; 48 | 49 | // for(const auto& c : plugin1->action(v1)) { 50 | // std::cout << "action for p1 : " << c << std::endl; 51 | // } 52 | 53 | // for(const auto& c : plugin2->action(v2)) { 54 | // std::cout << "action for p2 : " << c << std::endl; 55 | // } 56 | 57 | // std::cout << "action as int " << plugin->action(1) << std::endl; 58 | // std::cout << "action as string: " << plugin->action("Hi Action!") << std::endl; 59 | 60 | // std::vector v = {"A", "B", "C"}; 61 | 62 | // for(const auto& c : plugin->action(v)) { 63 | // std::cout << "action as vector : " << c << std::endl; 64 | // } 65 | 66 | 67 | // const auto temp = plugin->multiAction(v); 68 | // for(const auto& c : temp) { 69 | // std::cout << "V : " << c << std::endl; 70 | // } 71 | 72 | // if ( plugin != NULL ) 73 | // { 74 | // std::cout << "INFO: Plugin --" << plugin->getName() << "(" << plugin->getVersion() << ") \n " << " : " << plugin->getDescription() << " -- successfully loaded." << std::endl; 75 | // } 76 | // else 77 | // { 78 | // std::cerr << "ERROR: Plugin --" << plugin->getName() << "-- failed to load." << std::endl; 79 | // } 80 | } 81 | 82 | 83 | //assert( plugin != nullptr ); 84 | 85 | // PluginList plist; 86 | 87 | // std::string pName; 88 | // for(const auto& o : PluginInterface::Instance().getDetail()) { 89 | // std::cout << "Name : " << o.name << std::endl; 90 | // pName = o.name; 91 | // std::cout << "Description : " << o.description << std::endl; 92 | // std::cout << "Version : " << o.version << std::endl; 93 | // std::cout << "Author : " << o.author << std::endl; 94 | // } 95 | 96 | 97 | for(const auto& c : PluginInterface::instance().getErrors()) { 98 | std::cout << " P : " << c << std::endl; 99 | } 100 | 101 | //PluginManager::Instance().unload(plugin1); 102 | //PluginManager::Instance().unload(plugin2); 103 | 104 | std::cout << "INFO: Plugin Unloaded." << std::endl; 105 | 106 | //system("PAUSE"); 107 | 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(Dynamic-Application LANGUAGES CXX) 4 | 5 | option(BUILD_APPLICATION "Enable building application" ON) 6 | option(BUILD_INTERFACE "Enable building interface" ON) 7 | option(BUILD_PLUGINS "Enable building plugins" ON) 8 | 9 | if(BUILD_APPLICATION) 10 | add_subdirectory(Application) 11 | endif() 12 | if(BUILD_INTERFACE) 13 | add_subdirectory(Interface) 14 | endif() 15 | if(BUILD_PLUGINS) 16 | add_subdirectory(Plugins/PluginOne) 17 | add_subdirectory(Plugins/PluginTwo) 18 | endif() 19 | -------------------------------------------------------------------------------- /Interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(PluginInterface LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 20) 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 8 | 9 | set(PREFIX_HPPHEADER *.hpp) 10 | set(PREFIX_SOURCE *.cpp) 11 | 12 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 13 | 14 | 15 | file(GLOB SOURCESFILE 16 | ${PREFIX_HPPHEADER} 17 | ${PREFIX_SOURCE} 18 | ) 19 | 20 | option(ENABLE_STATIC "Enable building static for ${PROJECT_NAME}" FALSE) 21 | 22 | if(ENABLE_STATIC) 23 | add_library(${PROJECT_NAME} STATIC ${SOURCESFILE}) 24 | else() 25 | add_library(${PROJECT_NAME} SHARED ${SOURCESFILE}) 26 | endif() 27 | 28 | #json 29 | find_package(nlohmann_json REQUIRED) 30 | include_directories(third-party/json/) 31 | 32 | target_compile_definitions(${PROJECT_NAME} PRIVATE PLUGININTERFACE_LIBRARY) 33 | 34 | install(TARGETS ${PROJECT_NAME} DESTINATION build/lib) 35 | -------------------------------------------------------------------------------- /Interface/common.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * MIT License 3 | * 4 | * @author : Kambiz Asadzadeh 5 | * @file : This file is a part of the project. 6 | * @version : 1.0 7 | * @copyright : Copyright (c) 2020 Kambiz Asadzadeh 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | */ 27 | 28 | #ifndef COMMON_HPP 29 | #define COMMON_HPP 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | constexpr std::string_view __project_full_version = "0.5"; 36 | constexpr std::string_view __project_release_mode = "alpha"; 37 | constexpr std::string_view __project_release_mode_number = "2"; 38 | 39 | #define STLLIB_STANDARD 0x0 40 | #define STLLIB_TECHNICAL_REPORT 0x1 41 | #define STLLIB_EXPERIMENTAL 0x2 42 | #define STLLIB_BOOST 0x3 43 | #define STLLIB_NETWORKING_ERROR "We don't even have access to networking TS." 44 | #define STLLIB_SYSTEM_ERROR "We don't even have access to system TS." 45 | #define BOOST_ASIO_NO_DEPRECATED 46 | 47 | #undef PROJECT_COPYRIGHT 48 | #define PROJECT_COPYRIGHT 1 49 | 50 | //! Compiler Predefined Variables. 51 | 52 | #define __project_null_str "" 53 | #define __project_zero 0 54 | #define __project_newline "\n" 55 | #define __project_compiler_counter __COUNTER__ 56 | #define __project_compiler_line __LINE__ 57 | #define __project_compiler_file __FILE__ 58 | #define __project_compiler_function __FUNCTION__ 59 | #define __project_compiler_pretty_function __PRETTY_FUNCTION__ 60 | #define __project_compiled_date __DATE__ 61 | #define __project_compiler_time __TIME__ 62 | 63 | #define __project_has_include __has_include 64 | 65 | #define PROJECT_BRACE_BEGIN { 66 | #define PROJECT_BRACE_END } 67 | #define PROJECT_USING_NAMESPACE using namespace 68 | #define PROJECT_NAMESPACE_BEGIN(x) namespace x { 69 | #define PROJECT_ANONYMOUS_NAMESPACE_BEGIN namespace { 70 | #define PROJECT_NAMESPACE_END } 71 | #define PROJECT_USING using 72 | #define PROJECT_NAMESPACE namespace 73 | 74 | /* 75 | * C++11 keywords and expressions 76 | */ 77 | #ifdef PROJECT_COMPILER_NULLPTR 78 | # define __project_nullptr nullptr 79 | #else 80 | # define __project_nullptr NULL 81 | #endif 82 | 83 | # define __project_override override 84 | # define __project_final final 85 | 86 | # define __project_noexcept noexcept 87 | # define __project_noexcept_expr(x) noexcept(x) 88 | 89 | #define __project_no_discard [[nodiscard]] 90 | #define __project_no_discard_message(x) [[nodiscard(x)]] 91 | 92 | #define PROJECT_HAS_INCLUDE __has_include 93 | #define PROJECT_ENABLE_SHARED_FROM(x) std::enable_shared_from_this 94 | 95 | #define PROJECT_MOVE(x) std::move(x) 96 | 97 | #define PROJECT_DEFAULT_OCTORS(Class) \ 98 | Class();\ 99 | ~Class(); 100 | 101 | #define PROJECT_DEFAULT_OCTORS_IMPL(Class) \ 102 | Class::Class()\ 103 | {\ 104 | }\ 105 | Class::~Class()\ 106 | {\ 107 | }\ 108 | 109 | #define PointerToObject(object, name)\ 110 | typedef object* (*name)(); 111 | 112 | #define PointerToFunction void(*)() 113 | 114 | #define __project_enum enum class 115 | 116 | #define __project_shared_ptr(Class) \ 117 | std::shared_ptr 118 | 119 | #define PROJECT_DISABLE_COPY(Class) \ 120 | Class(const Class &) = delete;\ 121 | Class &operator=(const Class &) = delete; 122 | 123 | #define PROJECT_DISABLE_MOVE(Class) \ 124 | Class(Class &&) = delete; \ 125 | Class &operator=(Class &&) = delete; 126 | 127 | #define PROJECT_DISABLE_COPY_MOVE(Class) \ 128 | PROJECT_DISABLE_COPY(Class) \ 129 | PROJECT_DISABLE_MOVE(Class) 130 | 131 | #if defined(__WINNT) || defined(__WINNT__) || defined(WIN32) || \ 132 | defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || \ 133 | defined(WIN64) || defined(_WIN64) || defined(__WIN64) || \ 134 | defined(__WIN64__) 135 | //! Microsoft Windows 136 | #define __project_export __declspec(dllexport) 137 | #define __project_import __declspec(dllimport) 138 | #elif defined(__GNUC__) 139 | //! Define for Unix base OS such as: Linux, macOS, FreeBSD, etc... 140 | #define __project_export __attribute__((visibility("default"))) 141 | #define __project_import __attribute__((visibility("default"))) 142 | #define __project_hidden __attribute__((visibility("hidden"))) 143 | #else 144 | // do nothing and hope for the best? 145 | #define __project_export 146 | #define __project_import 147 | #pragma warning Unknown dynamic link import / export semantics. 148 | #endif 149 | 150 | #if defined(__APPLE__) && defined(__MACH__) 151 | /* macOS */ 152 | #define __PLATFORM_OS "macOS" 153 | #define __PLATFORM_MAC "Unix-macOS (X11)" 154 | #define __PLATFORM_TYPE "Macintosh" 155 | #elif defined(__linux__) && defined(linux) && !defined(__ANDROID__) && \ 156 | !defined(ANDROID) 157 | /* Linux. --------------------------------------------------- */ 158 | #define __PLATFORM_OS "Linux" 159 | #define __PLATFORM_LINUX "Linux" 160 | #define __PLATFORM_DEVICE "Desktop" 161 | #define __PLATFORM_TYPE "Unix (Linux)" 162 | #elif defined(X64_64bit) && defined(__linux) && defined(__linux__) && \ 163 | defined(linux) && !defined(__ANDROID__) && !defined(ANDROID) 164 | /* Linux. --------------------------------------------------- */ 165 | #define __PLATFORM_OS "Linux" 166 | #define __PLATFORM_LINUX "Linux" 167 | #define __PLATFORM_DEVICE "Desktop" 168 | #define __PLATFORM_TYPE "Unix (Linux)" 169 | #elif defined(_WIN32) || defined(_WIN32_WINNT) && !defined(_WIN64) && \ 170 | !defined(WINAPI_FAMILY_phone_APP) && \ 171 | !defined(WINAPI_FAMILY) && \ 172 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 173 | /* Microsoft Windows (32-bit). ------------------------------ */ 174 | #define __PLATFORM_OS "Windows" 175 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 176 | #define __PLATFORM_WINDOWS "Microsoft Windows (32-Bit)" 177 | #define __PLATFORM_DEVICE "Desktop" 178 | #define __PLATFORM_TYPE "PC (Windows)" 179 | #elif defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) && \ 180 | !defined(WINAPI_FAMILY_phone_APP) && \ 181 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 182 | /* Microsoft Windows (64-bit). ------------------------------ */ 183 | #define __PLATFORM_OS "Windows " 184 | #define __PLATFORM_ARCH "x64 (64-Bit)" 185 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows" 186 | #define __PLATFORM_DEVICE "Desktop" 187 | #define __PLATFORM_WINDOWS "Microsoft Windows" 188 | #define __PLATFORM_TYPE "PC (Windows)" 189 | /* Microsoft Phone ------------------------------ */ 190 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) 191 | /* Microsoft Windows Store or Universal Windows Platform - (32-bit). 192 | * ------------------------------ */ 193 | #define __PLATFORM_OS "Windows" 194 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 195 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP (32-Bit)" 196 | #define __PLATFORM_DEVICE "Desktop" 197 | #define __PLATFORM_TYPE "PC (Windows)" 198 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) && \ 199 | defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) 200 | /* Microsoft Windows (64-bit). ------------------------------ */ 201 | #define __PLATFORM_OS "Windows " 202 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows x64" 203 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP" 204 | #define __PLATFORM_DEVICE "Desktop" 205 | #define __PLATFORM_WINDOWS "Microsoft Windows" 206 | #define __PLATFORM_TYPE "PC (Windows)" 207 | /* Microsoft Phone ------------------------------ */ 208 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_phone_APP) 209 | /* Microsoft Windows (Phone). ------------------------------ */ 210 | #define __PLATFORM_OS "WindowsRT" 211 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 212 | #define __PLATFORM_DEVICE "Mobile" 213 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 214 | #elif defined(_WIN64) && defined(WINAPI_FAMILY_phone_APP) 215 | /* Microsoft Windows (Phone). ------------------------------ */ 216 | #define __PLATFORM_OS "WindowsRT" 217 | #define __PLATFORM_DEVICE "Mobile" 218 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 219 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 220 | #endif 221 | 222 | #if defined(__clang__) 223 | /* Clang/LLVM. ---------------------------------------------- */ 224 | #undef __PLATFORM_COMPILER 225 | #define __PLATFORM_COMPILER "Clang/LLVM" 226 | #undef __PLATFORM_COMPILER_ver 227 | #define __PLATFORM_COMPILER_ver __clang_version__ 228 | #elif defined(__ICC) || defined(__INTEL_COMPILER) 229 | /* Intel ICC/ICPC. ------------------------------------------ */ 230 | #define __PLATFORM_COMPILER "Intel ICC/ICPC" 231 | #define __PLATFORM_COMPILER_ver __INTEL_COMPILER_BUILD_DATE 232 | #elif defined(__MINGW32__) && !defined(__amd64__) && !defined(__amd64) && \ 233 | !defined(__ia64__) 234 | /* __MINGW32__. ------------------------------------------------- */ 235 | #undef __PLATFORM_COMPILER 236 | #define __PLATFORM_COMPILER "MinGW-w86 (x86) 32 Bit" 237 | #undef __PLATFORM_COMPILER_ver 238 | #define __PLATFORM_COMPILER_ver \ 239 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 240 | #elif defined(__MINGW32__) 241 | /* __MINGW32__. ------------------------------------------------- */ 242 | #undef __PLATFORM_COMPILER 243 | #define __PLATFORM_COMPILER "MinGW-w64 (x86_64) 32-64 Bit" 244 | #undef __PLATFORM_COMPILER_ver 245 | #define __PLATFORM_COMPILER_ver \ 246 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 247 | #elif defined(__MINGW64__) 248 | /* __MINGW64__. ------------------------------------------------- */ 249 | #undef __PLATFORM_COMPILER 250 | #define __PLATFORM_COMPILER "MinGW-w64 (x64) 64 Bit" 251 | #undef __PLATFORM_COMPILER_ver 252 | #define __PLATFORM_COMPILER_ver \ 253 | __MINGW64_MAJOR_VERSION << '.' << __MINGW64_MINOR_VERSION 254 | #elif defined(__GNUC__) || defined(__GNUG__) && !defined(__clang__) 255 | /* GNU GCC/G++. --------------------------------------------- */ 256 | #undef __PLATFORM_COMPILER 257 | #define __PLATFORM_COMPILER "GNU GCC/G++" 258 | #undef __PLATFORM_COMPILER_ver 259 | #define __PLATFORM_COMPILER_ver __GNUC__ 260 | #elif defined(__HPPP_cc) || defined(__HPPP_aCC) 261 | /* Hewlett-Packard C/aC++. ---------------------------------- */ 262 | #define __PLATFORM_COMPILER "Hewlett-Packard C/aC++" 263 | #define __PLATFORM_COMPILER_ver __HPPP_aCC 264 | #elif defined(__IBMC__) || defined(__IBMCPP__) 265 | /* IBM XL C/C++. -------------------------------------------- */ 266 | #define __PLATFORM_COMPILER "IBM XL C/C++" 267 | #define __PLATFORM_COMPILER_ver __xlC_veR 268 | #elif defined(_MSC_VER) 269 | /* Microsoft Visual Studio. --------------------------------- */ 270 | #undef __PLATFORM_COMPILER 271 | #define __PLATFORM_COMPILER "MSVC++ " 272 | #undef __PLATFORM_COMPILER_MSVC 273 | #define __PLATFORM_COMPILER_MSVC 274 | #undef __PLATFORM_COMPILER_ver_ 275 | #define __PLATFORM_COMPILER_ver _MSC_VER 276 | #elif defined(__PGI) 277 | /* Portland Group PGCC/PGCPP. ------------------------------- */ 278 | #define __PLATFORM_COMPILER "PGCC/PGCPP" 279 | #define __PLATFORM_COMPILER_ver __VERSION__ 280 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) 281 | /* Oracle Solaris Studio. ----------------------------------- */ 282 | #define __PLATFORM_COMPILER "Oracle Solaris" 283 | #define __PLATFORM_COMPILER_ver __SUNPRO_CC 284 | #endif 285 | 286 | #endif // COMMON_HPP 287 | -------------------------------------------------------------------------------- /Interface/plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "plugin.hpp" 2 | #include "plugininterface.hpp" 3 | 4 | Plugin::Plugin() 5 | { 6 | PluginInterface::instance().addName("Interface"); 7 | } 8 | 9 | Plugin::~Plugin() 10 | { 11 | } 12 | 13 | //std::string Plugin::getName() 14 | //{ 15 | // return m_name; 16 | //} 17 | 18 | //void Plugin::setName(const std::string &name) 19 | //{ 20 | // m_name = name; 21 | //} 22 | 23 | //std::string Plugin::getDescription() const noexcept 24 | //{ 25 | // return m_description; 26 | //} 27 | 28 | //void Plugin::setDescription(const std::string &desc) 29 | //{ 30 | // m_description = desc; 31 | //} 32 | 33 | //std::string Plugin::getVersion() const noexcept 34 | //{ 35 | // return m_version; 36 | //} 37 | 38 | //void Plugin::setVersion(const std::string &version) 39 | //{ 40 | // m_version = version; 41 | //} 42 | 43 | //std::string Plugin::getAuthor() const noexcept 44 | //{ 45 | // return m_author; 46 | //} 47 | 48 | //void Plugin::setAuthor(const std::string &author) 49 | //{ 50 | // m_author = author; 51 | //} 52 | 53 | -------------------------------------------------------------------------------- /Interface/plugin.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLUGIN_HPP 2 | #define PLUGIN_HPP 3 | 4 | #include "plugininterface.hpp" 5 | #include "common.hpp" 6 | 7 | /*! 8 | * \brief The PluginType enum 9 | */ 10 | enum class PluginType { 11 | Index, //!For global user service. 12 | Admin, //!For administrator service. 13 | System, //!For system service. 14 | Cron, //!For cron job service. 15 | Core, //!For cms core service. 16 | Theme, //!For cms template. 17 | Default //!For default global service. 18 | }; 19 | 20 | 21 | class __project_export Plugin 22 | { 23 | public: 24 | Plugin(); 25 | virtual ~Plugin(); 26 | 27 | /*! 28 | * \brief getName function returns name of plugin. 29 | * \return string of name. 30 | */ 31 | [[nodiscard]] virtual std::string getName() const noexcept = 0; 32 | 33 | /*! 34 | * \brief getDescription function returns description of plugin. 35 | * \return string of details. 36 | */ 37 | [[nodiscard]] virtual std::string getDescription() const noexcept = 0; 38 | 39 | /*! 40 | * \brief getVersion function returns version of plugin. 41 | * \return string of version number. 42 | */ 43 | [[nodiscard]] virtual std::string getVersion() const noexcept = 0; 44 | 45 | /*! 46 | * \brief getVersion function returns version of plugin. 47 | * \return string of plugin's author. 48 | */ 49 | [[nodiscard]] virtual std::string getAuthor() const noexcept = 0; 50 | 51 | /*! 52 | * \brief doAction is action function for plugins. 53 | */ 54 | virtual void doAction() const noexcept = 0; 55 | 56 | template 57 | /*! 58 | * \brief action as auto! 59 | * \param val returns any type based on user input. 60 | */ 61 | auto action(const auto& val) 62 | { 63 | return val; 64 | } 65 | 66 | template 67 | /*! 68 | * \brief multiAction as multi types. 69 | * \param obj 70 | */ 71 | auto multiAction(T& obj) -> decltype(obj) { 72 | return obj; 73 | } 74 | 75 | /*! 76 | * \brief function type specifies the type of plugin. 77 | * \returns type of plugin. 78 | */ 79 | virtual PluginType type() const noexcept = 0; 80 | 81 | protected: 82 | friend class PluginManager; 83 | void setName(const std::string& name); 84 | void setDescription(const std::string& desc); 85 | void setVersion(const std::string& version); 86 | void setAuthor(const std::string& author); 87 | 88 | private: 89 | PluginType m_pluginType = {PluginType::Default}; 90 | std::string m_name = {"unknwon"}; 91 | std::string m_description = {"unknown"}; 92 | std::string m_version = {"unknown"}; 93 | std::string m_author = {"unknown"}; 94 | }; 95 | 96 | 97 | #endif // PLUGIN_HPP 98 | -------------------------------------------------------------------------------- /Interface/plugininterface.cpp: -------------------------------------------------------------------------------- 1 | #include "plugininterface.hpp" 2 | 3 | class PluginInterfaceImpl 4 | { 5 | public: 6 | NameList m_nameList; 7 | PluginList m_pluginList; 8 | ErrorString m_errors; 9 | }; 10 | 11 | PluginInterface::PluginInterface() 12 | { 13 | m_pImpl = new PluginInterfaceImpl(); 14 | return; 15 | } 16 | 17 | PluginInterface::~PluginInterface() 18 | { 19 | m_pImpl->m_nameList.clear(); 20 | delete m_pImpl; 21 | } 22 | 23 | PluginInterface& PluginInterface::instance() 24 | { 25 | static PluginInterface inst; 26 | return inst; 27 | } 28 | 29 | void PluginInterface::addDetail(const PluginList& plist) { 30 | m_pImpl->m_pluginList = plist; 31 | } 32 | 33 | void PluginInterface::addName(const std::string& name) 34 | { 35 | m_pImpl->m_nameList.push_back(name); 36 | } 37 | 38 | void PluginInterface::setError(const std::string &var) 39 | { 40 | m_pImpl->m_errors.push_back(var); 41 | } 42 | 43 | const NameList& PluginInterface::getNames() const 44 | { 45 | return m_pImpl->m_nameList; 46 | } 47 | 48 | const PluginList& PluginInterface::getDetail() const 49 | { 50 | return m_pImpl->m_pluginList; 51 | } 52 | 53 | const ErrorString& PluginInterface::getErrors() const 54 | { 55 | return m_pImpl->m_errors; 56 | } 57 | -------------------------------------------------------------------------------- /Interface/plugininterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLUGININTERFACE_HPP 2 | #define PLUGININTERFACE_HPP 3 | 4 | #include "common.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | //!JSON 11 | #include "third-party/json/json.hpp" 12 | //! TODO json configuration... 13 | //! Add new feature for configuration plugins based on json file. 14 | 15 | struct PluginDetail { 16 | std::string name; 17 | std::string description; 18 | std::string version; 19 | std::string author; 20 | }; 21 | 22 | //!GLOBAL 23 | using NameList = std::vector; 24 | using PluginList = std::vector; 25 | using ErrorString = std::vector; 26 | 27 | //!JSON 28 | using JSon = nlohmann::json; 29 | using JSonException = nlohmann::detail::exception; 30 | 31 | class PluginInterfaceImpl; 32 | 33 | /*! 34 | * \brief The PluginInterface class is exported from the mail library. 35 | */ 36 | class __project_export PluginInterface { 37 | public: 38 | //Return a static instance of this class 39 | static PluginInterface& instance(); 40 | 41 | /*! 42 | * \brief addDetail function sets all information of plugins. 43 | * \param plist is type of PluginList [std::vector] 44 | */ 45 | void addDetail(const PluginList& plist); 46 | 47 | /*! 48 | * \brief addName function sets name of plugins. 49 | * \param name of plugin. 50 | */ 51 | void addName(const std::string& name); 52 | 53 | /*! 54 | * \brief setError function sets message of error inside plugins. 55 | * \param var is message of error. 56 | */ 57 | void setError(const std::string& var); 58 | 59 | /*! 60 | * \brief getDetail function gets detail from plugins. 61 | * \return list of detail such as name, version and etc. 62 | */ 63 | const PluginList& getDetail() const; 64 | 65 | /*! 66 | * \brief getNames function gets name of plugins. 67 | * \return list of plugin. 68 | */ 69 | const NameList& getNames() const; 70 | 71 | /*! 72 | * \brief getErrors function gets list of errors. 73 | * \return list of errors as string [ErrorString : std::vector]. 74 | */ 75 | const ErrorString& getErrors() const; 76 | 77 | private: 78 | PluginInterface(); 79 | virtual ~PluginInterface(); 80 | PluginInterfaceImpl* m_pImpl = {nullptr}; 81 | NameList m_nameList; 82 | PluginList m_pluginList; 83 | ErrorString m_errors; 84 | }; 85 | 86 | 87 | #endif // PLUGININTERFACE_HPP 88 | -------------------------------------------------------------------------------- /Interface/pluginmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "pluginmanager.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using PluginMap = std::map; 12 | 13 | using LibraryMap = std::map; 14 | 15 | class PluginManagerPimpl 16 | { 17 | public: 18 | PluginMap m_plugins; 19 | LibraryMap m_libs; 20 | }; 21 | 22 | PluginManager::PluginManager() 23 | { 24 | m_implementation = std::make_unique(); 25 | } 26 | 27 | PluginManager::~PluginManager() 28 | { 29 | 30 | } 31 | 32 | PluginManager& PluginManager::instance() 33 | { 34 | static PluginManager pluginManager; 35 | return pluginManager; 36 | } 37 | 38 | Plugin* PluginManager::load(const std::string& name) 39 | { 40 | Plugin* plugin = nullptr; 41 | PluginMap::iterator iter = m_implementation->m_plugins.find(name); 42 | if (iter == m_implementation->m_plugins.end()) 43 | { 44 | // Try to load the plugin library 45 | #if defined(__PLATFORM_WINDOWS) 46 | void *hModule; 47 | hModule = LoadLibraryW(name.c_str()); 48 | #elif defined(__PLATFORM_MAC) 49 | void *hModule; 50 | hModule = dlopen(name.c_str(), RTLD_LAZY); 51 | #elif defined(__PLATFORM_LINUX) 52 | void *hModule; 53 | hModule = dlopen(name.c_str(), RTLD_LAZY); 54 | #endif 55 | 56 | if (hModule != nullptr) 57 | { 58 | 59 | #if defined(__PLATFORM_WINDOWS) 60 | fnCreatePlugin CreatePlugin = (fnCreatePlugin)GetProcAddress(hModule, "CreatePlugin"); 61 | #elif defined(__PLATFORM_MAC) 62 | fnCreatePlugin CreatePlugin = (fnCreatePlugin)dlsym(hModule, "CreatePlugin"); 63 | #elif defined(__PLATFORM_LINUX) 64 | fnCreatePlugin CreatePlugin = (fnCreatePlugin)dlsym(hModule, "CreatePlugin"); 65 | #endif 66 | 67 | if (CreatePlugin != nullptr) 68 | { 69 | // Invoke the function to get the plugin from the DLL. 70 | plugin = CreatePlugin(); 71 | 72 | if (plugin != nullptr) 73 | { 74 | //plugin->setName(pluginName); set real name not a name! 75 | // Add the plugin and library18 to the maps. 76 | m_implementation->m_plugins.insert(PluginMap::value_type(name, plugin)); 77 | m_implementation->m_libs.insert(LibraryMap::value_type(name, hModule)); 78 | } 79 | else 80 | { 81 | std::wcerr << "ERROR: Could not load plugin from " << name.c_str() << std::endl; 82 | 83 | // Unload the library. 84 | #if defined(__PLATFORM_WINDOWS) 85 | FreeLibrary(hModule); 86 | #elif defined(__PLATFORM_MAC) 87 | dlclose(hModule); 88 | #elif defined(__PLATFORM_LINUX) 89 | dlclose(hModule); 90 | #endif 91 | } 92 | } 93 | else 94 | { 95 | std::wcerr << "ERROR: Could not find symbol \"CreatePlugin\" in " << name.c_str() << std::endl; 96 | #if defined(__PLATFORM_WINDOWS) 97 | FreeLibrary(hModule); 98 | #elif defined(__PLATFORM_MAC) 99 | dlclose(hModule); 100 | #elif defined(__PLATFORM_LINUX) 101 | dlclose(hModule); 102 | #endif 103 | } 104 | } 105 | else 106 | { 107 | std::wcerr << "ERROR: Could not load library: " << name.c_str() << std::endl; 108 | m_status = {false}; 109 | } 110 | } 111 | else 112 | { 113 | std::wcout << "INFO: Library \"" << name.c_str() << "\" already loaded." << std::endl; 114 | plugin = iter->second; 115 | m_status = {true}; 116 | } 117 | return plugin; 118 | } 119 | 120 | void PluginManager::unload(Plugin *&plugin) 121 | { 122 | if (plugin != nullptr) 123 | { 124 | LibraryMap::iterator iter = m_implementation->m_libs.find(plugin->getName()); 125 | if(iter != m_implementation->m_libs.end()) 126 | { 127 | // Remove the plugin from our plugin map. 128 | m_implementation->m_plugins.erase(plugin->getName()); 129 | void* hModule = iter->second; 130 | #if defined(__PLATFORM_WINDOWS) 131 | fnDestroyPlugin DestroyPlugin = (fnDestroyPlugin)GetProcAddress(hModule, "DestroyPlugin"); 132 | #elif defined(__PLATFORM_MAC) 133 | fnDestroyPlugin DestroyPlugin = (fnDestroyPlugin)dlsym(hModule, "DestroyPlugin"); 134 | #elif defined(__PLATFORM_LINUX) 135 | fnDestroyPlugin DestroyPlugin = (fnDestroyPlugin)dlsym(hModule, "DestroyPlugin"); 136 | #endif 137 | if (DestroyPlugin != nullptr) 138 | { 139 | DestroyPlugin(); 140 | } 141 | else 142 | { 143 | std::wcerr << "ERROR: Unable to find symbol \"DestroyPlugin\" in library \"" << plugin->getName().c_str() << std::endl; 144 | } 145 | // Unload the library and remove the library from the map. 146 | #if defined(__PLATFORM_WINDOWS) 147 | FreeLibrary(hModule); 148 | #elif defined(__PLATFORM_MAC) 149 | dlclose(hModule); 150 | #elif defined(__PLATFORM_LINUX) 151 | dlclose(hModule); 152 | #endif 153 | m_implementation->m_libs.erase(iter); 154 | } 155 | else 156 | { 157 | std::cout << "WARNING: Trying to unload a plugin that is already unloaded or has never been loaded." << std::endl; 158 | } 159 | plugin = nullptr; 160 | } 161 | } 162 | 163 | bool PluginManager::isLoaded() const 164 | { 165 | return m_status; 166 | } 167 | -------------------------------------------------------------------------------- /Interface/pluginmanager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLUGINMANAGER_HPP 2 | #define PLUGINMANAGER_HPP 3 | 4 | #include "plugin.hpp" 5 | #include "plugininterface.hpp" 6 | #include 7 | #include 8 | 9 | // Define the prototype for a function that should exist in the lib 10 | // that is used to create and return the plugin type in the lib. 11 | 12 | PointerToObject(Plugin, fnCreatePlugin) 13 | 14 | // Destroys the plugin type from the lib before the library is unloaded. 15 | using fnDestroyPlugin = PointerToFunction; 16 | 17 | class PluginManagerPimpl; 18 | 19 | /*! 20 | * \brief The PluginManager class 21 | */ 22 | class __project_export PluginManager 23 | { 24 | public: 25 | static PluginManager& instance(); 26 | 27 | /*! 28 | * \brief load function loads the plugin and returns true if the plugin was loaded successfully; otherwise returns false. 29 | * \param plugin is plugin name. 30 | * \return plugin. 31 | */ 32 | Plugin* load(const std::string& plugin); 33 | 34 | /*! 35 | * \brief unload function unloads the plugin and returns true if the plugin could be unloaded; otherwise returns false. 36 | * \param plugin 37 | */ 38 | void unload(Plugin*& plugin); 39 | 40 | /*! 41 | * \brief isLoaded function returns true if the plugin is loaded; otherwise returns false. 42 | * \return bolean of status. 43 | */ 44 | bool isLoaded() const; 45 | 46 | private: 47 | PluginManager(); 48 | ~PluginManager(); 49 | 50 | bool m_status = {false}; 51 | 52 | std::unique_ptr m_implementation; 53 | }; 54 | 55 | 56 | #endif // PLUGINMANAGER_HPP 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Kambiz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Plugins/PluginOne/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(PluginOne LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 20) 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 8 | 9 | set(PREFIX_HPPHEADER *.hpp) 10 | set(PREFIX_SOURCE *.cpp) 11 | 12 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 13 | 14 | file(GLOB SOURCESFILE 15 | ${PREFIX_HPPHEADER} 16 | ${PREFIX_SOURCE} 17 | ) 18 | 19 | include_directories(${PROJECT_SOURCE_DIR}/../../Interface/) 20 | 21 | option(ENABLE_STATIC "Enable building static for ${PROJECT_NAME}" FALSE) 22 | 23 | if(ENABLE_STATIC) 24 | add_library(${PROJECT_NAME} STATIC ${SOURCESFILE}) 25 | else() 26 | add_library(${PROJECT_NAME} SHARED ${SOURCESFILE}) 27 | endif() 28 | 29 | target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/../../Interface/build) 30 | target_link_libraries(${PROJECT_NAME} PRIVATE PluginInterface) 31 | 32 | install(TARGETS ${PROJECT_NAME} DESTINATION build/lib) 33 | 34 | -------------------------------------------------------------------------------- /Plugins/PluginOne/common.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * MIT License 3 | * 4 | * @author : Kambiz Asadzadeh 5 | * @file : This file is a part of the project. 6 | * @version : 1.0 7 | * @copyright : Copyright (c) 2020 Kambiz Asadzadeh 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | */ 27 | 28 | #ifndef COMMON_HPP 29 | #define COMMON_HPP 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | constexpr std::string_view __project_full_version = "0.5"; 36 | constexpr std::string_view __project_release_mode = "alpha"; 37 | constexpr std::string_view __project_release_mode_number = "2"; 38 | 39 | #define STLLIB_STANDARD 0x0 40 | #define STLLIB_TECHNICAL_REPORT 0x1 41 | #define STLLIB_EXPERIMENTAL 0x2 42 | #define STLLIB_BOOST 0x3 43 | #define STLLIB_NETWORKING_ERROR "We don't even have access to networking TS." 44 | #define STLLIB_SYSTEM_ERROR "We don't even have access to system TS." 45 | #define BOOST_ASIO_NO_DEPRECATED 46 | 47 | #undef PROJECT_COPYRIGHT 48 | #define PROJECT_COPYRIGHT 1 49 | 50 | //! Compiler Predefined Variables. 51 | 52 | #define __project_null_str "" 53 | #define __project_zero 0 54 | #define __project_newline "\n" 55 | #define __project_compiler_counter __COUNTER__ 56 | #define __project_compiler_line __LINE__ 57 | #define __project_compiler_file __FILE__ 58 | #define __project_compiler_function __FUNCTION__ 59 | #define __project_compiler_pretty_function __PRETTY_FUNCTION__ 60 | #define __project_compiled_date __DATE__ 61 | #define __project_compiler_time __TIME__ 62 | 63 | #define __project_has_include __has_include 64 | 65 | #define PROJECT_BRACE_BEGIN { 66 | #define PROJECT_BRACE_END } 67 | #define PROJECT_USING_NAMESPACE using namespace 68 | #define PROJECT_NAMESPACE_BEGIN(x) namespace x { 69 | #define PROJECT_ANONYMOUS_NAMESPACE_BEGIN namespace { 70 | #define PROJECT_NAMESPACE_END } 71 | #define PROJECT_USING using 72 | #define PROJECT_NAMESPACE namespace 73 | 74 | /* 75 | * C++11 keywords and expressions 76 | */ 77 | #ifdef PROJECT_COMPILER_NULLPTR 78 | # define __project_nullptr nullptr 79 | #else 80 | # define __project_nullptr NULL 81 | #endif 82 | 83 | # define __project_override override 84 | # define __project_final final 85 | 86 | # define __project_noexcept noexcept 87 | # define __project_noexcept_expr(x) noexcept(x) 88 | 89 | #define __project_no_discard [[nodiscard]] 90 | #define __project_no_discard_message(x) [[nodiscard(x)]] 91 | 92 | #define PROJECT_HAS_INCLUDE __has_include 93 | #define PROJECT_ENABLE_SHARED_FROM(x) std::enable_shared_from_this 94 | 95 | #define PROJECT_MOVE(x) std::move(x) 96 | 97 | #define PROJECT_DEFAULT_OCTORS(Class) \ 98 | Class();\ 99 | ~Class(); 100 | 101 | #define PROJECT_DEFAULT_OCTORS_IMPL(Class) \ 102 | Class::Class()\ 103 | {\ 104 | }\ 105 | Class::~Class()\ 106 | {\ 107 | }\ 108 | 109 | #define PointerToObject(object, name)\ 110 | typedef object* (*name)(); 111 | 112 | #define PointerToFunction void(*)() 113 | 114 | #define __project_enum enum class 115 | 116 | #define __project_shared_ptr(Class) \ 117 | std::shared_ptr 118 | 119 | #define PROJECT_DISABLE_COPY(Class) \ 120 | Class(const Class &) = delete;\ 121 | Class &operator=(const Class &) = delete; 122 | 123 | #define PROJECT_DISABLE_MOVE(Class) \ 124 | Class(Class &&) = delete; \ 125 | Class &operator=(Class &&) = delete; 126 | 127 | #define PROJECT_DISABLE_COPY_MOVE(Class) \ 128 | PROJECT_DISABLE_COPY(Class) \ 129 | PROJECT_DISABLE_MOVE(Class) 130 | 131 | #if defined(__WINNT) || defined(__WINNT__) || defined(WIN32) || \ 132 | defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || \ 133 | defined(WIN64) || defined(_WIN64) || defined(__WIN64) || \ 134 | defined(__WIN64__) 135 | //! Microsoft Windows 136 | #define __project_export __declspec(dllexport) 137 | #define __project_import __declspec(dllimport) 138 | #elif defined(__GNUC__) 139 | //! Define for Unix base OS such as: Linux, macOS, FreeBSD, etc... 140 | #define __project_export __attribute__((visibility("default"))) 141 | #define __project_import __attribute__((visibility("default"))) 142 | #define __project_hidden __attribute__((visibility("hidden"))) 143 | #else 144 | // do nothing and hope for the best? 145 | #define __project_export 146 | #define __project_import 147 | #pragma warning Unknown dynamic link import / export semantics. 148 | #endif 149 | 150 | #if defined(__APPLE__) && defined(__MACH__) 151 | /* macOS */ 152 | #define __PLATFORM_OS "macOS" 153 | #define __PLATFORM_MAC "Unix-macOS (X11)" 154 | #define __PLATFORM_TYPE "Macintosh" 155 | #elif defined(__linux__) && defined(linux) && !defined(__ANDROID__) && \ 156 | !defined(ANDROID) 157 | /* Linux. --------------------------------------------------- */ 158 | #define __PLATFORM_OS "Linux" 159 | #define __PLATFORM_LINUX "Linux" 160 | #define __PLATFORM_DEVICE "Desktop" 161 | #define __PLATFORM_TYPE "Unix (Linux)" 162 | #elif defined(X64_64bit) && defined(__linux) && defined(__linux__) && \ 163 | defined(linux) && !defined(__ANDROID__) && !defined(ANDROID) 164 | /* Linux. --------------------------------------------------- */ 165 | #define __PLATFORM_OS "Linux" 166 | #define __PLATFORM_LINUX "Linux" 167 | #define __PLATFORM_DEVICE "Desktop" 168 | #define __PLATFORM_TYPE "Unix (Linux)" 169 | #elif defined(_WIN32) || defined(_WIN32_WINNT) && !defined(_WIN64) && \ 170 | !defined(WINAPI_FAMILY_phone_APP) && \ 171 | !defined(WINAPI_FAMILY) && \ 172 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 173 | /* Microsoft Windows (32-bit). ------------------------------ */ 174 | #define __PLATFORM_OS "Windows" 175 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 176 | #define __PLATFORM_WINDOWS "Microsoft Windows (32-Bit)" 177 | #define __PLATFORM_DEVICE "Desktop" 178 | #define __PLATFORM_TYPE "PC (Windows)" 179 | #elif defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) && \ 180 | !defined(WINAPI_FAMILY_phone_APP) && \ 181 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 182 | /* Microsoft Windows (64-bit). ------------------------------ */ 183 | #define __PLATFORM_OS "Windows " 184 | #define __PLATFORM_ARCH "x64 (64-Bit)" 185 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows" 186 | #define __PLATFORM_DEVICE "Desktop" 187 | #define __PLATFORM_WINDOWS "Microsoft Windows" 188 | #define __PLATFORM_TYPE "PC (Windows)" 189 | /* Microsoft Phone ------------------------------ */ 190 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) 191 | /* Microsoft Windows Store or Universal Windows Platform - (32-bit). 192 | * ------------------------------ */ 193 | #define __PLATFORM_OS "Windows" 194 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 195 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP (32-Bit)" 196 | #define __PLATFORM_DEVICE "Desktop" 197 | #define __PLATFORM_TYPE "PC (Windows)" 198 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) && \ 199 | defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) 200 | /* Microsoft Windows (64-bit). ------------------------------ */ 201 | #define __PLATFORM_OS "Windows " 202 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows x64" 203 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP" 204 | #define __PLATFORM_DEVICE "Desktop" 205 | #define __PLATFORM_WINDOWS "Microsoft Windows" 206 | #define __PLATFORM_TYPE "PC (Windows)" 207 | /* Microsoft Phone ------------------------------ */ 208 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_phone_APP) 209 | /* Microsoft Windows (Phone). ------------------------------ */ 210 | #define __PLATFORM_OS "WindowsRT" 211 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 212 | #define __PLATFORM_DEVICE "Mobile" 213 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 214 | #elif defined(_WIN64) && defined(WINAPI_FAMILY_phone_APP) 215 | /* Microsoft Windows (Phone). ------------------------------ */ 216 | #define __PLATFORM_OS "WindowsRT" 217 | #define __PLATFORM_DEVICE "Mobile" 218 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 219 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 220 | #endif 221 | 222 | #if defined(__clang__) 223 | /* Clang/LLVM. ---------------------------------------------- */ 224 | #undef __PLATFORM_COMPILER 225 | #define __PLATFORM_COMPILER "Clang/LLVM" 226 | #undef __PLATFORM_COMPILER_ver 227 | #define __PLATFORM_COMPILER_ver __clang_version__ 228 | #elif defined(__ICC) || defined(__INTEL_COMPILER) 229 | /* Intel ICC/ICPC. ------------------------------------------ */ 230 | #define __PLATFORM_COMPILER "Intel ICC/ICPC" 231 | #define __PLATFORM_COMPILER_ver __INTEL_COMPILER_BUILD_DATE 232 | #elif defined(__MINGW32__) && !defined(__amd64__) && !defined(__amd64) && \ 233 | !defined(__ia64__) 234 | /* __MINGW32__. ------------------------------------------------- */ 235 | #undef __PLATFORM_COMPILER 236 | #define __PLATFORM_COMPILER "MinGW-w86 (x86) 32 Bit" 237 | #undef __PLATFORM_COMPILER_ver 238 | #define __PLATFORM_COMPILER_ver \ 239 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 240 | #elif defined(__MINGW32__) 241 | /* __MINGW32__. ------------------------------------------------- */ 242 | #undef __PLATFORM_COMPILER 243 | #define __PLATFORM_COMPILER "MinGW-w64 (x86_64) 32-64 Bit" 244 | #undef __PLATFORM_COMPILER_ver 245 | #define __PLATFORM_COMPILER_ver \ 246 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 247 | #elif defined(__MINGW64__) 248 | /* __MINGW64__. ------------------------------------------------- */ 249 | #undef __PLATFORM_COMPILER 250 | #define __PLATFORM_COMPILER "MinGW-w64 (x64) 64 Bit" 251 | #undef __PLATFORM_COMPILER_ver 252 | #define __PLATFORM_COMPILER_ver \ 253 | __MINGW64_MAJOR_VERSION << '.' << __MINGW64_MINOR_VERSION 254 | #elif defined(__GNUC__) || defined(__GNUG__) && !defined(__clang__) 255 | /* GNU GCC/G++. --------------------------------------------- */ 256 | #undef __PLATFORM_COMPILER 257 | #define __PLATFORM_COMPILER "GNU GCC/G++" 258 | #undef __PLATFORM_COMPILER_ver 259 | #define __PLATFORM_COMPILER_ver __GNUC__ 260 | #elif defined(__HPPP_cc) || defined(__HPPP_aCC) 261 | /* Hewlett-Packard C/aC++. ---------------------------------- */ 262 | #define __PLATFORM_COMPILER "Hewlett-Packard C/aC++" 263 | #define __PLATFORM_COMPILER_ver __HPPP_aCC 264 | #elif defined(__IBMC__) || defined(__IBMCPP__) 265 | /* IBM XL C/C++. -------------------------------------------- */ 266 | #define __PLATFORM_COMPILER "IBM XL C/C++" 267 | #define __PLATFORM_COMPILER_ver __xlC_veR 268 | #elif defined(_MSC_VER) 269 | /* Microsoft Visual Studio. --------------------------------- */ 270 | #undef __PLATFORM_COMPILER 271 | #define __PLATFORM_COMPILER "MSVC++ " 272 | #undef __PLATFORM_COMPILER_MSVC 273 | #define __PLATFORM_COMPILER_MSVC 274 | #undef __PLATFORM_COMPILER_ver_ 275 | #define __PLATFORM_COMPILER_ver _MSC_VER 276 | #elif defined(__PGI) 277 | /* Portland Group PGCC/PGCPP. ------------------------------- */ 278 | #define __PLATFORM_COMPILER "PGCC/PGCPP" 279 | #define __PLATFORM_COMPILER_ver __VERSION__ 280 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) 281 | /* Oracle Solaris Studio. ----------------------------------- */ 282 | #define __PLATFORM_COMPILER "Oracle Solaris" 283 | #define __PLATFORM_COMPILER_ver __SUNPRO_CC 284 | #endif 285 | 286 | #endif // COMMON_HPP 287 | -------------------------------------------------------------------------------- /Plugins/PluginOne/interface.cpp: -------------------------------------------------------------------------------- 1 | #include "interface.hpp" 2 | #include "plugin.hpp" 3 | 4 | #include 5 | #include 6 | 7 | Interface::Interface() 8 | { 9 | m_detail.name = "Plugin One"; 10 | m_detail.description = "This is Plugin One for Tegra CMS."; 11 | m_detail.version = "0.5"; 12 | m_detail.author = "Kambiz Asadzadeh"; 13 | 14 | PluginList plist = {m_detail}; 15 | PluginInterface::instance().addDetail(plist); 16 | PluginInterface::instance().addName(m_detail.name); 17 | } 18 | 19 | Interface::~Interface() 20 | { 21 | } 22 | 23 | std::string Interface::getName() const noexcept { 24 | return "Plugin One"; 25 | } 26 | 27 | std::string Interface::getDescription() const noexcept { 28 | return "This is theme changer plugin for Tegra CMS."; 29 | } 30 | 31 | std::string Interface::getVersion() const noexcept { 32 | return "0.2"; 33 | } 34 | 35 | std::string Interface::getAuthor() const noexcept { 36 | return "Kambiz Asadzadeh"; 37 | } 38 | 39 | void Interface::doAction() const noexcept { 40 | std::cout << "Do action... for " << m_detail.name << " !\n"; 41 | std::stringstream message; 42 | message << "Error on line : " << __project_compiler_line << " inside plugin : " << m_detail.name; 43 | PluginInterface::instance().setError(message.str()); 44 | } 45 | 46 | PluginType Interface::type() const noexcept { 47 | return PluginType::Theme; 48 | } 49 | -------------------------------------------------------------------------------- /Plugins/PluginOne/interface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CONCRETEPLUGIN_HPP 2 | #define CONCRETEPLUGIN_HPP 3 | 4 | #include "pluginone.hpp" 5 | 6 | class __project_export Interface : public Plugin 7 | { 8 | public: 9 | Interface(); 10 | ~Interface(); 11 | 12 | [[nodiscard]] std::string getName() const noexcept override; 13 | 14 | [[nodiscard]] std::string getDescription() const noexcept override; 15 | 16 | [[nodiscard]] std::string getVersion() const noexcept override; 17 | 18 | [[nodiscard]] std::string getAuthor() const noexcept override; 19 | 20 | [[nodiscard]] PluginType type() const noexcept override; 21 | 22 | void doAction() const noexcept override; 23 | 24 | template 25 | auto action(const auto& val) 26 | { 27 | return val; 28 | } 29 | 30 | template 31 | auto multiAction(T& obj) -> decltype(obj) { 32 | return obj; 33 | } 34 | 35 | private: 36 | PluginDetail m_detail; 37 | 38 | }; 39 | 40 | 41 | #endif // CONCRETEPLUGIN_HPP 42 | -------------------------------------------------------------------------------- /Plugins/PluginOne/pluginone.cpp: -------------------------------------------------------------------------------- 1 | #include "pluginone.hpp" 2 | #include "interface.hpp" 3 | #include 4 | 5 | Interface* g_Interface = NULL; 6 | 7 | extern "C" __project_export Plugin* CreatePlugin() 8 | { 9 | assert(g_Interface == NULL); 10 | g_Interface = new Interface(); 11 | return g_Interface; 12 | } 13 | 14 | extern "C" __project_export void DestroyPlugin() 15 | { 16 | assert(g_Interface); 17 | delete g_Interface; 18 | g_Interface = NULL; 19 | } 20 | 21 | extern "C" __project_export void helloNow() 22 | { 23 | std::cout << "Hello from Plugin One!\n"; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Plugins/PluginOne/pluginone.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HELLOPLUGIN_HPP 2 | #define HELLOPLUGIN_HPP 3 | 4 | #include "plugin.hpp" 5 | #include 6 | 7 | // This class is exported from the PluginOne.dll 8 | class __project_export PluginOne { 9 | public: 10 | PluginOne(); 11 | // TODO: add your methods here. 12 | void helloNow(); 13 | }; 14 | 15 | extern "C" __project_export Plugin* CreatePlugin(); 16 | extern "C" __project_export void DestroyPlugin(); 17 | 18 | 19 | #endif // HELLOPLUGIN_HPP 20 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(PluginTwo LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 20) 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 8 | 9 | set(PREFIX_HPPHEADER *.hpp) 10 | set(PREFIX_SOURCE *.cpp) 11 | 12 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 13 | 14 | file(GLOB SOURCESFILE 15 | ${PREFIX_HPPHEADER} 16 | ${PREFIX_SOURCE} 17 | ) 18 | 19 | include_directories(${PROJECT_SOURCE_DIR}/../../Interface/) 20 | 21 | option(ENABLE_STATIC "Enable building static for ${PROJECT_NAME}" FALSE) 22 | 23 | if(ENABLE_STATIC) 24 | add_library(${PROJECT_NAME} STATIC ${SOURCESFILE}) 25 | else() 26 | add_library(${PROJECT_NAME} SHARED ${SOURCESFILE}) 27 | endif() 28 | 29 | target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/../../Interface/build) 30 | target_link_libraries(${PROJECT_NAME} PRIVATE PluginInterface) 31 | 32 | install(TARGETS ${PROJECT_NAME} DESTINATION build/lib) 33 | 34 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/common.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * MIT License 3 | * 4 | * @author : Kambiz Asadzadeh 5 | * @file : This file is a part of the project. 6 | * @version : 1.0 7 | * @copyright : Copyright (c) 2020 Kambiz Asadzadeh 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | */ 27 | 28 | #ifndef COMMON_HPP 29 | #define COMMON_HPP 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | constexpr std::string_view __project_full_version = "0.5"; 36 | constexpr std::string_view __project_release_mode = "alpha"; 37 | constexpr std::string_view __project_release_mode_number = "2"; 38 | 39 | #define STLLIB_STANDARD 0x0 40 | #define STLLIB_TECHNICAL_REPORT 0x1 41 | #define STLLIB_EXPERIMENTAL 0x2 42 | #define STLLIB_BOOST 0x3 43 | #define STLLIB_NETWORKING_ERROR "We don't even have access to networking TS." 44 | #define STLLIB_SYSTEM_ERROR "We don't even have access to system TS." 45 | #define BOOST_ASIO_NO_DEPRECATED 46 | 47 | #undef PROJECT_COPYRIGHT 48 | #define PROJECT_COPYRIGHT 1 49 | 50 | //! Compiler Predefined Variables. 51 | 52 | #define __project_null_str "" 53 | #define __project_zero 0 54 | #define __project_newline "\n" 55 | #define __project_compiler_counter __COUNTER__ 56 | #define __project_compiler_line __LINE__ 57 | #define __project_compiler_file __FILE__ 58 | #define __project_compiler_function __FUNCTION__ 59 | #define __project_compiler_pretty_function __PRETTY_FUNCTION__ 60 | #define __project_compiled_date __DATE__ 61 | #define __project_compiler_time __TIME__ 62 | 63 | #define __project_has_include __has_include 64 | 65 | #define PROJECT_BRACE_BEGIN { 66 | #define PROJECT_BRACE_END } 67 | #define PROJECT_USING_NAMESPACE using namespace 68 | #define PROJECT_NAMESPACE_BEGIN(x) namespace x { 69 | #define PROJECT_ANONYMOUS_NAMESPACE_BEGIN namespace { 70 | #define PROJECT_NAMESPACE_END } 71 | #define PROJECT_USING using 72 | #define PROJECT_NAMESPACE namespace 73 | 74 | /* 75 | * C++11 keywords and expressions 76 | */ 77 | #ifdef PROJECT_COMPILER_NULLPTR 78 | # define __project_nullptr nullptr 79 | #else 80 | # define __project_nullptr NULL 81 | #endif 82 | 83 | # define __project_override override 84 | # define __project_final final 85 | 86 | # define __project_noexcept noexcept 87 | # define __project_noexcept_expr(x) noexcept(x) 88 | 89 | #define __project_no_discard [[nodiscard]] 90 | #define __project_no_discard_message(x) [[nodiscard(x)]] 91 | 92 | #define PROJECT_HAS_INCLUDE __has_include 93 | #define PROJECT_ENABLE_SHARED_FROM(x) std::enable_shared_from_this 94 | 95 | #define PROJECT_MOVE(x) std::move(x) 96 | 97 | #define PROJECT_DEFAULT_OCTORS(Class) \ 98 | Class();\ 99 | ~Class(); 100 | 101 | #define PROJECT_DEFAULT_OCTORS_IMPL(Class) \ 102 | Class::Class()\ 103 | {\ 104 | }\ 105 | Class::~Class()\ 106 | {\ 107 | }\ 108 | 109 | #define PointerToObject(object, name)\ 110 | typedef object* (*name)(); 111 | 112 | #define PointerToFunction void(*)() 113 | 114 | #define __project_enum enum class 115 | 116 | #define __project_shared_ptr(Class) \ 117 | std::shared_ptr 118 | 119 | #define PROJECT_DISABLE_COPY(Class) \ 120 | Class(const Class &) = delete;\ 121 | Class &operator=(const Class &) = delete; 122 | 123 | #define PROJECT_DISABLE_MOVE(Class) \ 124 | Class(Class &&) = delete; \ 125 | Class &operator=(Class &&) = delete; 126 | 127 | #define PROJECT_DISABLE_COPY_MOVE(Class) \ 128 | PROJECT_DISABLE_COPY(Class) \ 129 | PROJECT_DISABLE_MOVE(Class) 130 | 131 | #if defined(__WINNT) || defined(__WINNT__) || defined(WIN32) || \ 132 | defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || \ 133 | defined(WIN64) || defined(_WIN64) || defined(__WIN64) || \ 134 | defined(__WIN64__) 135 | //! Microsoft Windows 136 | #define __project_export __declspec(dllexport) 137 | #define __project_import __declspec(dllimport) 138 | #elif defined(__GNUC__) 139 | //! Define for Unix base OS such as: Linux, macOS, FreeBSD, etc... 140 | #define __project_export __attribute__((visibility("default"))) 141 | #define __project_import __attribute__((visibility("default"))) 142 | #define __project_hidden __attribute__((visibility("hidden"))) 143 | #else 144 | // do nothing and hope for the best? 145 | #define __project_export 146 | #define __project_import 147 | #pragma warning Unknown dynamic link import / export semantics. 148 | #endif 149 | 150 | #if defined(__APPLE__) && defined(__MACH__) 151 | /* macOS */ 152 | #define __PLATFORM_OS "macOS" 153 | #define __PLATFORM_MAC "Unix-macOS (X11)" 154 | #define __PLATFORM_TYPE "Macintosh" 155 | #elif defined(__linux__) && defined(linux) && !defined(__ANDROID__) && \ 156 | !defined(ANDROID) 157 | /* Linux. --------------------------------------------------- */ 158 | #define __PLATFORM_OS "Linux" 159 | #define __PLATFORM_LINUX "Linux" 160 | #define __PLATFORM_DEVICE "Desktop" 161 | #define __PLATFORM_TYPE "Unix (Linux)" 162 | #elif defined(X64_64bit) && defined(__linux) && defined(__linux__) && \ 163 | defined(linux) && !defined(__ANDROID__) && !defined(ANDROID) 164 | /* Linux. --------------------------------------------------- */ 165 | #define __PLATFORM_OS "Linux" 166 | #define __PLATFORM_LINUX "Linux" 167 | #define __PLATFORM_DEVICE "Desktop" 168 | #define __PLATFORM_TYPE "Unix (Linux)" 169 | #elif defined(_WIN32) || defined(_WIN32_WINNT) && !defined(_WIN64) && \ 170 | !defined(WINAPI_FAMILY_phone_APP) && \ 171 | !defined(WINAPI_FAMILY) && \ 172 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 173 | /* Microsoft Windows (32-bit). ------------------------------ */ 174 | #define __PLATFORM_OS "Windows" 175 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 176 | #define __PLATFORM_WINDOWS "Microsoft Windows (32-Bit)" 177 | #define __PLATFORM_DEVICE "Desktop" 178 | #define __PLATFORM_TYPE "PC (Windows)" 179 | #elif defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) && \ 180 | !defined(WINAPI_FAMILY_phone_APP) && \ 181 | (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) 182 | /* Microsoft Windows (64-bit). ------------------------------ */ 183 | #define __PLATFORM_OS "Windows " 184 | #define __PLATFORM_ARCH "x64 (64-Bit)" 185 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows" 186 | #define __PLATFORM_DEVICE "Desktop" 187 | #define __PLATFORM_WINDOWS "Microsoft Windows" 188 | #define __PLATFORM_TYPE "PC (Windows)" 189 | /* Microsoft Phone ------------------------------ */ 190 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) 191 | /* Microsoft Windows Store or Universal Windows Platform - (32-bit). 192 | * ------------------------------ */ 193 | #define __PLATFORM_OS "Windows" 194 | #define __PLATFORM_WINDOWS_x86 "Microsoft Windows (32-Bit)" 195 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP (32-Bit)" 196 | #define __PLATFORM_DEVICE "Desktop" 197 | #define __PLATFORM_TYPE "PC (Windows)" 198 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) && \ 199 | defined(_WIN64) && !defined(_WIN32) && !defined(_WIN32_WINNT) 200 | /* Microsoft Windows (64-bit). ------------------------------ */ 201 | #define __PLATFORM_OS "Windows " 202 | #define __PLATFORM_WINDOWS_X64 "Microsoft Windows x64" 203 | #define __PLATFORM_WINDOWS_UWP "Microsoft Windows UWP" 204 | #define __PLATFORM_DEVICE "Desktop" 205 | #define __PLATFORM_WINDOWS "Microsoft Windows" 206 | #define __PLATFORM_TYPE "PC (Windows)" 207 | /* Microsoft Phone ------------------------------ */ 208 | #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_phone_APP) 209 | /* Microsoft Windows (Phone). ------------------------------ */ 210 | #define __PLATFORM_OS "WindowsRT" 211 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 212 | #define __PLATFORM_DEVICE "Mobile" 213 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 214 | #elif defined(_WIN64) && defined(WINAPI_FAMILY_phone_APP) 215 | /* Microsoft Windows (Phone). ------------------------------ */ 216 | #define __PLATFORM_OS "WindowsRT" 217 | #define __PLATFORM_DEVICE "Mobile" 218 | #define __PLATFORM_WINDOWS_phone "Windows Phone" 219 | #define __PLATFORM_TYPE "Mobile (Windows Phone)" 220 | #endif 221 | 222 | #if defined(__clang__) 223 | /* Clang/LLVM. ---------------------------------------------- */ 224 | #undef __PLATFORM_COMPILER 225 | #define __PLATFORM_COMPILER "Clang/LLVM" 226 | #undef __PLATFORM_COMPILER_ver 227 | #define __PLATFORM_COMPILER_ver __clang_version__ 228 | #elif defined(__ICC) || defined(__INTEL_COMPILER) 229 | /* Intel ICC/ICPC. ------------------------------------------ */ 230 | #define __PLATFORM_COMPILER "Intel ICC/ICPC" 231 | #define __PLATFORM_COMPILER_ver __INTEL_COMPILER_BUILD_DATE 232 | #elif defined(__MINGW32__) && !defined(__amd64__) && !defined(__amd64) && \ 233 | !defined(__ia64__) 234 | /* __MINGW32__. ------------------------------------------------- */ 235 | #undef __PLATFORM_COMPILER 236 | #define __PLATFORM_COMPILER "MinGW-w86 (x86) 32 Bit" 237 | #undef __PLATFORM_COMPILER_ver 238 | #define __PLATFORM_COMPILER_ver \ 239 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 240 | #elif defined(__MINGW32__) 241 | /* __MINGW32__. ------------------------------------------------- */ 242 | #undef __PLATFORM_COMPILER 243 | #define __PLATFORM_COMPILER "MinGW-w64 (x86_64) 32-64 Bit" 244 | #undef __PLATFORM_COMPILER_ver 245 | #define __PLATFORM_COMPILER_ver \ 246 | __MINGW32_MAJOR_VERSION << '.' << __MINGW32_MINOR_VERSION 247 | #elif defined(__MINGW64__) 248 | /* __MINGW64__. ------------------------------------------------- */ 249 | #undef __PLATFORM_COMPILER 250 | #define __PLATFORM_COMPILER "MinGW-w64 (x64) 64 Bit" 251 | #undef __PLATFORM_COMPILER_ver 252 | #define __PLATFORM_COMPILER_ver \ 253 | __MINGW64_MAJOR_VERSION << '.' << __MINGW64_MINOR_VERSION 254 | #elif defined(__GNUC__) || defined(__GNUG__) && !defined(__clang__) 255 | /* GNU GCC/G++. --------------------------------------------- */ 256 | #undef __PLATFORM_COMPILER 257 | #define __PLATFORM_COMPILER "GNU GCC/G++" 258 | #undef __PLATFORM_COMPILER_ver 259 | #define __PLATFORM_COMPILER_ver __GNUC__ 260 | #elif defined(__HPPP_cc) || defined(__HPPP_aCC) 261 | /* Hewlett-Packard C/aC++. ---------------------------------- */ 262 | #define __PLATFORM_COMPILER "Hewlett-Packard C/aC++" 263 | #define __PLATFORM_COMPILER_ver __HPPP_aCC 264 | #elif defined(__IBMC__) || defined(__IBMCPP__) 265 | /* IBM XL C/C++. -------------------------------------------- */ 266 | #define __PLATFORM_COMPILER "IBM XL C/C++" 267 | #define __PLATFORM_COMPILER_ver __xlC_veR 268 | #elif defined(_MSC_VER) 269 | /* Microsoft Visual Studio. --------------------------------- */ 270 | #undef __PLATFORM_COMPILER 271 | #define __PLATFORM_COMPILER "MSVC++ " 272 | #undef __PLATFORM_COMPILER_MSVC 273 | #define __PLATFORM_COMPILER_MSVC 274 | #undef __PLATFORM_COMPILER_ver_ 275 | #define __PLATFORM_COMPILER_ver _MSC_VER 276 | #elif defined(__PGI) 277 | /* Portland Group PGCC/PGCPP. ------------------------------- */ 278 | #define __PLATFORM_COMPILER "PGCC/PGCPP" 279 | #define __PLATFORM_COMPILER_ver __VERSION__ 280 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) 281 | /* Oracle Solaris Studio. ----------------------------------- */ 282 | #define __PLATFORM_COMPILER "Oracle Solaris" 283 | #define __PLATFORM_COMPILER_ver __SUNPRO_CC 284 | #endif 285 | 286 | #endif // COMMON_HPP 287 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/interface.cpp: -------------------------------------------------------------------------------- 1 | #include "interface.hpp" 2 | #include "plugin.hpp" 3 | #include 4 | #include 5 | 6 | Interface::Interface() 7 | { 8 | m_detail.name = "Plugin Two"; 9 | m_detail.description = "This is Plugin Two for Tegra CMS."; 10 | m_detail.version = "0.5"; 11 | m_detail.author = "Kambiz Asadzadeh"; 12 | 13 | PluginList plist = {m_detail}; 14 | PluginInterface::instance().addDetail(plist); 15 | PluginInterface::instance().addName(m_detail.name); 16 | 17 | } 18 | 19 | Interface::~Interface() 20 | { 21 | } 22 | 23 | std::string Interface::getName() const noexcept { 24 | return "Plugin Two"; 25 | } 26 | 27 | std::string Interface::getDescription() const noexcept { 28 | return "This is Plugin Two for Tegra CMS."; 29 | } 30 | 31 | std::string Interface::getVersion() const noexcept { 32 | return "0.2"; 33 | } 34 | 35 | std::string Interface::getAuthor() const noexcept { 36 | return "Kambiz Asadzadeh"; 37 | } 38 | 39 | void Interface::doAction() const noexcept { 40 | std::cout << "Do action... for " << m_detail.name << " !\n"; 41 | std::stringstream message; 42 | message << "Error on line : " << __project_compiler_line << " inside plugin : " << m_detail.name; 43 | PluginInterface::instance().setError(message.str()); 44 | } 45 | 46 | PluginType Interface::type() const noexcept { 47 | return PluginType::Admin; 48 | } 49 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/interface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CONCRETEPLUGIN_HPP 2 | #define CONCRETEPLUGIN_HPP 3 | 4 | #include "plugintwo.hpp" 5 | 6 | class __project_export Interface : public Plugin 7 | { 8 | public: 9 | Interface(); 10 | ~Interface(); 11 | 12 | [[nodiscard]] std::string getName() const noexcept override; 13 | 14 | [[nodiscard]] std::string getDescription() const noexcept override; 15 | 16 | [[nodiscard]] std::string getVersion() const noexcept override; 17 | 18 | [[nodiscard]] std::string getAuthor() const noexcept override; 19 | 20 | [[nodiscard]] PluginType type() const noexcept override; 21 | 22 | void doAction() const noexcept override; 23 | 24 | template 25 | auto action(const auto& val) 26 | { 27 | return val; 28 | } 29 | 30 | template 31 | auto multiAction(T& obj) -> decltype(obj) { 32 | return obj; 33 | } 34 | 35 | private: 36 | PluginDetail m_detail; 37 | 38 | }; 39 | 40 | 41 | #endif // CONCRETEPLUGIN_HPP 42 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/plugintwo.cpp: -------------------------------------------------------------------------------- 1 | #include "plugintwo.hpp" 2 | #include "interface.hpp" 3 | #include 4 | 5 | Interface* g_Interface = NULL; 6 | 7 | extern "C" __project_export Plugin* CreatePlugin() 8 | { 9 | assert(g_Interface == NULL); 10 | g_Interface = new Interface(); 11 | return g_Interface; 12 | } 13 | 14 | extern "C" __project_export void DestroyPlugin() 15 | { 16 | assert(g_Interface); 17 | delete g_Interface; 18 | g_Interface = NULL; 19 | } 20 | -------------------------------------------------------------------------------- /Plugins/PluginTwo/plugintwo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HELLOPLUGIN_HPP 2 | #define HELLOPLUGIN_HPP 3 | 4 | #include "plugin.hpp" 5 | #include 6 | 7 | // This class is exported from the PluginTwo.dll 8 | class __project_export PluginTwo { 9 | public: 10 | PluginTwo(); 11 | // TODO: add your methods here. 12 | }; 13 | 14 | extern "C" __project_export Plugin* CreatePlugin(); 15 | extern "C" __project_export void DestroyPlugin(); 16 | 17 | 18 | #endif // HELLOPLUGIN_HPP 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Concept of Dynamic Application 2 | This is a basic concept of dynamic software that supports plug-in feature. 3 | 4 | ## More information coming soon... 5 | 6 | ## Dynamic-Application is a concept cross-platform plug-in library ## 7 | **Note :** This library is not yet complete and conceptually under development. 8 | 9 | [![forthebadge](https://forthebadge.com/images/badges/made-with-c-plus-plus.svg)](https://forthebadge.com) 10 | 11 | ![Language iso: C++](https://img.shields.io/badge/C%2B%2B-20-blue) 12 | ![Version](https://img.shields.io/badge/Version-0.4-lightgrey) 13 | ![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20Android%20%7C%20Web-lightgrey) 14 | 15 | ## Building 16 | 17 | - You need CMake tool for building source code 18 | - All source code is written with Pure STL 1z (C++17, 20) 19 | - MSVC 2017, GCC8.x or Clang 9.x 20 | 21 | **Note:** In order to build the create, your compiler must support C++17 features. 22 | 23 | **Building extra option in CMake** 24 | ``` 25 | cmake .. -DEENABLE_STATIC=true 26 | ``` 27 | 28 | ## Usage Example 29 | Check the application main.cpp file. 30 | 31 | ## Contribution 32 | Bug fixes, docs, and enhancements welcome! Please let me know kambiz.ceo@gmail.com 33 | 34 | ## **ToDo** 35 | * Add more functions and features. 36 | --------------------------------------------------------------------------------