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
0500997e
Commit
0500997e
authored
Feb 17, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to make the generic message handler to work
parent
ec70a4d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
+50
-2
skproto.cpp
plugins/skproto.cpp
+8
-0
skproto.h
plugins/skproto.h
+4
-0
ipcmsg.cpp
src/ipcmsg.cpp
+22
-2
ipcmsg.h
src/ipcmsg.h
+16
-0
No files found.
plugins/skproto.cpp
View file @
0500997e
...
@@ -37,11 +37,19 @@
...
@@ -37,11 +37,19 @@
#include <iostream>
#include <iostream>
#include "skproto.h"
#include "skproto.h"
void
SkyliveProtocol
::
startPlugin
()
void
SkyliveProtocol
::
startPlugin
()
{
{
std
::
cout
<<
"SkyliveProtocol initialized in thread "
<<
thread
()
<<
std
::
endl
;
std
::
cout
<<
"SkyliveProtocol initialized in thread "
<<
thread
()
<<
std
::
endl
;
SKMessage
::
SKMessage
prova
(
"ANTANI STA PROVA!!"
);
SKMessage
::
SKMessage
prova
(
"ANTANI STA PROVA!!"
);
sendMessage
(
prova
);
sendMessage
(
prova
);
handlers
.
registerHandler
((
QString
)
"connectTelescopes"
,
&
SkyliveProtocol
::
handle_connect
);
}
void
SkyliveProtocol
::
handle_connect
(
SKMessage
::
SKMessage
msg
)
{
std
::
cout
<<
"SkyliveProtocol connect : "
<<
msg
.
handle
.
toStdString
()
<<
std
::
endl
;
}
}
void
SkyliveProtocol
::
receiveMessage
(
SKMessage
::
SKMessage
msg
)
void
SkyliveProtocol
::
receiveMessage
(
SKMessage
::
SKMessage
msg
)
...
...
plugins/skproto.h
View file @
0500997e
...
@@ -37,15 +37,19 @@
...
@@ -37,15 +37,19 @@
#include "pluginsinterfaces.h"
#include "pluginsinterfaces.h"
#include "ipcmsg.h"
#include "ipcmsg.h"
class
SkyliveProtocol
:
public
QObject
,
SkylivexPluginInterface
class
SkyliveProtocol
:
public
QObject
,
SkylivexPluginInterface
{
{
Q_OBJECT
Q_OBJECT
Q_PLUGIN_METADATA
(
IID
"com.skylivex.SkylivexPlugin/1.0"
FILE
"skproto.json"
)
Q_PLUGIN_METADATA
(
IID
"com.skylivex.SkylivexPlugin/1.0"
FILE
"skproto.json"
)
Q_INTERFACES
(
SkylivexPluginInterface
)
Q_INTERFACES
(
SkylivexPluginInterface
)
private
:
SKHandlers
::
SKHandlers
handlers
;
public
:
public
:
void
startPlugin
();
void
startPlugin
();
void
sendMessage
(
SKMessage
::
SKMessage
msg
);
void
sendMessage
(
SKMessage
::
SKMessage
msg
);
void
handle_connect
(
SKMessage
::
SKMessage
msg
);
public
slots
:
public
slots
:
void
receiveMessage
(
SKMessage
::
SKMessage
msg
);
void
receiveMessage
(
SKMessage
::
SKMessage
msg
);
signals
:
signals
:
...
...
src/ipcmsg.cpp
View file @
0500997e
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include <QString>
#include <QString>
#include <iostream>
#include <iostream>
#include "ipcmsg.h"
#include "ipcmsg.h"
#include "pluginsinterfaces.h"
SKMessage
::
SKMessage
(
QString
s
,
QString
h
,
QHash
<
QString
,
QString
>
p
)
SKMessage
::
SKMessage
(
QString
s
,
QString
h
,
QHash
<
QString
,
QString
>
p
)
{
{
...
@@ -74,7 +74,6 @@ SKMessage::SKMessage()
...
@@ -74,7 +74,6 @@ SKMessage::SKMessage()
SKMessage
::~
SKMessage
()
SKMessage
::~
SKMessage
()
{
{
}
}
SKMessage
::
SKMessage
(
const
SKMessage
&
other
)
SKMessage
::
SKMessage
(
const
SKMessage
&
other
)
...
@@ -84,3 +83,24 @@ SKMessage::SKMessage(const SKMessage &other)
...
@@ -84,3 +83,24 @@ SKMessage::SKMessage(const SKMessage &other)
parameters
=
other
.
parameters
;
parameters
=
other
.
parameters
;
time
=
other
.
time
;
time
=
other
.
time
;
}
}
SKHandlers
::
SKHandlers
()
{
}
void
SKHandlers
::
execute
(
SKMessage
::
SKMessage
&
msg
)
{
//if(_handlers.contains(msg.handle))
// _handlers[msg.handle](msg);
}
void
SKHandlers
::
registerHandler
(
QString
type
,
SKHandlerFunction
handler
)
{
_handlers
[
type
]
=
handler
;
}
SKHandlers
::~
SKHandlers
()
{
}
src/ipcmsg.h
View file @
0500997e
...
@@ -64,4 +64,20 @@ class SKMessage
...
@@ -64,4 +64,20 @@ class SKMessage
};
};
typedef
void
(
*
SKHandlerFunction
)(
SKMessage
::
SKMessage
);
class
SKHandlers
{
public
:
SKHandlers
();
~
SKHandlers
();
void
registerHandler
(
QString
type
,
SKHandlerFunction
handler
);
void
execute
(
SKMessage
::
SKMessage
&
msg
);
private
:
QHash
<
QString
,
SKHandlerFunction
>
_handlers
;
};
#endif
#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