Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
skylivex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
astronomy
skylivex
Commits
4187ca74
Commit
4187ca74
authored
Feb 16, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plugin loader ready
parent
934c7aa8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
4 deletions
+62
-4
skylivex.pro
skylivex.pro
+2
-1
pluginsinterfaces.h
src/pluginsinterfaces.h
+3
-0
skylivex.cpp
src/skylivex.cpp
+49
-2
skylivex.h
src/skylivex.h
+8
-1
No files found.
skylivex.pro
View file @
4187ca74
...
@@ -3,7 +3,8 @@ SOURCES = src/main.cpp \
...
@@ -3,7 +3,8 @@ SOURCES = src/main.cpp \
src
/
skylivex
.
cpp
#
src
/
plugins
.
cpp
src
/
skylivex
.
cpp
#
src
/
plugins
.
cpp
HEADERS
=
src
/
skylivex
.
h
\
HEADERS
=
src
/
skylivex
.
h
\
src
/
mainwin
.
h
#
src
/
plugins
.
h
src
/
pluginsinterfaces
.
h
src
/
mainwin
.
h
\
#
src
/
plugins
.
h
src
/
pluginsinterfaces
.
h
src
/
pluginsinterfaces
.
h
QT
+=
network
webkitwidgets
widgets
QT
+=
network
webkitwidgets
widgets
...
...
src/pluginsinterfaces.h
View file @
4187ca74
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
* Purpose:
* Purpose:
*
*
*/
*/
#ifndef PLUGINSINTERFACES_H
#define PLUGINSINTERFACES_H
#include <QtPlugin>
#include <QtPlugin>
QT_BEGIN_NAMESPACE
QT_BEGIN_NAMESPACE
...
@@ -51,3 +53,4 @@ QT_BEGIN_NAMESPACE
...
@@ -51,3 +53,4 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE
(
SkylivexPluginInterface
,
Q_DECLARE_INTERFACE
(
SkylivexPluginInterface
,
"com.skylivex.SkylivexPlugin/1.0"
)
"com.skylivex.SkylivexPlugin/1.0"
)
QT_END_NAMESPACE
QT_END_NAMESPACE
#endif
src/skylivex.cpp
View file @
4187ca74
...
@@ -33,16 +33,63 @@
...
@@ -33,16 +33,63 @@
*
*
*/
*/
#include <QPluginLoader>
#include <QApplication>
#include <QDir>
#include <QObject>
#include <QString>
#include "skylivex.h"
#include "skylivex.h"
#include "pluginsinterfaces.h"
#include <iostream>
#include <iostream>
// Load and initialize plugins and shared memory communication
void
SkyliveX
::
initialize
()
void
SkyliveX
::
initialize
()
{
{
std
::
cout
<<
"antani"
<<
std
::
endl
;
std
::
cout
<<
"antani"
<<
std
::
endl
;
loadPlugins
();
}
}
// read messages from plugins and dispatch to others
void
SkyliveX
::
process
()
void
SkyliveX
::
process
()
{
{
std
::
cout
<<
"process"
<<
std
::
endl
;
//std::cout << "process" << std::endl;
}
void
SkyliveX
::
loadPlugins
()
{
QDir
pluginsDir
=
QDir
(
qApp
->
applicationDirPath
());
pluginsDir
.
cd
(
"plugins"
);
std
::
cout
<<
"Try to load plugins in folder "
<<
pluginsDir
.
path
().
toStdString
()
<<
std
::
endl
;
foreach
(
QString
fileName
,
pluginsDir
.
entryList
(
QDir
::
Files
))
{
std
::
cout
<<
"Testing "
<<
pluginsDir
.
absoluteFilePath
(
fileName
).
toStdString
()
<<
std
::
endl
;
QPluginLoader
loader
(
pluginsDir
.
absoluteFilePath
(
fileName
));
QObject
*
plugin
=
loader
.
instance
();
if
(
plugin
)
{
std
::
cout
<<
"Loading "
<<
fileName
.
toStdString
()
<<
std
::
endl
;
initializePlugin
(
plugin
,
fileName
);
//pluginFileNames += fileName;SkylivexPluginInterface
}
else
{
std
::
cout
<<
loader
.
errorString
().
toStdString
()
<<
std
::
endl
;
std
::
cout
<<
plugin
<<
std
::
endl
;
}
}
}
void
SkyliveX
::
initializePlugin
(
QObject
*
plugin
,
QString
filename
)
{
skylivexPluginInterface
=
qobject_cast
<
SkylivexPluginInterface
*>
(
plugin
);
if
(
skylivexPluginInterface
)
{
std
::
cout
<<
"Plugin file "
<<
filename
.
toStdString
()
<<
" is valid."
<<
std
::
endl
;
// now the plugin can be initialized and used
}
}
}
src/skylivex.h
View file @
4187ca74
...
@@ -36,7 +36,8 @@
...
@@ -36,7 +36,8 @@
#define SKYLIVEX_H
#define SKYLIVEX_H
#include <QObject>
#include <QObject>
#include <QString>
#include "pluginsinterfaces.h"
/*
/*
* class SkyliveX
* class SkyliveX
...
@@ -48,14 +49,20 @@ class SkyliveX : public QObject
...
@@ -48,14 +49,20 @@ class SkyliveX : public QObject
{
{
Q_OBJECT
Q_OBJECT
private
:
SkylivexPluginInterface
*
skylivexPluginInterface
;
public
:
public
:
SkyliveX
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{}
SkyliveX
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{}
~
SkyliveX
()
{}
~
SkyliveX
()
{}
void
loadPlugins
();
void
initializePlugin
(
QObject
*
,
QString
);
public
slots
:
public
slots
:
void
initialize
();
void
initialize
();
void
process
();
void
process
();
signals
:
signals
:
void
finished
();
void
finished
();
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment