Skip to content
Snippets Groups Projects
Commit b976f2ca authored by Christian Nowke's avatar Christian Nowke
Browse files

working slot_out

parent 16b04ba7
No related branches found
No related tags found
No related merge requests found
......@@ -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}")
......
......@@ -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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment