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
4f7387ef
Commit
4f7387ef
authored
Feb 17, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connect plugins with signals
parent
a6f18bf4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
15 deletions
+79
-15
skauth.cpp
plugins/skauth.cpp
+11
-0
skauth.h
plugins/skauth.h
+8
-2
skproto.cpp
plugins/skproto.cpp
+12
-0
skproto.h
plugins/skproto.h
+7
-2
pluginsinterfaces.h
src/pluginsinterfaces.h
+8
-0
skylivex.cpp
src/skylivex.cpp
+29
-10
skylivex.h
src/skylivex.h
+4
-1
No files found.
plugins/skauth.cpp
View file @
4f7387ef
...
...
@@ -41,3 +41,14 @@ void SkyliveAuth::startPlugin()
std
::
cout
<<
"SkyliveAuth initialized"
<<
std
::
endl
;
}
void
SkyliveAuth
::
receiveMessage
(
std
::
string
&
msg
)
{
std
::
cout
<<
"SkyliveAuth receive"
<<
msg
<<
std
::
endl
;
}
void
SkyliveAuth
::
sendMessage
(
std
::
string
&
msg
)
{
emit
putMessage
(
msg
);
}
plugins/skauth.h
View file @
4f7387ef
...
...
@@ -42,7 +42,13 @@ class SkyliveAuth : public QObject, SkylivexPluginInterface
Q_PLUGIN_METADATA
(
IID
"com.skylivex.SkylivexPlugin/1.0"
FILE
"skauth.json"
)
Q_INTERFACES
(
SkylivexPluginInterface
)
public
:
void
startPlugin
();
public
:
void
startPlugin
();
void
sendMessage
(
std
::
string
&
msg
);
public
slots
:
void
receiveMessage
(
std
::
string
&
msg
);
signals
:
void
putMessage
(
std
::
string
&
msg
);
};
plugins/skproto.cpp
View file @
4f7387ef
...
...
@@ -39,5 +39,17 @@
void
SkyliveProtocol
::
startPlugin
()
{
std
::
cout
<<
"SkyliveProtocol initialized"
<<
std
::
endl
;
std
::
string
prova
(
"ANTANI STA PROVA!!"
);
sendMessage
(
prova
);
}
void
SkyliveProtocol
::
receiveMessage
(
std
::
string
&
msg
)
{
std
::
cout
<<
"SkyliveProtocol receive"
<<
msg
<<
std
::
endl
;
}
void
SkyliveProtocol
::
sendMessage
(
std
::
string
&
msg
)
{
emit
putMessage
(
msg
);
}
plugins/skproto.h
View file @
4f7387ef
...
...
@@ -42,7 +42,12 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
Q_PLUGIN_METADATA
(
IID
"com.skylivex.SkylivexPlugin/1.0"
FILE
"skproto.json"
)
Q_INTERFACES
(
SkylivexPluginInterface
)
public
:
void
startPlugin
();
public
:
void
startPlugin
();
void
sendMessage
(
std
::
string
&
msg
);
public
slots
:
void
receiveMessage
(
std
::
string
&
msg
);
signals
:
void
putMessage
(
std
::
string
&
msg
);
};
src/pluginsinterfaces.h
View file @
4f7387ef
...
...
@@ -35,6 +35,7 @@
#ifndef PLUGINSINTERFACES_H
#define PLUGINSINTERFACES_H
#include <QtPlugin>
#include <iostream>
QT_BEGIN_NAMESPACE
class
QStringList
;
...
...
@@ -46,6 +47,13 @@ class SkylivexPluginInterface
public
:
virtual
~
SkylivexPluginInterface
()
{}
virtual
void
startPlugin
()
=
0
;
virtual
void
sendMessage
(
std
::
string
)
{}
public
slots
:
virtual
void
receiveMessage
(
std
::
string
)
{}
signals
:
virtual
void
putMessage
(
std
::
string
)
{}
};
QT_BEGIN_NAMESPACE
...
...
src/skylivex.cpp
View file @
4f7387ef
...
...
@@ -58,7 +58,7 @@ void SkyliveX::process()
{
//std::cout << "process" << std::endl;
std
::
string
sarca
(
"ANTANI!"
);
sendM
sgToMainWin
(
sarca
);
sendM
essage
(
sarca
);
}
...
...
@@ -89,24 +89,43 @@ void SkyliveX::loadPlugins()
void
SkyliveX
::
initializePlugin
(
QObject
*
plugin
,
QString
filename
)
{
// connect signals/slots
connect
(
plugin
,
SIGNAL
(
putMessage
(
std
::
string
)),
this
,
SLOT
(
receiveFromPlugins
(
std
::
string
)));
connect
(
this
,
SIGNAL
(
msgForPlugins
(
std
::
string
)),
plugin
,
SLOT
(
receiveMessage
(
std
::
string
)));
// Move the plugin in it's own thread
QThread
*
consumer
=
new
QThread
();
plugin
->
moveToThread
(
consumer
);
consumer
->
start
();
// Save plugin in the plugin list hash
skylivexPluginList
.
insert
(
filename
,
plugin
);
// Cast the plugin skylivex interface
skylivexPluginInterface
=
qobject_cast
<
SkylivexPluginInterface
*>
(
plugin
);
if
(
skylivexPluginInterface
)
{
std
::
cout
<<
"Plugin file "
<<
filename
.
toStdString
()
<<
" is valid."
<<
std
::
endl
;
// Create a new thread for the plugin
QThread
*
consumer
=
new
QThread
();
plugin
->
moveToThread
(
consumer
);
consumer
->
start
();
// Save plugin in the plugin list hash
skylivexPluginList
.
insert
(
filename
,
plugin
);
// now the plugin can be initialized and used
// now the plugin can be initialized
skylivexPluginInterface
->
startPlugin
();
}
}
void
SkyliveX
::
sendM
sgToMainWin
(
std
::
string
&
msg
)
void
SkyliveX
::
sendM
essage
(
std
::
string
&
msg
)
{
//std::cout << "Send To MainWin: " << msg << std::endl;
emit
msgForMainWin
(
msg
);
emit
msgForPlugins
(
msg
);
}
void
SkyliveX
::
receiveFromMainWin
(
std
::
string
&
msg
)
{
emit
msgForPlugins
(
msg
);
}
void
SkyliveX
::
receiveFromPlugins
(
std
::
string
&
msg
)
{
sendMessage
(
msg
);
}
src/skylivex.h
View file @
4f7387ef
...
...
@@ -61,15 +61,18 @@ class SkyliveX : public QObject
~
SkyliveX
()
{}
void
loadPlugins
();
void
initializePlugin
(
QObject
*
,
QString
);
void
sendMessage
(
std
::
string
&
msg
);
public
slots
:
void
initialize
();
void
process
();
void
sendMsgToMainWin
(
std
::
string
&
msg
);
void
receiveFromMainWin
(
std
::
string
&
msg
);
void
receiveFromPlugins
(
std
::
string
&
msg
);
signals
:
void
finished
();
void
msgForMainWin
(
std
::
string
&
msg
);
void
msgForPlugins
(
std
::
string
&
msg
);
};
#endif
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