Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nett-python
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
nett-python
Commits
b976f2ca
Commit
b976f2ca
authored
9 years ago
by
Christian Nowke
Browse files
Options
Downloads
Patches
Plain Diff
working slot_out
parent
16b04ba7
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMake/CMakeHelpers.cmake
+3
-0
3 additions, 0 deletions
CMake/CMakeHelpers.cmake
CMakeLists.txt
+5
-6
5 additions, 6 deletions
CMakeLists.txt
src/nett-python/nett-python.cpp
+36
-7
36 additions, 7 deletions
src/nett-python/nett-python.cpp
with
44 additions
and
13 deletions
CMake/CMakeHelpers.cmake
+
3
−
0
View file @
b976f2ca
...
...
@@ -2,6 +2,9 @@
macro
(
add_event arg1 event_name dir dir_out
)
exec_program
(
"protoc"
"
${
PROTOBUF_BIN
}
"
ARGS
"
${
dir
}
/
${
event_name
}
.proto"
"--proto_path=
${
dir
}
"
"--python_out=
${
dir_out
}
"
OUTPUT_VARIABLE output
)
list
(
APPEND
${
arg1
}
_EVENT_SOURCE_FILES
"
${
dir
}
/
${
event_name
}
.pb.h"
"
${
dir
}
/
${
event_name
}
.pb.cc"
)
# message ("output off protoc is: ${output}")
# message ("${dir}")
# message ("${dir_out}")
...
...
This diff is collapsed.
Click to expand it.
CMakeLists.txt
+
5
−
6
View file @
b976f2ca
...
...
@@ -29,8 +29,6 @@ set (NETT_LIBRARY_DEBUG "" CACHE FILEPATH "The nett debug library to link agains
set
(
ZMQ_LIBRARY
""
CACHE FILEPATH
"The zmq library to link against"
)
include
(
"include/nett-python/_SourceFiles.cmake"
)
include
(
"src/nett-python/_SourceFiles.cmake"
)
...
...
@@ -41,16 +39,17 @@ include_directories (${PROTOBUF_INCLUDE_DIR})
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
add_library
(
nett_python SHARED
${
ProjectSources
}
)
add_event
(
nett_python routing_message
${
NETT_SCHEMA_DIR
}
${
PROJECT_BINARY_DIR
}
)
add_event
(
nett_python string_message
${
NETT_SCHEMA_DIR
}
${
PROJECT_BINARY_DIR
}
)
add_library
(
nett_python SHARED
${
ProjectSources
}
${
nett_python_EVENT_SOURCE_FILES
}
)
target_link_libraries
(
nett_python optimized
${
NETT_LIBRARY
}
debug
${
NETT_LIBRARY_DEBUG
}
)
target_link_libraries
(
nett_python optimized
${
PYTHON_LIBRARY
}
debug
${
PYTHON_LIBRARY_DEBUG
}
)
target_link_libraries
(
nett_python optimized
${
BOOST_PYTHON_LIBRARY
}
debug
${
BOOST_PYTHON_LIBRARY_DEBUG
}
)
target_link_libraries
(
nett_python optimized
${
PROTOBUF_LIBRARY
}
debug
${
PROTOBUF_LIBRARY_DEBUG
}
)
target_link_libraries
(
nett_python
${
ZMQ_LIBRARY
}
)
add_event
(
nett_python routing_message
${
NETT_SCHEMA_DIR
}
${
PROJECT_BINARY_DIR
}
)
add_event
(
nett_python string_message
${
NETT_SCHEMA_DIR
}
${
PROJECT_BINARY_DIR
}
)
if
(
WIN32
)
add_custom_command
(
TARGET nett_python
POST_BUILD
...
...
This diff is collapsed.
Click to expand it.
src/nett-python/nett-python.cpp
+
36
−
7
View file @
b976f2ca
...
...
@@ -11,22 +11,51 @@
#include
<../schema/string_message.pb.h>
using
namespace
boost
::
python
;
std
::
shared_ptr
<
nett
::
slot_in
<
string_message
>>
create_slot_in_string_message
()
const
std
::
string
&
a
=
"tcp://127.0.0.1:65445"
;
void
initA
(
std
::
string
endpoint
)
{
return
nett
::
make_slot_in
<
string_message
>
(
);
nett
::
initialize
(
a
);
}
//nett::make_slot_out<string_message>(const std::string &slot_tag);
template
<
class
event_type
>
class
python_slot_out
{
public:
python_slot_out
(
std
::
string
const
&
slot_tag
)
{
slot_
=
nett
::
make_slot_out
<
event_type
>
(
slot_tag
);
}
void
send
(
std
::
string
const
&
message
)
{
slot_
->
send
(
convert
(
message
));
}
private
:
event_type
convert
(
std
::
string
const
&
serialized
)
{
event_type
message
;
if
(
!
message
.
ParseFromString
(
serialized
)
)
throw
std
::
runtime_error
(
"protobuf ParseFromString() failed"
);
return
message
;
}
std
::
shared_ptr
<
nett
::
slot_out
<
event_type
>
>
slot_
;
};
BOOST_PYTHON_MODULE
(
nett_python
)
{
def
(
"initialize"
,
&
nett
::
initialize
);
//def( "shutdown", &nett::shutdown);
class_
<
python_slot_out
<
string_message
>
>
(
"slot_out_string"
,
init
<
std
::
string
>
()
)
.
def
(
"send"
,
&
python_slot_out
<
string_message
>::
send
)
;
class_
<
nett
::
slot_in
<
string_message
>
,
boost
::
noncopyable
>
(
"slot_in_string"
,
no_init
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment