Commit fe885bcf2ae4578d2a4cf97e108dbfcbaea45ccb
0 parents
Initial commit.
Showing
22 changed files
with
1758 additions
and
0 deletions
.gitignore
0 → 100644
CMakeLists.txt
0 → 100644
| 1 | +++ a/CMakeLists.txt | |
| 1 | +cmake_minimum_required(VERSION 3.0) | |
| 2 | + | |
| 3 | +# Check to see where cmake is located. | |
| 4 | +if( IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) | |
| 5 | + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | |
| 6 | +elseif( IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../cmake ) | |
| 7 | + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) | |
| 8 | +else() | |
| 9 | + return() | |
| 10 | +endif() | |
| 11 | + | |
| 12 | +# Check to see if there is versioning information available | |
| 13 | +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake) | |
| 14 | + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake) | |
| 15 | + include(osdevversion) | |
| 16 | +endif() | |
| 17 | + | |
| 18 | +include(projectheader) | |
| 19 | +project_header(osdev_global) | |
| 20 | + | |
| 21 | +add_subdirectory(src) | |
| 22 | +add_subdirectory(tests) | |
| 23 | + | |
| 24 | +# include(packaging) | |
| 25 | +# package_component() | ... | ... |
README.md
0 → 100644
| 1 | +++ a/README.md | ... | ... |
src/CMakeLists.txt
0 → 100644
| 1 | +++ a/src/CMakeLists.txt | |
| 1 | +cmake_minimum_required(VERSION 3.0) | |
| 2 | +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake) | |
| 3 | +include(projectheader) | |
| 4 | +project_header(global) | |
| 5 | + | |
| 6 | +find_package( Qt5Core REQUIRED ) | |
| 7 | + | |
| 8 | +include_directories( SYSTEM | |
| 9 | + ${Qt5Core_INCLUDE_DIRS} | |
| 10 | + ${Qt5Core_PRIVATE_INCLUDE_DIRS} | |
| 11 | +) | |
| 12 | + | |
| 13 | +include(compiler) | |
| 14 | + | |
| 15 | +include_directories( | |
| 16 | + ${CMAKE_CURRENT_SOURCE_DIR}/../pugixml | |
| 17 | + ${CMAKE_CURRENT_SOURCE_DIR}/../config | |
| 18 | + ${CMAKE_CURRENT_SOURCE_DIR}/../logutils | |
| 19 | + ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces | |
| 20 | +) | |
| 21 | + | |
| 22 | +set(SRC_LIST | |
| 23 | + ${CMAKE_CURRENT_SOURCE_DIR}/argumentparserbase.cpp | |
| 24 | + ${CMAKE_CURRENT_SOURCE_DIR}/systeminfo.cpp | |
| 25 | + ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp | |
| 26 | + ${CMAKE_CURRENT_SOURCE_DIR}/pluginmanager.cpp | |
| 27 | + ${CMAKE_CURRENT_SOURCE_DIR}/conversionutils.cpp | |
| 28 | + ${CMAKE_CURRENT_SOURCE_DIR}/timeutils.cpp | |
| 29 | + ${CMAKE_CURRENT_SOURCE_DIR}/threadmon.cpp | |
| 30 | +) | |
| 31 | + | |
| 32 | +include(qtmoc) | |
| 33 | +create_mocs( SRC_LIST MOC_LIST | |
| 34 | + ${CMAKE_CURRENT_SOURCE_DIR}/pluginmanager.h | |
| 35 | +) | |
| 36 | + | |
| 37 | +link_directories( | |
| 38 | + ${CMAKE_BINARY_DIR}/lib | |
| 39 | +) | |
| 40 | + | |
| 41 | +include(library) | |
| 42 | +add_libraries( | |
| 43 | + ${Qt5Core_LIBRARIES} | |
| 44 | + logutils | |
| 45 | + config | |
| 46 | + interfaces | |
| 47 | + pugixml | |
| 48 | +) | |
| 49 | + | |
| 50 | +include(installation) | |
| 51 | +install_component() | ... | ... |
src/argumentparserbase.cpp
0 → 100644
| 1 | +++ a/src/argumentparserbase.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +// osdev::caelus | |
| 23 | +#include "argumentparserbase.h" | |
| 24 | + | |
| 25 | +using namespace osdev::components; | |
| 26 | + | |
| 27 | +ArgumentParserBase::ArgumentParserBase( const QStringList& arguments ) | |
| 28 | + : m_argument_list( arguments ) | |
| 29 | +{ | |
| 30 | +} | |
| 31 | + | |
| 32 | +ArgumentParserBase::~ArgumentParserBase() = default; | |
| 33 | + | |
| 34 | +void ArgumentParserBase::setArgumentList( const QStringList &arg_list ) | |
| 35 | +{ | |
| 36 | + m_argument_list = arg_list; | |
| 37 | +} | |
| 38 | + | |
| 39 | +QString ArgumentParserBase::getArgumentValue( const QString &argument_switch ) const | |
| 40 | +{ | |
| 41 | + QString l_result = QString(); | |
| 42 | + | |
| 43 | + if( 1 == m_argument_list.count( argument_switch ) ) | |
| 44 | + { | |
| 45 | + l_result = m_argument_list.at( m_argument_list.indexOf( argument_switch ) + 1 ); | |
| 46 | + } | |
| 47 | + | |
| 48 | + return l_result; | |
| 49 | +} | ... | ... |
src/argumentparserbase.h
0 → 100644
| 1 | +++ a/src/argumentparserbase.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_ARGUMENTPARSERBASE_H | |
| 23 | +#define OSDEV_COMPONENTS_ARGUMENTPARSERBASE_H | |
| 24 | + | |
| 25 | +#include <QString> | |
| 26 | +#include <QStringList> | |
| 27 | + | |
| 28 | +namespace osdev { | |
| 29 | +namespace components { | |
| 30 | + | |
| 31 | +class ArgumentParserBase | |
| 32 | +{ | |
| 33 | +public: | |
| 34 | + ArgumentParserBase(const QStringList& arguments = QStringList()); | |
| 35 | + virtual ~ArgumentParserBase(); | |
| 36 | + | |
| 37 | + void setArgumentList(const QStringList& arg_list); | |
| 38 | + QString getArgumentValue(const QString& argument_switch) const; | |
| 39 | + | |
| 40 | +private: | |
| 41 | + QStringList m_argument_list; | |
| 42 | +}; | |
| 43 | + | |
| 44 | +} /* End namespace components */ | |
| 45 | +} /* End namespace osdev */ | |
| 46 | + | |
| 47 | +#endif /* OSDEV_COMPONENTS_ARGUMENTPARSERBASE_H */ | ... | ... |
src/compat-c++14.h
0 → 100644
| 1 | +++ a/src/compat-c++14.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_COMPATCXX14 | |
| 23 | +#define OSDEV_COMPONENTS_COMPATCXX14 | |
| 24 | + | |
| 25 | +#include <memory> | |
| 26 | + | |
| 27 | +// The code below must be skipped if we use a C++ 14 or newer compiler | |
| 28 | +#if __cplusplus == 201103L | |
| 29 | + | |
| 30 | +namespace std | |
| 31 | +{ | |
| 32 | + | |
| 33 | +/// Copied from libstdc++ 4.9.2 bits/unique_ptr.h | |
| 34 | +template<typename _Tp> | |
| 35 | +struct _MakeUniq | |
| 36 | +{ | |
| 37 | + typedef unique_ptr<_Tp> __single_object; | |
| 38 | +}; | |
| 39 | + | |
| 40 | +template<typename _Tp> | |
| 41 | +struct _MakeUniq<_Tp[]> | |
| 42 | +{ | |
| 43 | + typedef unique_ptr<_Tp> __array; | |
| 44 | +}; | |
| 45 | + | |
| 46 | +template<typename _Tp, size_t _Bound> | |
| 47 | +struct _MakeUniq<_Tp[_Bound]> | |
| 48 | +{ | |
| 49 | + struct __invalid_type { }; | |
| 50 | +}; | |
| 51 | + | |
| 52 | +/// std::make_unique for single objects | |
| 53 | +template<typename _Tp, typename... _Args> | |
| 54 | +inline typename _MakeUniq<_Tp>::__single_object make_unique(_Args&&... __args) | |
| 55 | +{ | |
| 56 | + return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); | |
| 57 | +} | |
| 58 | + | |
| 59 | +/// std::make_unique for arrays of unknown bound | |
| 60 | +template<typename _Tp> | |
| 61 | +inline typename _MakeUniq<_Tp>::__array make_unique(size_t __num) | |
| 62 | +{ | |
| 63 | + return unique_ptr<_Tp>(new typename remove_extent<_Tp>::type[__num]()); | |
| 64 | +} | |
| 65 | + | |
| 66 | +/// Disable std::make_unique for arrays of known bound | |
| 67 | +template<typename _Tp, typename... _Args> | |
| 68 | +inline typename _MakeUniq<_Tp>::__invalid_type make_unique(_Args&&...) = delete; | |
| 69 | + | |
| 70 | +} /* End namespace std */ | |
| 71 | + | |
| 72 | +#endif /* End check for c++ 14 */ | |
| 73 | + | |
| 74 | +#endif /* OSDEV_COMPONENTS_COMPATCXX14 */ | ... | ... |
src/conversionutils.cpp
0 → 100644
| 1 | +++ a/src/conversionutils.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "conversionutils.h" | |
| 23 | + | |
| 24 | +using namespace osdev::components; | |
| 25 | + | |
| 26 | +namespace | |
| 27 | +{ | |
| 28 | + | |
| 29 | +QHash<QString, QVariant::Type> gQHTypes( | |
| 30 | + { | |
| 31 | + { "UNKNOWN", QVariant::Invalid }, | |
| 32 | + { "BITARRAY", QVariant::BitArray }, | |
| 33 | + { "BITMAP", QVariant::Bitmap }, | |
| 34 | + { "BOOL", QVariant::Bool }, | |
| 35 | + { "BRUSH", QVariant::Brush }, | |
| 36 | + { "BYTEARRAY", QVariant::ByteArray }, | |
| 37 | + { "CHAR", QVariant::Char }, | |
| 38 | + { "COLOR", QVariant::Color }, | |
| 39 | + { "CURSOR", QVariant::Cursor }, | |
| 40 | + { "DATE", QVariant::Date }, | |
| 41 | + { "DATETIME", QVariant::DateTime }, | |
| 42 | + { "DOUBLE", QVariant::Double }, | |
| 43 | + { "EASINGCURVE", QVariant::EasingCurve }, | |
| 44 | + { "UUID", QVariant::Uuid }, | |
| 45 | + { "MODELINDEX", QVariant::ModelIndex }, | |
| 46 | + { "FONT", QVariant::Font }, | |
| 47 | + { "HASH", QVariant::Hash }, | |
| 48 | + { "ICON", QVariant::Icon }, | |
| 49 | + { "IMAGE", QVariant::Image }, | |
| 50 | + { "INT", QVariant::Int }, | |
| 51 | + { "SMALLINT", QVariant::Int }, | |
| 52 | + { "KEYSEQUENCE", QVariant::KeySequence }, | |
| 53 | + { "LINE", QVariant::Line }, | |
| 54 | + { "LINEF", QVariant::LineF }, | |
| 55 | + { "LIST", QVariant::List }, | |
| 56 | + { "LOCALE", QVariant::Locale }, | |
| 57 | + { "LONGLONG", QVariant::LongLong }, | |
| 58 | + { "MAP", QVariant::Map }, | |
| 59 | + { "MATRIX", QVariant::Matrix }, | |
| 60 | + { "TRANSFORM", QVariant::Transform }, | |
| 61 | + { "MATRIX4X4", QVariant::Matrix4x4 }, | |
| 62 | + { "PALETTE", QVariant::Palette }, | |
| 63 | + { "PEN", QVariant::Pen }, | |
| 64 | + { "PIXMAP", QVariant::Pixmap }, | |
| 65 | + { "POINT", QVariant::Point }, | |
| 66 | + { "POINTF", QVariant::PointF }, | |
| 67 | + { "POLYGON", QVariant::Polygon }, | |
| 68 | + { "POLYGONF", QVariant::PolygonF }, | |
| 69 | + { "QUATERNION", QVariant::Quaternion }, | |
| 70 | + { "RECT", QVariant::Rect }, | |
| 71 | + { "RECTF", QVariant::RectF }, | |
| 72 | + { "REGEXP", QVariant::RegExp }, | |
| 73 | + { "REGULAREXPRESSION", QVariant::RegularExpression }, | |
| 74 | + { "REGION", QVariant::Region }, | |
| 75 | + { "SIZE", QVariant::Size }, | |
| 76 | + { "SIZEF", QVariant::SizeF }, | |
| 77 | + { "SIZEPOLICY", QVariant::SizePolicy }, | |
| 78 | + { "STRING", QVariant::String }, | |
| 79 | + { "STRINGLIST", QVariant::StringList }, | |
| 80 | + { "TEXTFORMAT", QVariant::TextFormat }, | |
| 81 | + { "TEXTLENGTH", QVariant::TextLength }, | |
| 82 | + { "TIME", QVariant::Time }, | |
| 83 | + { "UINT", QVariant::UInt }, | |
| 84 | + { "ULONGLONG", QVariant::ULongLong }, | |
| 85 | + { "URL", QVariant::Url }, | |
| 86 | + { "VECTOR2D", QVariant::Vector2D }, | |
| 87 | + { "VECTOR3D", QVariant::Vector3D }, | |
| 88 | + { "VECTOR4D", QVariant::Vector4D }, | |
| 89 | + { "USERTYPE", QVariant::UserType }, | |
| 90 | + | |
| 91 | + // PostGreSQL Datatypes, also aliases for historical purposes | |
| 92 | + | |
| 93 | + { "BIGINT", QVariant::Int }, | |
| 94 | + { "INT8", QVariant::Int }, | |
| 95 | + { "BIGSERIAL", QVariant::Int }, | |
| 96 | + { "SERIAL8", QVariant::Int }, | |
| 97 | + { "BIT", QVariant::String }, | |
| 98 | + { "BIT VARYING", QVariant::String }, | |
| 99 | + { "VARBIT", QVariant::String }, | |
| 100 | + { "BOOLEAN", QVariant::Bool }, | |
| 101 | + { "BYTEA", QVariant::String }, | |
| 102 | + { "CHARACTER", QVariant::String }, | |
| 103 | + { "CHAR", QVariant::String }, | |
| 104 | + { "CHARACTER VARYING", QVariant::String }, | |
| 105 | + { "CIDR", QVariant::String }, | |
| 106 | + { "DATE", QVariant::Date }, | |
| 107 | + { "DOUBLE PRECISION", QVariant::Double }, | |
| 108 | + { "FLOAT8", QVariant::Double }, | |
| 109 | + { "INET", QVariant::String }, | |
| 110 | + { "INTEGER", QVariant::Int }, | |
| 111 | + { "INT4", QVariant::Int }, | |
| 112 | + { "JSON", QVariant::String }, | |
| 113 | + { "MACADDR", QVariant::String }, | |
| 114 | + { "REAL", QVariant::Double }, | |
| 115 | + { "FLOAT4", QVariant::Double }, | |
| 116 | + { "INT2", QVariant::Int }, | |
| 117 | + { "SMALLSERIAL", QVariant::Int }, | |
| 118 | + { "SERIAL2", QVariant::Int }, | |
| 119 | + { "SERIAL", QVariant::Int }, | |
| 120 | + { "SERIAL4", QVariant::Int }, | |
| 121 | + { "TEXT", QVariant::String }, | |
| 122 | + { "TIME", QVariant::Time }, | |
| 123 | + { "TIMESTAMP", QVariant::DateTime }, | |
| 124 | + { "TIMESTAMP WITH TIME ZONE", QVariant::DateTime }, | |
| 125 | + { "TIMESTAMPTZ", QVariant::DateTime }, | |
| 126 | + { "TSQUERY", QVariant::String }, | |
| 127 | + { "UUID", QVariant::Uuid }, | |
| 128 | + { "XML", QVariant::String } | |
| 129 | + }); | |
| 130 | + | |
| 131 | +} // anonymous | |
| 132 | + | |
| 133 | +// static | |
| 134 | +QVariant::Type ConversionUtils::stringToQvarType( const QString& sValueType ) | |
| 135 | +{ | |
| 136 | + return gQHTypes.value( sValueType.toUpper() ); | |
| 137 | +} | |
| 138 | + | |
| 139 | +// static | |
| 140 | +QStringList ConversionUtils::getTypes() | |
| 141 | +{ | |
| 142 | + return QStringList( gQHTypes.keys() ); | |
| 143 | +} | |
| 144 | + | |
| 145 | +// static | |
| 146 | +QVariant ConversionUtils::convertToType( const QVariant &varValue, QVariant::Type varType ) | |
| 147 | +{ | |
| 148 | + QVariant varResult = varValue; | |
| 149 | + | |
| 150 | + if( varValue.type() == QVariant::Bool && varType == QVariant::String ) | |
| 151 | + { | |
| 152 | + if( varValue.toBool() ) | |
| 153 | + { | |
| 154 | + varResult = QVariant( QString( "1" ) ); | |
| 155 | + } | |
| 156 | + else | |
| 157 | + { | |
| 158 | + varResult = QVariant( QString( "0" ) ); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + else if( varValue.type() == QVariant::Bool && varType == QVariant::Int ) | |
| 162 | + { | |
| 163 | + if( varValue.toBool() ) | |
| 164 | + { | |
| 165 | + varResult = QVariant( 1 ); | |
| 166 | + } | |
| 167 | + else | |
| 168 | + { | |
| 169 | + varResult = QVariant( 0 ); | |
| 170 | + } | |
| 171 | + } | |
| 172 | + | |
| 173 | + return varResult; | |
| 174 | +} | |
| 175 | + | |
| 176 | +// static | |
| 177 | +QVariant ConversionUtils::convertToType(const QVariant &varValue, const QString &varType ) | |
| 178 | +{ | |
| 179 | + return convertToType( varValue, stringToQvarType( varType ) ); | |
| 180 | +} | ... | ... |
src/conversionutils.h
0 → 100644
| 1 | +++ a/src/conversionutils.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_CONVERSIONUTILS_H | |
| 23 | +#define OSDEV_COMPONENTS_CONVERSIONUTILS_H | |
| 24 | + | |
| 25 | +#include <QVariant> | |
| 26 | +#include <QString> | |
| 27 | +#include <QMetaType> | |
| 28 | +#include <QHash> | |
| 29 | + | |
| 30 | +namespace osdev { | |
| 31 | +namespace components { | |
| 32 | + | |
| 33 | +/*! | |
| 34 | + * \brief The ConversionUtils class converts an string expression to a QVariant Type. | |
| 35 | + * The modelmapper is build from a configurationfile and fieldtypes are given in strings | |
| 36 | + * By mapping those string expressions to the corresponding QVariant Type, we ensure the | |
| 37 | + * data is handled correctly. | |
| 38 | + * | |
| 39 | + * The number of types is *everything* mentioned in to Qt-documentation although | |
| 40 | + * it is doubtful we'll ever use everything. | |
| 41 | + * | |
| 42 | + * Instead of using the nameToType method of QVariant, we did our own translation table, | |
| 43 | + * making it possible to use Database types or any type whatsoever. | |
| 44 | + */ | |
| 45 | + | |
| 46 | +class ConversionUtils | |
| 47 | +{ | |
| 48 | +public: | |
| 49 | + ConversionUtils() = delete; | |
| 50 | + | |
| 51 | + static QVariant::Type stringToQvarType( const QString& sValueType ); | |
| 52 | + static QStringList getTypes(); | |
| 53 | + | |
| 54 | + static QVariant convertToType( const QVariant &varValue, QVariant::Type varType ); | |
| 55 | + static QVariant convertToType( const QVariant &varValue, const QString& varType ); | |
| 56 | +}; | |
| 57 | + | |
| 58 | +} /* End namespace components */ | |
| 59 | +} /* End namespace osdev */ | |
| 60 | + | |
| 61 | +#endif /* OSDEV_COMPONENTS_CONVERSIONUTILS_H */ | ... | ... |
src/globallibexport.h
0 → 100644
| 1 | +++ a/src/globallibexport.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_GLOBAL_LIBEXPORT_H | |
| 23 | +#define OSDEV_COMPONENTS_GLOBAL_LIBEXPORT_H | |
| 24 | + | |
| 25 | +#ifdef WIN32 | |
| 26 | + | |
| 27 | +#ifdef GLOBALLIB | |
| 28 | +#define GLOBALLIBINTERFACE __declspec(dllexport) | |
| 29 | +#else | |
| 30 | +#define GLOBALLIBINTERFACE __declspec(dllimport) | |
| 31 | +#endif | |
| 32 | + | |
| 33 | +#else | |
| 34 | +#define GLOBALLIBINTERFACE | |
| 35 | +#endif | |
| 36 | + | |
| 37 | + | |
| 38 | +#endif // OSDEV_COMPONENTS_GLOBAL_LIBEXPORT_H | ... | ... |
src/lockguard.h
0 → 100644
| 1 | +++ a/src/lockguard.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef MLOGIC_COMMON_LOCKGUARD_H | |
| 23 | +#define MLOGIC_COMMON_LOCKGUARD_H | |
| 24 | + | |
| 25 | +// std | |
| 26 | +#include <mutex> | |
| 27 | + | |
| 28 | +// mlogic::common | |
| 29 | +#include "mlogic/common/utils.h" | |
| 30 | + | |
| 31 | +#define MLOGIC_COMMON_LOCKGUARD(mutexVariableName) \ | |
| 32 | + std::lock_guard<std::mutex> Lock__Guard__##mutexVariableName##__(mutexVariableName); \ | |
| 33 | + mlogic::common::apply_unused_parameters(Lock__Guard__##mutexVariableName##__); | |
| 34 | + | |
| 35 | +#define MLOGIC_COMMON_RECURSIVELOCKGUARD(mutexVariableName) \ | |
| 36 | + std::lock_guard<std::recursive_mutex> Lock__Guard__##mutexVariableName##__(mutexVariableName); \ | |
| 37 | + mlogic::common::apply_unused_parameters(Lock__Guard__##mutexVariableName##__); | |
| 38 | + | |
| 39 | +#endif // MLOGIC_COMMON_LOCKGUARD_H | |
| 40 | + | ... | ... |
src/plugin.cpp
0 → 100644
| 1 | +++ a/src/plugin.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "plugin.h" | |
| 23 | + | |
| 24 | +namespace osdev { | |
| 25 | +namespace components { | |
| 26 | + | |
| 27 | +Plugin::Plugin( const QString& pluginName, const QString& pluginFile, const QString& pluginPath, | |
| 28 | + const QString& pluginConfig, const QUuid& pluginUuid, | |
| 29 | + QObject* ptr_plugin ) | |
| 30 | + : m_pluginName( pluginName ) | |
| 31 | + , m_pluginFile( pluginFile ) | |
| 32 | + , m_pluginPath( pluginPath ) | |
| 33 | + , m_pluginConfigurationFile( pluginConfig ) | |
| 34 | + , m_pluginUuid( pluginUuid ) | |
| 35 | + , m_plugin( ptr_plugin ) | |
| 36 | +{ | |
| 37 | +} | |
| 38 | + | |
| 39 | +Plugin::Plugin( const Plugin& other ) | |
| 40 | + : Plugin(other.name(), other.fileName(), other.path(), other.config(), other.uuid(), other.plugin()) | |
| 41 | +{ | |
| 42 | +} | |
| 43 | + | |
| 44 | +Plugin& Plugin::operator=( const Plugin& other ) | |
| 45 | +{ | |
| 46 | + if(this != &other) { | |
| 47 | + m_pluginName = other.name(); | |
| 48 | + m_pluginFile = other.fileName(); | |
| 49 | + m_pluginPath = other.path(); | |
| 50 | + m_pluginConfigurationFile = other.config(); | |
| 51 | + m_pluginUuid = other.uuid(); | |
| 52 | + m_plugin = other.plugin(); | |
| 53 | + } | |
| 54 | + return *this; | |
| 55 | +} | |
| 56 | + | |
| 57 | +QString Plugin::asString() | |
| 58 | +{ | |
| 59 | + QString PluginData = QString( "[PluginName = %1] [PluginFile = %2] [PluginPath = %3] [PluginConfigFile = %4] [PluginUUId = %5]" ) | |
| 60 | + .arg( m_pluginName ).arg( m_pluginFile ).arg( m_pluginPath ).arg( m_pluginConfigurationFile ).arg( m_pluginUuid.toString() ); | |
| 61 | + | |
| 62 | + return PluginData; | |
| 63 | +} | |
| 64 | + | |
| 65 | +} // End namespace components | |
| 66 | +} // End namespace osdev | |
| 67 | + | ... | ... |
src/plugin.h
0 → 100644
| 1 | +++ a/src/plugin.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_PLUGIN_H | |
| 23 | +#define OSDEV_COMPONENTS_PLUGIN_H | |
| 24 | + | |
| 25 | +#include <QString> | |
| 26 | +#include <QUuid> | |
| 27 | + | |
| 28 | +class QObject; | |
| 29 | + | |
| 30 | +namespace osdev { | |
| 31 | +namespace components { | |
| 32 | + | |
| 33 | +/*! | |
| 34 | + * \brief The Plugin class is a structure representing a single plugin. | |
| 35 | + * It is used internally by the Pluginmanager and holds all information | |
| 36 | + * needed. | |
| 37 | + *//* | |
| 38 | + * _______________________________________ | |
| 39 | + * / Heuristics are bug ridden by \ | |
| 40 | + * | definition. If they didn't have bugs, | | |
| 41 | + * \ then they'd be algorithms. / | |
| 42 | + * --------------------------------------- | |
| 43 | + * \ | |
| 44 | + * \ | |
| 45 | + * .--. | |
| 46 | + * |o_o | | |
| 47 | + * |:_/ | | |
| 48 | + * // \ \ | |
| 49 | + * (| | ) | |
| 50 | + * /'\_ _/`\ | |
| 51 | + * \___)=(___/ | |
| 52 | + * | |
| 53 | + */ | |
| 54 | + | |
| 55 | +class Plugin | |
| 56 | +{ | |
| 57 | +public: | |
| 58 | + //! | |
| 59 | + /** | |
| 60 | + * @brief Constructor | |
| 61 | + * @param pluginName Name of the plugin | |
| 62 | + * @param pluginPath Path to the plugin | |
| 63 | + * @param pluginConfig Configuration file for the plugin | |
| 64 | + * @param pluginUuid UUID for the plugin | |
| 65 | + * @param ptr_plugin Plugin instance | |
| 66 | + */ | |
| 67 | + Plugin(const QString& pluginName = QString(), | |
| 68 | + const QString& pluginFile = QString(), | |
| 69 | + const QString& pluginPath = QString(), | |
| 70 | + const QString& pluginConfig = QString(), | |
| 71 | + const QUuid& pluginUuid = QUuid(), | |
| 72 | + QObject* ptr_plugin = nullptr ); | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * @brief Copy-constructor | |
| 76 | + * @param other Plugin to copy from | |
| 77 | + */ | |
| 78 | + Plugin(const Plugin& other); | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * @brief Assignment operator | |
| 82 | + * @param other Plugin to copy from | |
| 83 | + * @return Reference to this | |
| 84 | + */ | |
| 85 | + Plugin& operator=(const Plugin& other); | |
| 86 | + | |
| 87 | + /*** Getters and Setters ***/ | |
| 88 | + //! @returns Name of the plugin ( like : libplugin_myplugin ). | |
| 89 | + QString name() const { return m_pluginName; } | |
| 90 | + | |
| 91 | + //! @returns Path to the plugin. | |
| 92 | + QString path() const { return m_pluginPath; } | |
| 93 | + | |
| 94 | + //! @returns the filename of the plugin. | |
| 95 | + QString fileName() const { return m_pluginFile; } | |
| 96 | + | |
| 97 | + //! @returns Full pathname to the plugin specific configurationfile. | |
| 98 | + QString config() const { return m_pluginConfigurationFile; } | |
| 99 | + | |
| 100 | + //! @returns Unique Identifier of the plugin. | |
| 101 | + QUuid uuid() const { return m_pluginUuid; } | |
| 102 | + | |
| 103 | + //! @returns Pointer to the plugin-instance as a QObject. | |
| 104 | + QObject* plugin() const { return m_plugin; } | |
| 105 | + | |
| 106 | + //! Sets the name of the plugin. Make sure to omit the extension. | |
| 107 | + //! @param pluginName Name of the plugin | |
| 108 | + void setName( const QString& pluginName ) { m_pluginName = pluginName; } | |
| 109 | + | |
| 110 | + //! Sets the filename of the plugin. Make sure we omit the extension. | |
| 111 | + //! @param pluginFile Filename of the plugin. | |
| 112 | + void setFileName( const QString &fileName ) { m_pluginFile = fileName; } | |
| 113 | + | |
| 114 | + //! Sets the path to the plugin. | |
| 115 | + //! @param pluginPath Path to the plugin | |
| 116 | + //! | |
| 117 | + //! PluginManager uses only one pluginpath, but it was added for future use. | |
| 118 | + void setPath( const QString& pluginPath ) { m_pluginPath = pluginPath; } | |
| 119 | + | |
| 120 | + //! Sets the full pathname and name of the plugin specific configuration file | |
| 121 | + //! @param pluginConfig Configuration file for the plugin | |
| 122 | + void setConfig( const QString& pluginConfig ) { m_pluginConfigurationFile = pluginConfig; } | |
| 123 | + | |
| 124 | + /*! Sets the Unique Identifier of the specific plugin. | |
| 125 | + * | |
| 126 | + * If the plugin is not yet loaded, its value is | |
| 127 | + * {00000000-0000-0000-0000-000000000000} ( or isNull is true ). If a plugin | |
| 128 | + * is loaded, its value is changed with the value read from the pluginID. | |
| 129 | + * | |
| 130 | + * @param pluginUuid UUID for the plugin | |
| 131 | + */ | |
| 132 | + void setUuid( const QUuid& pluginUuid ) { m_pluginUuid = pluginUuid; } | |
| 133 | + | |
| 134 | + //! Sets the pointer to the plugin-instance. | |
| 135 | + //! @param ptr_plugin Instance pointer | |
| 136 | + void setPlugin( QObject* ptr_plugin ) { m_plugin = ptr_plugin; } | |
| 137 | + | |
| 138 | + QString asString(); | |
| 139 | + | |
| 140 | +private: | |
| 141 | + QString m_pluginName; ///< Name of the plugin | |
| 142 | + QString m_pluginFile; ///< Filename of the plugin | |
| 143 | + QString m_pluginPath; ///< Full path to the plugin | |
| 144 | + QString m_pluginConfigurationFile; ///< Full path to the configuration file | |
| 145 | + QUuid m_pluginUuid; ///< Plugin UUID | |
| 146 | + QObject* m_plugin; ///< Plugin implementation | |
| 147 | +}; | |
| 148 | + | |
| 149 | +} // End namespace components | |
| 150 | +} // End namespace osdev | |
| 151 | + | |
| 152 | +#endif // OSDEV_COMPONENTS_PLUGIN_H | ... | ... |
src/pluginmanager.cpp
0 → 100644
| 1 | +++ a/src/pluginmanager.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "pluginmanager.h" | |
| 23 | + | |
| 24 | +#include <QCoreApplication> | |
| 25 | +#include <QFileInfo> | |
| 26 | +#include <memory> | |
| 27 | + | |
| 28 | +#include "log.h" | |
| 29 | +#include "dcxmlconfig.h" | |
| 30 | +#include "iplugin.h" | |
| 31 | + | |
| 32 | +#include <QtDebug> | |
| 33 | + | |
| 34 | +namespace osdev { | |
| 35 | +namespace components { | |
| 36 | + | |
| 37 | +using namespace osdev::caelus; | |
| 38 | + | |
| 39 | +std::unique_ptr<PluginManager> PluginManager::s_instance( nullptr ); | |
| 40 | + | |
| 41 | + | |
| 42 | +PluginManager& PluginManager::Instance() | |
| 43 | +{ | |
| 44 | + if ( nullptr == s_instance ) | |
| 45 | + { | |
| 46 | + s_instance = std::unique_ptr<PluginManager>( new PluginManager() ); | |
| 47 | + } | |
| 48 | + | |
| 49 | + return *s_instance; | |
| 50 | +} | |
| 51 | + | |
| 52 | +bool PluginManager::addLibrary( const QString& pluginName ) | |
| 53 | +{ | |
| 54 | + bool bResult = false; | |
| 55 | + | |
| 56 | + if( m_pluginHash.contains( pluginName ) ) | |
| 57 | + { | |
| 58 | + bResult = false; | |
| 59 | + } | |
| 60 | + else | |
| 61 | + { | |
| 62 | + Plugin* l_plugin = new Plugin( pluginName ); | |
| 63 | + if( nullptr != l_plugin ) | |
| 64 | + { | |
| 65 | + m_pluginHash.insert( pluginName, l_plugin ); | |
| 66 | + bResult = true; | |
| 67 | + | |
| 68 | + LogInfo( m_className, QString( "Library : %1 was added to the library list." ).arg( pluginName ) ) | |
| 69 | + } | |
| 70 | + } | |
| 71 | + return bResult; | |
| 72 | +} | |
| 73 | + | |
| 74 | +bool PluginManager::loadPlugin(const QString& pluginName) | |
| 75 | +{ | |
| 76 | + bool bStatus = false; | |
| 77 | + | |
| 78 | + LogInfo( m_className, QString( "Load plugin %1" ).arg( pluginName ) ) | |
| 79 | + | |
| 80 | + QPluginLoader loader( pluginName ); | |
| 81 | + QObject *plugin = loader.instance(); | |
| 82 | + if ( plugin ) | |
| 83 | + { | |
| 84 | + LogInfo( m_className, "plugin was loaded..." ) | |
| 85 | + IPlugin *iPlugin = qobject_cast<IPlugin*>( plugin ); | |
| 86 | + if ( iPlugin ) | |
| 87 | + { | |
| 88 | + LogInfo( m_className, QString( "%1 implements the IPlugin interface.." ).arg( pluginName ) ) | |
| 89 | + | |
| 90 | + // Call initialization function on plugin | |
| 91 | + iPlugin->initialise(); | |
| 92 | + | |
| 93 | + // Get the path of the just loaded plugin | |
| 94 | + QString pluginPath = QFileInfo(loader.fileName()).path(); | |
| 95 | + | |
| 96 | + LogInfo( m_className, QString("Plugin name : %1").arg( iPlugin->getName() ) ) | |
| 97 | + LogInfo( m_className, QString("Plugin uuid : %1").arg( iPlugin->getId().toString() ) ) | |
| 98 | + LogInfo( m_className, QString("Plugin description : %1").arg( iPlugin->getDescription() ) ) | |
| 99 | + LogInfo( m_className, QString("Plugin path : %1").arg( pluginPath ) ) | |
| 100 | + | |
| 101 | + // Set the created id to the pluginHash. | |
| 102 | + Plugin *ptrPlugin = m_pluginHash.value( pluginName, nullptr ); | |
| 103 | + if ( ptrPlugin ) | |
| 104 | + { // Retrieve the correct pointer and adjust the values. | |
| 105 | + ptrPlugin->setName( iPlugin->getName() ); | |
| 106 | + ptrPlugin->setFileName( pluginName ); | |
| 107 | + ptrPlugin->setUuid( iPlugin->getId() ); | |
| 108 | + ptrPlugin->setPath( pluginPath ); | |
| 109 | + ptrPlugin->setPlugin( plugin ); | |
| 110 | + } | |
| 111 | + else | |
| 112 | + { // The plugin just loaded doesn't exist. Create it and add it to the hash. | |
| 113 | + ptrPlugin = new Plugin( iPlugin->getName(), pluginName, pluginPath, QString(), iPlugin->getId(), plugin ); | |
| 114 | + m_pluginHash.insert(iPlugin->getName(), ptrPlugin); | |
| 115 | + } | |
| 116 | + // Load successfull | |
| 117 | + bStatus = true; | |
| 118 | + | |
| 119 | + } | |
| 120 | + else | |
| 121 | + { | |
| 122 | + LogError( m_className, QString( "Ignoring plugin %1 because it does not support the IPlugin interface." ).arg( pluginName ) ) | |
| 123 | + } | |
| 124 | + } | |
| 125 | + else | |
| 126 | + { | |
| 127 | + LogError( m_className, QString( "Loading of plugin %1 failed....." ).arg( pluginName ) ) | |
| 128 | + LogError( m_className, QString( "PluginLoader reported : %1" ).arg( loader.errorString() ) ) | |
| 129 | + LogError( m_className, QString( "LibraryPaths : %1 " ).arg( QCoreApplication::libraryPaths().join( "\n" ) ) ) | |
| 130 | + } | |
| 131 | + return bStatus; | |
| 132 | +} | |
| 133 | + | |
| 134 | +bool PluginManager::loadPlugins(const QStringList& pluginNames) | |
| 135 | +{ | |
| 136 | + bool bStatus = false; | |
| 137 | + | |
| 138 | + LogDebug( m_className, QString("Adding %1 to the Hash.").arg( pluginNames.join(" ") ) ) | |
| 139 | + buildLibraryList(); | |
| 140 | + | |
| 141 | + LogDebug( m_className, QString("Looking for plugins in : %1").arg( QCoreApplication::libraryPaths().join(":") ) ) | |
| 142 | + for( const QString& pluginName : pluginNames ) | |
| 143 | + { | |
| 144 | + bStatus &= loadPlugin( pluginName ); | |
| 145 | + } | |
| 146 | + | |
| 147 | + return bStatus; | |
| 148 | +} | |
| 149 | + | |
| 150 | +bool PluginManager::loadPlugins() | |
| 151 | +{ | |
| 152 | + bool bStatus = false; | |
| 153 | + | |
| 154 | + auto l_pluginNames = m_pluginHash.keys(); | |
| 155 | + for( const QString& l_pluginName : l_pluginNames ) | |
| 156 | + { | |
| 157 | + bStatus &= loadPlugin( l_pluginName ); | |
| 158 | + } | |
| 159 | + | |
| 160 | + return bStatus; | |
| 161 | +} | |
| 162 | + | |
| 163 | +bool PluginManager::unloadPlugin( const QString& pluginName ) | |
| 164 | +{ | |
| 165 | + bool bStatus = false; | |
| 166 | + | |
| 167 | + QPluginLoader loader( pluginName ); | |
| 168 | + if ( loader.unload() ) | |
| 169 | + { | |
| 170 | + LogInfo(m_className, QString("Plugin %1 successfully unloaded.").arg(pluginName)) | |
| 171 | + LogInfo(m_className, QString("Removing Plugin %1 form the hashtable.").arg(pluginName)) | |
| 172 | + Plugin *ptr_plugin = m_pluginHash.take( pluginName ); | |
| 173 | + delete ptr_plugin; | |
| 174 | + bStatus = true; | |
| 175 | + } | |
| 176 | + else | |
| 177 | + { | |
| 178 | + LogError( m_className, QString("Unloading of plugin %1 failed.").arg(pluginName) ) | |
| 179 | + LogError( m_className, QString("Last PluginError : %1").arg(loader.errorString() ) ) | |
| 180 | + } | |
| 181 | + return bStatus; | |
| 182 | +} | |
| 183 | + | |
| 184 | +void PluginManager::addLibraryPaths(const QStringList& paths) | |
| 185 | +{ | |
| 186 | + for( const QString& libPath : paths ) | |
| 187 | + { | |
| 188 | + QCoreApplication::addLibraryPath( libPath ); | |
| 189 | + } | |
| 190 | +} | |
| 191 | + | |
| 192 | +void PluginManager::addLibraryPath(const QString& path) | |
| 193 | +{ | |
| 194 | + QCoreApplication::addLibraryPath( path ); | |
| 195 | +} | |
| 196 | + | |
| 197 | +QObject* PluginManager::getPlugin(const QUuid &id) const | |
| 198 | +{ | |
| 199 | + QObject *l_plugin = nullptr; | |
| 200 | + | |
| 201 | + for(auto it = m_pluginHash.begin(); it != m_pluginHash.end(); ++it) | |
| 202 | + { | |
| 203 | + if ( id == it.value()->uuid() ) | |
| 204 | + { | |
| 205 | + l_plugin = it.value()->plugin(); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + return l_plugin; | |
| 210 | +} | |
| 211 | + | |
| 212 | +QList<QObject*> PluginManager::getPlugins(const QString& i_interface) const | |
| 213 | +{ | |
| 214 | + QList<QObject*> l_pObjectList; | |
| 215 | + | |
| 216 | + for(auto it = m_pluginHash.begin(); it != m_pluginHash.end(); ++it ) | |
| 217 | + { | |
| 218 | + QObject *l_plugin = it.value()->plugin(); | |
| 219 | + if( l_plugin && l_plugin->qt_metacast( i_interface.toUtf8().data() ) ) | |
| 220 | + { | |
| 221 | + // We've found a plugin with this interface | |
| 222 | + l_pObjectList.push_back( l_plugin ); | |
| 223 | + } | |
| 224 | + } | |
| 225 | + | |
| 226 | + return l_pObjectList; | |
| 227 | +} | |
| 228 | + | |
| 229 | +PluginManager::PluginManager() | |
| 230 | + : m_pluginHash() | |
| 231 | + , m_libraryList() | |
| 232 | + , m_className("PluginManager :: ") | |
| 233 | +{ | |
| 234 | + QCoreApplication::addLibraryPath( "." ); | |
| 235 | +} | |
| 236 | + | |
| 237 | +void PluginManager::buildLibraryList() | |
| 238 | +{ | |
| 239 | + // Get the config object and get the plugins and librarypaths... | |
| 240 | + DCXmlConfig& l_config = DCXmlConfig::Instance(); | |
| 241 | + | |
| 242 | + // Get all the plugins and create their representing objects.. | |
| 243 | + QStringList l_plugins = l_config.getPlugins(); | |
| 244 | + for(const QString& pluginName : l_plugins) | |
| 245 | + { | |
| 246 | + Plugin* plugin = new Plugin( pluginName ); | |
| 247 | + if (nullptr != plugin) | |
| 248 | + { | |
| 249 | + m_pluginHash.insert(pluginName, plugin); | |
| 250 | + qDebug() << m_pluginHash; | |
| 251 | + } | |
| 252 | + } | |
| 253 | +} | |
| 254 | + | |
| 255 | +QString PluginManager::getLibrary( const QString& pluginName ) const | |
| 256 | +{ | |
| 257 | + /// @TODO this should find the actual file name corresponding to the plugin. QFileInfo should be constructed with the actual filename. | |
| 258 | + /// We are looking for that name so this is not working as intended. | |
| 259 | + LogDebug( m_className, QString( "Plugin Name looking for : %1" ).arg( pluginName ) ) | |
| 260 | + for( const QString& library : m_pluginHash.keys() ) | |
| 261 | + { | |
| 262 | + LogDebug( m_className, QString( "Library = %1" ).arg( library ) ) | |
| 263 | + QFileInfo info( library ); | |
| 264 | + LogDebug( m_className, QString( "Library base of : %1" ).arg( info.baseName() ) ) | |
| 265 | + if ( pluginName == info.baseName() ) | |
| 266 | + { // First found can be returned | |
| 267 | + return library; | |
| 268 | + } | |
| 269 | + } | |
| 270 | + // Nothing found | |
| 271 | + return QString(); | |
| 272 | +} | |
| 273 | + | |
| 274 | +bool PluginManager::isLoaded( const QString& pluginName ) const | |
| 275 | +{ | |
| 276 | + return m_pluginHash.contains( pluginName ); | |
| 277 | +} | |
| 278 | + | |
| 279 | +QUuid PluginManager::getPluginId( const QString& pluginName ) const | |
| 280 | +{ | |
| 281 | + if( isLoaded( pluginName ) ) | |
| 282 | + { | |
| 283 | + return m_pluginHash.value( pluginName )->uuid(); | |
| 284 | + } | |
| 285 | + return QUuid(); | |
| 286 | +} | |
| 287 | + | |
| 288 | +QUuid PluginManager::getPluginIdByInterfaceId( const QString &interface_id ) | |
| 289 | +{ | |
| 290 | + for(auto it = m_pluginHash.begin(); it != m_pluginHash.end(); ++it ) | |
| 291 | + { | |
| 292 | + QObject *l_plugin = it.value()->plugin(); | |
| 293 | + if( l_plugin && l_plugin->qt_metacast( interface_id.toUtf8().data() ) ) | |
| 294 | + { | |
| 295 | + // We've found a plugin with this interface | |
| 296 | + IPlugin *iPlugin = qobject_cast<IPlugin*>( it.value()->plugin() ); | |
| 297 | + if( iPlugin ) | |
| 298 | + { | |
| 299 | + return iPlugin->getId(); | |
| 300 | + } | |
| 301 | + else | |
| 302 | + LogInfo( "[PluginManager::getPluginIdByInterfaceId]", QString( "No plugin found with interface : " + interface_id ) ); | |
| 303 | + } | |
| 304 | + } | |
| 305 | + return QUuid(); | |
| 306 | +} | |
| 307 | + | |
| 308 | +QString PluginManager::getPluginNameByUuid( const QUuid &uuid ) | |
| 309 | +{ | |
| 310 | + for( const auto& key : m_pluginHash.keys() ) | |
| 311 | + { | |
| 312 | + Plugin *ptr_plugin = m_pluginHash.value( key, nullptr ); | |
| 313 | + if( nullptr != ptr_plugin ) | |
| 314 | + { | |
| 315 | + if( ptr_plugin->uuid() == uuid ) | |
| 316 | + { | |
| 317 | + return ptr_plugin->name(); | |
| 318 | + } | |
| 319 | + } | |
| 320 | + } | |
| 321 | + return QString(); | |
| 322 | +} | |
| 323 | + | |
| 324 | +QUuid PluginManager::getPluginUuidByName( const QString &name ) | |
| 325 | +{ | |
| 326 | + for( const auto& key : m_pluginHash.keys() ) | |
| 327 | + { | |
| 328 | + Plugin *ptr_plugin = m_pluginHash.value( key, nullptr ); | |
| 329 | + if( nullptr != ptr_plugin ) | |
| 330 | + { | |
| 331 | + if( ptr_plugin->name() == name ) | |
| 332 | + { | |
| 333 | + return ptr_plugin->uuid(); | |
| 334 | + } | |
| 335 | + } | |
| 336 | + } | |
| 337 | + return QUuid(); | |
| 338 | +} | |
| 339 | + | |
| 340 | +void PluginManager::slotConfigChanged( const QString& fileName ) | |
| 341 | +{ | |
| 342 | + LogInfo(m_className, | |
| 343 | + QString( "Configurationfile %1 was changed. Reread the configuration and plugins." ).arg( fileName ) ) | |
| 344 | +} | |
| 345 | + | |
| 346 | +} // End namespace components | |
| 347 | +} // End namespace osdev | ... | ... |
src/pluginmanager.h
0 → 100644
| 1 | +++ a/src/pluginmanager.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_PLUGINMANAGER_H | |
| 23 | +#define OSDEV_COMPONENTS_PLUGINMANAGER_H | |
| 24 | + | |
| 25 | +#include <QObject> | |
| 26 | +#include <QUuid> | |
| 27 | +#include <QHash> | |
| 28 | +#include <QList> | |
| 29 | +#include <QStringList> | |
| 30 | + | |
| 31 | +#include "plugin.h" | |
| 32 | + | |
| 33 | +#include "globallibexport.h" | |
| 34 | + | |
| 35 | +#include <memory> | |
| 36 | + | |
| 37 | +namespace osdev { | |
| 38 | +namespace components { | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * \brief This component is responsible for loading plugins. | |
| 42 | + * | |
| 43 | + * It also has support for supplying interfaces on the loaded pluins. The plugin | |
| 44 | + * manager is a singleton component. | |
| 45 | + *//* | |
| 46 | + * ________________________________________ | |
| 47 | + * / One of the signs of Napoleon's \ | |
| 48 | + * | greatness is the fact that he once had | | |
| 49 | + * | a publisher shot. | | |
| 50 | + * | | | |
| 51 | + * \ -- Siegfried Unseld / | |
| 52 | + * ---------------------------------------- | |
| 53 | + * \ | |
| 54 | + * \ | |
| 55 | + * .--. | |
| 56 | + * |o_o | | |
| 57 | + * |:_/ | | |
| 58 | + * // \ \ | |
| 59 | + * (| | ) | |
| 60 | + * /'\_ _/`\ | |
| 61 | + * \___)=(___/ | |
| 62 | + * | |
| 63 | + */ | |
| 64 | +class GLOBALLIBINTERFACE PluginManager : public QObject | |
| 65 | +{ | |
| 66 | + Q_OBJECT | |
| 67 | + | |
| 68 | +public: | |
| 69 | + //! Constructs the plugin manager | |
| 70 | + static PluginManager& Instance(); | |
| 71 | + | |
| 72 | + /// Deleted copy-constructor | |
| 73 | + PluginManager( const PluginManager& ) = delete; | |
| 74 | + /// Deleted assignment operator | |
| 75 | + PluginManager& operator=(const PluginManager&) = delete; | |
| 76 | + /// Deleted move-constructor | |
| 77 | + PluginManager( PluginManager&& ) = delete; | |
| 78 | + /// Deleted move operator | |
| 79 | + PluginManager& operator=( PluginManager&& ) = delete; | |
| 80 | + | |
| 81 | + //! Adds a plugin not listed in the configuration. | |
| 82 | + bool addLibrary( const QString& pluginName ); | |
| 83 | + | |
| 84 | + //! Load the plugin by its name and location | |
| 85 | + bool loadPlugin(const QString& pluginName); | |
| 86 | + | |
| 87 | + //! Loads a list of plugins. Names are resolved against the paths added with addLibraryPaths(). | |
| 88 | + bool loadPlugins(const QStringList& pluginNames); | |
| 89 | + | |
| 90 | + //! Load all plugins set in the staging table. | |
| 91 | + bool loadPlugins(); | |
| 92 | + | |
| 93 | + //! Unloads a plugin and removes it from the manager | |
| 94 | + bool unloadPlugin( const QString& pluginName ); | |
| 95 | + | |
| 96 | + //! Specify where the plugin manager will look for plugins | |
| 97 | + void addLibraryPaths(const QStringList& paths); | |
| 98 | + | |
| 99 | + //! Specify a single plugin path | |
| 100 | + void addLibraryPath(const QString& path); | |
| 101 | + | |
| 102 | + //! Retrieve a loaded plugin with its object ID. | |
| 103 | + QObject* getPlugin(const QUuid &id) const; | |
| 104 | + | |
| 105 | + //! Retrieve all objects that have the specified interface. | |
| 106 | + QList<QObject*> getPlugins(const QString& i_interface) const; | |
| 107 | + | |
| 108 | + //! Check if a specific plugin was already loaded... | |
| 109 | + bool isLoaded( const QString& pluginName ) const; | |
| 110 | + | |
| 111 | + //! Retrieve the uuid of the given plugin by its filename. | |
| 112 | + QUuid getPluginId( const QString& pluginName ) const; | |
| 113 | + | |
| 114 | + //! Retrieve the uuid of the given plugin by its Interface_id | |
| 115 | + QUuid getPluginIdByInterfaceId( const QString &interface_id ); | |
| 116 | + | |
| 117 | + //! Retrieve the name of the given plugin by its uuid | |
| 118 | + QString getPluginNameByUuid( const QUuid &uuid ); | |
| 119 | + | |
| 120 | + //! Retrieve the plugin_id by its systemname. | |
| 121 | + QUuid getPluginUuidByName( const QString &name ); | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * @brief Locate the interface with the specified name | |
| 125 | + * @tparam T Type of interface needed | |
| 126 | + * @param i_interface Name of the interface | |
| 127 | + * @return Interface implementation, or nullptr if no valid interface could | |
| 128 | + * be found | |
| 129 | + */ | |
| 130 | + template<class T> | |
| 131 | + T* queryInterface(const QString& i_interface); | |
| 132 | + | |
| 133 | +public slots: | |
| 134 | + /** | |
| 135 | + * @brief Slot called when a configuration file changed | |
| 136 | + * @param fileName Name of the changed file | |
| 137 | + * @todo Implement me! | |
| 138 | + */ | |
| 139 | + void slotConfigChanged( const QString& fileName ); | |
| 140 | + | |
| 141 | +private: | |
| 142 | + | |
| 143 | + //! Constructs the plugin manager (CTor) | |
| 144 | + PluginManager(); | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * @brief Get all the plugins and create their representing objects | |
| 148 | + */ | |
| 149 | + void buildLibraryList(); | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * @brief Find the library associated with a plugin-name | |
| 153 | + * @param pluginName Plugin name to look for | |
| 154 | + * @return Library-name, or an empty string if no library was found | |
| 155 | + */ | |
| 156 | + QString getLibrary(const QString& pluginName) const; | |
| 157 | + | |
| 158 | + // ------------------------------------------------------ | |
| 159 | + | |
| 160 | + //! Contains the only instance of a Pluginmanager | |
| 161 | + static std::unique_ptr<PluginManager> s_instance; | |
| 162 | + | |
| 163 | + //! Hash table of all plugins. Loaded or not... | |
| 164 | + QHash<QString, Plugin*> m_pluginHash; | |
| 165 | + | |
| 166 | + //! List of all possible libraries that may be loaded by the PM.... | |
| 167 | + QStringList m_libraryList; | |
| 168 | + | |
| 169 | + //! Member holding the classname. | |
| 170 | + QString m_className; | |
| 171 | +}; | |
| 172 | + | |
| 173 | +// ------------------------------------------------------ | |
| 174 | + | |
| 175 | +template <class T> | |
| 176 | +T* PluginManager::queryInterface(const QString& i_interface) | |
| 177 | +{ | |
| 178 | + // Hash used to store queried interfaces | |
| 179 | + static QHash<QString, T*> ifaceCache; | |
| 180 | + | |
| 181 | + T* pInterface = nullptr; | |
| 182 | + | |
| 183 | + if ( ifaceCache.contains(i_interface) ) | |
| 184 | + { | |
| 185 | + pInterface = ifaceCache[i_interface]; | |
| 186 | + } | |
| 187 | + else | |
| 188 | + { | |
| 189 | + QList<QObject*> pPluginList = PluginManager::Instance().getPlugins( i_interface ); | |
| 190 | + if ( !pPluginList.isEmpty() ) | |
| 191 | + { | |
| 192 | + // Return the first plugin with the wanted interface. | |
| 193 | + pInterface = qobject_cast<T*>(pPluginList[0]); | |
| 194 | + /// @todo What if we specify the wrong T for this plugin? | |
| 195 | + Q_ASSERT(pInterface); | |
| 196 | + ifaceCache.insert(i_interface, pInterface); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + return pInterface; | |
| 200 | +} | |
| 201 | + | |
| 202 | +} // End namespace components | |
| 203 | +} // End namespace osdev | |
| 204 | + | |
| 205 | +#endif // OSDEV_COMPONENTS_PLUGINMANAGER_H | ... | ... |
src/systeminfo.cpp
0 → 100644
| 1 | +++ a/src/systeminfo.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "systeminfo.h" | |
| 23 | +#include "log.h" | |
| 24 | + | |
| 25 | +#include <QDir> | |
| 26 | + | |
| 27 | +using namespace osdev::components; | |
| 28 | + | |
| 29 | +// The only instance of the singleton system info. | |
| 30 | +std::unique_ptr<SystemInfo> SystemInfo::s_pInstance(nullptr); | |
| 31 | + | |
| 32 | +// The configuration directory. | |
| 33 | +static const QString qsConfigDir = "config/"; | |
| 34 | +static const QString qsResourceDir = "resource/"; | |
| 35 | + | |
| 36 | +static const QString qsDynaBuilderSystemPluginConfig; | |
| 37 | +static const QString qsDynaBuilderUiPluginConfig; | |
| 38 | +static const QString qsDynaBuilderBackendPluginConfig; | |
| 39 | + | |
| 40 | + | |
| 41 | +SystemInfo::SystemInfo() | |
| 42 | + : m_qsApplicationPath() | |
| 43 | + , m_qsExecutablePath(QDir::currentPath()) | |
| 44 | +{ | |
| 45 | +} | |
| 46 | + | |
| 47 | +SystemInfo::~SystemInfo() | |
| 48 | +{ | |
| 49 | +} | |
| 50 | + | |
| 51 | +SystemInfo& SystemInfo::Instance() | |
| 52 | +{ | |
| 53 | + // Is it the first call? | |
| 54 | + if (nullptr == s_pInstance) | |
| 55 | + { | |
| 56 | + // Create sole instance | |
| 57 | + s_pInstance.reset(new SystemInfo()); | |
| 58 | + } | |
| 59 | + | |
| 60 | + // Return the address of sole instance | |
| 61 | + return *s_pInstance.get(); | |
| 62 | +} | |
| 63 | + | |
| 64 | +void SystemInfo::destroyInstance() | |
| 65 | +{ | |
| 66 | + s_pInstance.reset(); | |
| 67 | +} | |
| 68 | + | |
| 69 | +void SystemInfo::setApplicationPath(const QString& qsName) | |
| 70 | +{ | |
| 71 | + QDir dir( qsName ); | |
| 72 | + | |
| 73 | + m_qsApplicationPath = dir.absolutePath(); | |
| 74 | + | |
| 75 | + LogInfo("SystemInfo::setApplicationPath", | |
| 76 | + "ApplicationPath before :: " + m_qsApplicationPath); | |
| 77 | + | |
| 78 | + // Remove appl name. | |
| 79 | + int lSlashPosition = m_qsApplicationPath.lastIndexOf ( '/' ); | |
| 80 | + | |
| 81 | + // And platform path. | |
| 82 | + // lSlashPosition = m_qsApplicationPath.lastIndexOf ( '/', lSlashPosition - 1); | |
| 83 | + m_qsApplicationPath = m_qsApplicationPath.left( lSlashPosition + 1 ); | |
| 84 | + | |
| 85 | + QString strBin = "bin"; | |
| 86 | + | |
| 87 | + m_qsApplicationPath = m_qsApplicationPath.left( m_qsApplicationPath.lastIndexOf( strBin ) ); | |
| 88 | + | |
| 89 | + LogInfo("SystemInfo::setApplicationPath", | |
| 90 | + "ApplicationPath after :: " + m_qsApplicationPath); | |
| 91 | + | |
| 92 | + /// @todo The application can be started via the PATH variable. This path | |
| 93 | + /// should be prepended to the path. | |
| 94 | +} | |
| 95 | + | |
| 96 | +QString SystemInfo::getApplicationPath() const | |
| 97 | +{ | |
| 98 | + return m_qsApplicationPath; | |
| 99 | +} | |
| 100 | + | |
| 101 | +QString SystemInfo::getExecutablePath() const | |
| 102 | +{ | |
| 103 | + return m_qsExecutablePath; | |
| 104 | +} | |
| 105 | + | |
| 106 | +QString SystemInfo::getResourcePath() const | |
| 107 | +{ | |
| 108 | + return getApplicationPath() + qsResourceDir; | |
| 109 | +} | |
| 110 | + | |
| 111 | +QString SystemInfo::getConfigurationPath() const | |
| 112 | +{ | |
| 113 | + return getApplicationPath() + qsConfigDir; | |
| 114 | +} | |
| 115 | + | |
| 116 | +QString SystemInfo::getConfigFile(ConfigFile fileType) const | |
| 117 | +{ | |
| 118 | + switch(fileType) | |
| 119 | + { | |
| 120 | + case ConfigFile::System: | |
| 121 | + return getApplicationPath() + qsConfigDir + qsDynaBuilderSystemPluginConfig; | |
| 122 | + case ConfigFile::UI: | |
| 123 | + return getApplicationPath() + qsConfigDir + qsDynaBuilderUiPluginConfig; | |
| 124 | + case ConfigFile::Backend: | |
| 125 | + return getApplicationPath() + qsConfigDir + qsDynaBuilderBackendPluginConfig; | |
| 126 | + } | |
| 127 | + Q_ASSERT(0 && "Unknown configuration file type"); | |
| 128 | + return QString(); | |
| 129 | +} | ... | ... |
src/systeminfo.h
0 → 100644
| 1 | +++ a/src/systeminfo.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_SYSTEMINFO_H | |
| 23 | +#define OSDEV_COMPONENTS_SYSTEMINFO_H | |
| 24 | + | |
| 25 | +#include "globallibexport.h" | |
| 26 | + | |
| 27 | +#include <memory> | |
| 28 | +#include <QString> | |
| 29 | + | |
| 30 | +namespace osdev { | |
| 31 | +namespace components { | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * @brief Collects information about the current system | |
| 35 | + * | |
| 36 | + * Singleton class. | |
| 37 | + */ | |
| 38 | +class GLOBALLIBINTERFACE SystemInfo | |
| 39 | +{ | |
| 40 | +public: | |
| 41 | + /// Supported classes of configuration file | |
| 42 | + enum class ConfigFile { | |
| 43 | + System, ///< System configuration | |
| 44 | + UI, ///< UI configuration | |
| 45 | + Backend ///< Backend configuration | |
| 46 | + }; | |
| 47 | + | |
| 48 | + //! Constructs the systeminfo (Ctor). | |
| 49 | + //! @return Reference to the SystemInfo instance | |
| 50 | + static SystemInfo& Instance(); | |
| 51 | + | |
| 52 | + /// Deleted copy-constructor | |
| 53 | + SystemInfo(const SystemInfo&) = delete; | |
| 54 | + /// Deleted assignment operator | |
| 55 | + SystemInfo& operator= (const SystemInfo&) = delete; | |
| 56 | + /// Deleted move-constructor | |
| 57 | + SystemInfo(SystemInfo&&) = delete; | |
| 58 | + /// Deleted move operator | |
| 59 | + SystemInfo& operator=(SystemInfo&&) = delete; | |
| 60 | + | |
| 61 | + //! Destructs the config parser (Dtor) | |
| 62 | + ~SystemInfo(); | |
| 63 | + | |
| 64 | + //! Destroy single instance | |
| 65 | + static void destroyInstance(); | |
| 66 | + | |
| 67 | + //! Set the application path. | |
| 68 | + void setApplicationPath(const QString& qsName); | |
| 69 | + | |
| 70 | + //! Returns the application path. | |
| 71 | + QString getApplicationPath() const; | |
| 72 | + | |
| 73 | + //! Returns the location (path to) the executable | |
| 74 | + QString getExecutablePath() const; | |
| 75 | + | |
| 76 | + //! Return xml configuration path. | |
| 77 | + QString getConfigurationPath() const; | |
| 78 | + | |
| 79 | + //! Return resource path. | |
| 80 | + QString getResourcePath() const; | |
| 81 | + | |
| 82 | + //! Returns the path of a config file. | |
| 83 | + QString getConfigFile( ConfigFile fileType ) const; | |
| 84 | + | |
| 85 | +private: | |
| 86 | + //! Constructs the config parser (Ctor) | |
| 87 | + SystemInfo(); | |
| 88 | + | |
| 89 | +private: | |
| 90 | + | |
| 91 | + //! Contains the only instance of a CSystemInfo. | |
| 92 | + static std::unique_ptr<SystemInfo> s_pInstance; | |
| 93 | + | |
| 94 | + //! The name of the configfile. | |
| 95 | + QString m_qsApplicationPath; | |
| 96 | + | |
| 97 | + //! The path with the location of the executable | |
| 98 | + QString m_qsExecutablePath; | |
| 99 | +}; | |
| 100 | + | |
| 101 | +} // End namespace components | |
| 102 | +} // End namespace osdev | |
| 103 | + | |
| 104 | +#endif /* OSDEV_COMPONENTS_SYSTEMINFO_H */ | ... | ... |
src/threadmon.cpp
0 → 100644
| 1 | +++ a/src/threadmon.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "threadmon.h" | |
| 23 | +#include <QtCore/private/qthread_p.h> | |
| 24 | + | |
| 25 | +using namespace osdev::components; | |
| 26 | + | |
| 27 | +int ThreadMon::postedEventsCountForThread(QThread* pThread) | |
| 28 | +{ | |
| 29 | + /* Check if we have a valid pointer */ | |
| 30 | + if (nullptr == pThread) | |
| 31 | + return -1; | |
| 32 | + | |
| 33 | + auto threadData = QThreadData::get2(pThread); | |
| 34 | + if (nullptr == threadData) | |
| 35 | + return -1; | |
| 36 | + | |
| 37 | + QMutexLocker lock(&threadData->postEventList.mutex); | |
| 38 | + | |
| 39 | + return (threadData->postEventList.size() - threadData->postEventList.startOffset); | |
| 40 | +} | ... | ... |
src/threadmon.h
0 → 100644
| 1 | +++ a/src/threadmon.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_THREADMON_H | |
| 23 | +#define OSDEV_COMPONENTS_THREADMON_H | |
| 24 | + | |
| 25 | +#include <QtCore> | |
| 26 | + | |
| 27 | +namespace osdev { | |
| 28 | +namespace components { | |
| 29 | + | |
| 30 | +class ThreadMon | |
| 31 | +{ | |
| 32 | +public: | |
| 33 | + /*! | |
| 34 | + * \brief postedEventsCountForThread will report the number of meesages waiting in the eventloop of the given QThread | |
| 35 | + * \param pThread - raw-pointer to the thread we want to investigate. | |
| 36 | + * \return -1 if nothing to report. >= 0 if the thread is valid and the eventQueue was queried. | |
| 37 | + */ | |
| 38 | + static int postedEventsCountForThread(QThread* pThread); | |
| 39 | +}; | |
| 40 | + | |
| 41 | +} /* End namespace components */ | |
| 42 | +} /* End namespace osdev */ | |
| 43 | + | |
| 44 | +#endif /* OSDEV_COMPONENTS_THREADMON_H */ | ... | ... |
src/timeutils.cpp
0 → 100644
| 1 | +++ a/src/timeutils.cpp | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#include "timeutils.h" | |
| 23 | + | |
| 24 | +// std | |
| 25 | +#include <chrono> | |
| 26 | + | |
| 27 | +using namespace osdev::components; | |
| 28 | + | |
| 29 | +std::uint64_t TimeUtils::getEpochUSecs() | |
| 30 | +{ | |
| 31 | + auto tsUSec = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now() ); | |
| 32 | + return static_cast<std::uint64_t>(tsUSec.time_since_epoch().count()); | |
| 33 | +} | ... | ... |
src/timeutils.h
0 → 100644
| 1 | +++ a/src/timeutils.h | |
| 1 | +/* **************************************************************************** | |
| 2 | + * Copyright 2019 Open Systems Development BV * | |
| 3 | + * * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a * | |
| 5 | + * copy of this software and associated documentation files (the "Software"), * | |
| 6 | + * to deal in the Software without restriction, including without limitation * | |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, * | |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the * | |
| 9 | + * Software is furnished to do so, subject to the following conditions: * | |
| 10 | + * * | |
| 11 | + * The above copyright notice and this permission notice shall be included in * | |
| 12 | + * all copies or substantial portions of the Software. * | |
| 13 | + * * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * | |
| 17 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * | |
| 19 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * | |
| 20 | + * DEALINGS IN THE SOFTWARE. * | |
| 21 | + * ***************************************************************************/ | |
| 22 | +#ifndef OSDEV_COMPONENTS_TIMEUTILS_H | |
| 23 | +#define OSDEV_COMPONENTS_TIMEUTILS_H | |
| 24 | + | |
| 25 | +#include <QtGlobal> | |
| 26 | +#include <cstdint> | |
| 27 | + | |
| 28 | +namespace osdev { | |
| 29 | +namespace components { | |
| 30 | + | |
| 31 | +class TimeUtils | |
| 32 | +{ | |
| 33 | +public: | |
| 34 | + static std::uint64_t getEpochUSecs(); | |
| 35 | +}; | |
| 36 | + | |
| 37 | +} /* End namespace components */ | |
| 38 | +} /* End namespace osdev */ | |
| 39 | + | |
| 40 | +#endif /* OSDEV_COMPONENTS_TIMEUTILS_H */ | ... | ... |
tests/CMakeLists.txt
0 → 100644
| 1 | +++ a/tests/CMakeLists.txt | |
| 1 | +cmake_minimum_required(VERSION 3.0) | |
| 2 | +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) | |
| 3 | + | |
| 4 | +include(projectheader) | |
| 5 | +project_header(test_logutils) | |
| 6 | + | |
| 7 | +include_directories( SYSTEM | |
| 8 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../src | |
| 9 | +) | |
| 10 | + | |
| 11 | +include(compiler) | |
| 12 | +set(SRC_LIST | |
| 13 | +) | |
| 14 | + | |
| 15 | +# add_executable( ${PROJECT_NAME} | |
| 16 | +# ${SRC_LIST} | |
| 17 | +# ) | |
| 18 | + | |
| 19 | +# target_link_libraries( | |
| 20 | +# ${PROJECT_NAME} | |
| 21 | +# ) | |
| 22 | + | |
| 23 | +# set_target_properties( ${PROJECT_NAME} PROPERTIES | |
| 24 | +# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin | |
| 25 | +# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib | |
| 26 | +# ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive | |
| 27 | +# ) | |
| 28 | + | |
| 29 | +# include(installation) | |
| 30 | +# install_application() | ... | ... |