[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/46: zeromq: first cut at compiling lib/
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/46: zeromq: first cut at compiling lib/ directory |
Date: |
Fri, 16 May 2014 19:37:13 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 9eedccd40fcbe8be49a7170e4338079a68d27360
Author: Johnathan Corgan <address@hidden>
Date: Sun Dec 8 12:44:51 2013 -0800
zeromq: first cut at compiling lib/ directory
---
cmake/Modules/FindZeroMQ.cmake | 59 +--
gr-zeromq/CMakeLists.txt | 2 +-
gr-zeromq/lib/CMakeLists.txt | 80 ++--
gr-zeromq/lib/gnuradio-zeromq.rc.in | 55 +++
gr-zeromq/lib/qa_zmqblocks.cc | 36 --
gr-zeromq/lib/qa_zmqblocks.h | 38 --
gr-zeromq/lib/sink_pubsub_impl.cc | 57 ++-
gr-zeromq/lib/sink_pubsub_impl.h | 38 +-
gr-zeromq/lib/sink_pushpull_impl.cc | 9 +-
gr-zeromq/lib/sink_pushpull_impl.h | 13 +-
gr-zeromq/lib/sink_reqrep_impl.cc | 9 +-
gr-zeromq/lib/sink_reqrep_impl.h | 13 +-
gr-zeromq/lib/sink_reqrep_nopoll_impl.cc | 9 +-
gr-zeromq/lib/sink_reqrep_nopoll_impl.h | 13 +-
gr-zeromq/lib/source_pushpull_feedback_impl.cc | 9 +-
gr-zeromq/lib/source_pushpull_feedback_impl.h | 13 +-
gr-zeromq/lib/source_pushpull_impl.cc | 9 +-
gr-zeromq/lib/source_pushpull_impl.h | 13 +-
gr-zeromq/lib/source_reqrep_impl.cc | 9 +-
gr-zeromq/lib/source_reqrep_impl.h | 13 +-
gr-zeromq/lib/source_reqrep_nopoll_impl.cc | 9 +-
gr-zeromq/lib/source_reqrep_nopoll_impl.h | 13 +-
gr-zeromq/lib/test_zmqblocks.cc | 47 ---
gr-zeromq/lib/zmq.hpp | 517 -------------------------
24 files changed, 228 insertions(+), 855 deletions(-)
diff --git a/cmake/Modules/FindZeroMQ.cmake b/cmake/Modules/FindZeroMQ.cmake
index 5ccbfbc..0cd5b00 100644
--- a/cmake/Modules/FindZeroMQ.cmake
+++ b/cmake/Modules/FindZeroMQ.cmake
@@ -1,45 +1,26 @@
-# - Try to find ZeroMQ headers and libraries
-# - THANKS CUBIT FOR THIS FIND MODULE
-#
-# Usage of this module as follows:
-#
-# find_package(ZeroMQ)
-#
-# Variables used by this module, they can change the default behaviour and need
-# to be set before calling find_package:
-#
-# ZeroMQ_ROOT_DIR Set this variable to the root installation of
-# ZeroMQ if the module has problems finding
-# the proper installation path.
-#
-# Variables defined by this module:
-#
-# ZEROMQ_FOUND System has ZeroMQ libs/headers
-# ZeroMQ_LIBRARIES The ZeroMQ libraries
-# ZeroMQ_INCLUDE_DIRS The location of ZeroMQ headers
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_ZEROMQ "libzmq")
-find_path(ZeroMQ_ROOT_DIR
- NAMES include/zmq.h
-)
-
-find_library(ZeroMQ_LIBRARIES
- NAMES zmq libzmq
- HINTS ${ZeroMQ_ROOT_DIR}/lib
-)
-
-find_path(ZeroMQ_INCLUDE_DIRS
+FIND_PATH(ZEROMQ_INCLUDE_DIRS
NAMES zmq.h
- HINTS ${ZeroMQ_ROOT_DIR}/include
+ HINTS ${PC_ZEROMQ_INCLUDE_DIR}
+ ${CMAKE_INSTALL_PREFIX}/include
+ PATHS
+ /usr/local/include
+ /usr/include
)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(ZeroMQ DEFAULT_MSG
- ZeroMQ_LIBRARIES
- ZeroMQ_INCLUDE_DIRS
+FIND_LIBRARY(ZEROMQ_LIBRARIES
+ NAMES zmq
+ HINTS ${PC_ZEROMQ_LIBDIR}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ ${CMAKE_INSTALL_PREFIX}/lib64
+ PATHS
+ ${ZEROMQ_INCLUDE_DIRS}/../lib
+ /usr/local/lib
+ /usr/lib
)
-mark_as_advanced(
- ZeroMQ_ROOT_DIR
- ZeroMQ_LIBRARIES
- ZeroMQ_INCLUDE_DIRS
-)
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZEROMQ DEFAULT_MSG ZEROMQ_LIBRARIES
ZEROMQ_INCLUDE_DIRS)
+MARK_AS_ADVANCED(ZEROMQ_LIBRARIES ZEROMQ_INCLUDE_DIRS)
diff --git a/gr-zeromq/CMakeLists.txt b/gr-zeromq/CMakeLists.txt
index 7ef24b8..f9340e0 100644
--- a/gr-zeromq/CMakeLists.txt
+++ b/gr-zeromq/CMakeLists.txt
@@ -86,7 +86,7 @@ CPACK_COMPONENT("zeromq_swig"
# Add subdirectories
########################################################################
add_subdirectory(include/gnuradio/zeromq)
-#add_subdirectory(lib)
+add_subdirectory(lib)
#if(ENABLE_PYTHON)
# add_subdirectory(swig)
# add_subdirectory(python/zeromq)
diff --git a/gr-zeromq/lib/CMakeLists.txt b/gr-zeromq/lib/CMakeLists.txt
index f37494f..a7d517b 100644
--- a/gr-zeromq/lib/CMakeLists.txt
+++ b/gr-zeromq/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011,2012 Free Software Foundation, Inc.
+# Copyright 2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -18,56 +18,56 @@
# Boston, MA 02110-1301, USA.
########################################################################
-# Setup library
+# Setup the include and linker paths
########################################################################
-include(GrPlatform) #define LIB_SUFFIX
+include_directories(
+ ${GR_ZEROMQ_INCLUDE_DIRS}
+ ${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
+ ${ZEROMQ_INCLUDE_DIRS}
+)
-include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
-list(APPEND zmqblocks_sources
- sink_reqrep_impl.cc
- source_reqrep_impl.cc
- sink_reqrep_nopoll_impl.cc
- source_reqrep_nopoll_impl.cc
- sink_pushpull_impl.cc
- source_pushpull_impl.cc
- source_pushpull_feedback_impl.cc
- sink_pubsub_impl.cc
- )
-add_library(gnuradio-zmqblocks SHARED ${zmqblocks_sources})
-target_link_libraries(gnuradio-zmqblocks ${Boost_LIBRARIES}
${GNURADIO_RUNTIME_LIBRARIES} ${ZeroMQ_LIBRARIES})
-set_target_properties(gnuradio-zmqblocks PROPERTIES DEFINE_SYMBOL
"gnuradio_zmqblocks_EXPORTS")
+if(ENABLE_GR_CTRLPORT)
+ ADD_DEFINITIONS(-DGR_CTRLPORT)
+ include_directories(${ICE_INCLUDE_DIR})
+endif(ENABLE_GR_CTRLPORT)
########################################################################
-# Install built library files
+# Setup library
########################################################################
-install(TARGETS gnuradio-zmqblocks
- LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file
- ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
- RUNTIME DESTINATION bin # .dll file
+list(APPEND zeromq_sources
+ sink_pubsub_impl.cc
+ sink_pushpull_impl.cc
+ sink_reqrep_impl.cc
+ sink_reqrep_nopoll_impl.cc
+ source_pushpull_feedback_impl.cc
+ source_pushpull_impl.cc
+ source_reqrep_impl.cc
+ source_reqrep_nopoll_impl.cc
)
-########################################################################
-# Build and register unit test
-########################################################################
-include(GrTest)
-
-include_directories(${CPPUNIT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS})
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
-list(APPEND test_zmqblocks_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/test_zmqblocks.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_zmqblocks.cc
-)
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-zeromq.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-zeromq.rc
+ @ONLY)
-add_executable(test-zmqblocks ${test_zmqblocks_sources})
+ list(APPEND gr_zeromq_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-zeromq.rc
+ )
+endif(MSVC)
-target_link_libraries(
- test-zmqblocks
- ${GNURADIO_RUNTIME_LIBRARIES}
- ${Boost_LIBRARIES}
- ${CPPUNIT_LIBRARIES}
- ${ZeroMQ_LIBRARIES}
+list(APPEND zeromq_libs
+ gnuradio-runtime
+ ${Boost_LIBRARIES}
+ ${ZeroMQ_LIBRARIES}
)
-GR_ADD_TEST(test_zmqblocks test-zmqblocks)
+add_library(gnuradio-zeromq SHARED ${zeromq_sources})
+target_link_libraries(gnuradio-zeromq ${zeromq_libs})
+GR_LIBRARY_FOO(gnuradio-zeromq RUNTIME_COMPONENT "zeromq_runtime"
DEVEL_COMPONENT "zeromq_devel")
diff --git a/gr-zeromq/lib/gnuradio-zeromq.rc.in
b/gr-zeromq/lib/gnuradio-zeromq.rc.in
new file mode 100644
index 0000000..41a5e65
--- /dev/null
+++ b/gr-zeromq/lib/gnuradio-zeromq.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION
@MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION
@MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-zeromq"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-zeromq.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-zeromq.dll"
+ VALUE "ProductName", "gnuradio-zeromq"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-zeromq/lib/qa_zmqblocks.cc b/gr-zeromq/lib/qa_zmqblocks.cc
deleted file mode 100644
index bc795c2..0000000
--- a/gr-zeromq/lib/qa_zmqblocks.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * This class gathers together all the test cases for the gr-filter
- * directory into a single test suite. As you create new test cases,
- * add them here.
- */
-
-#include "qa_zmqblocks.h"
-
-CppUnit::TestSuite *
-qa_zmqblocks::suite()
-{
- CppUnit::TestSuite *s = new CppUnit::TestSuite("zmqblocks");
-
- return s;
-}
diff --git a/gr-zeromq/lib/qa_zmqblocks.h b/gr-zeromq/lib/qa_zmqblocks.h
deleted file mode 100644
index 25b3370..0000000
--- a/gr-zeromq/lib/qa_zmqblocks.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _QA_ZMQBLOCKS_H_
-#define _QA_ZMQBLOCKS_H_
-
-#include <gnuradio/attributes.h>
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the gr-filter directory
-
-class __GR_ATTR_EXPORT qa_zmqblocks
-{
- public:
- //! return suite of tests for all of gr-filter directory
- static CppUnit::TestSuite *suite();
-};
-
-#endif /* _QA_ZMQBLOCKS_H_ */
diff --git a/gr-zeromq/lib/sink_pubsub_impl.cc
b/gr-zeromq/lib/sink_pubsub_impl.cc
index 3e3ef26..3c6fdd7 100644
--- a/gr-zeromq/lib/sink_pubsub_impl.cc
+++ b/gr-zeromq/lib/sink_pubsub_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
- *
- * Authors: Johannes Schmitz <address@hidden>
+ * Copyright 2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,54 +28,46 @@
#include "sink_pubsub_impl.h"
namespace gr {
- namespace zmqblocks {
-
+ namespace zeromq {
+
sink_pubsub::sptr
sink_pubsub::make(size_t itemsize, char *address)
{
- return gnuradio::get_initial_sptr
- (new sink_pubsub_impl(itemsize, address));
+ return gnuradio::get_initial_sptr
+ (new sink_pubsub_impl(itemsize, address));
}
-
- /*
- * The private constructor
- */
+
sink_pubsub_impl::sink_pubsub_impl(size_t itemsize, char *address)
: gr::sync_block("sink_pubsub",
gr::io_signature::make(1, 1, itemsize),
gr::io_signature::make(0, 0, 0)),
d_itemsize(itemsize)
{
- d_context = new zmq::context_t(1);
- d_socket = new zmq::socket_t(*d_context, ZMQ_PUB);
- d_socket->bind(address);
- std::cout << "sink_pubsub on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_PUB);
+ d_socket->bind(address);
}
-
- /*
- * Our virtual destructor.
- */
+
sink_pubsub_impl::~sink_pubsub_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
-
+
int
sink_pubsub_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const char *in = (const char *) input_items[0];
- // create message copy and send
- zmq::message_t msg(d_itemsize*noutput_items);
- memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
- d_socket->send(msg);
-
- return noutput_items;
+ const char *in = (const char *)input_items[0];
+ // create message copy and send
+ zmq::message_t msg(d_itemsize*noutput_items);
+ memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+ d_socket->send(msg);
+
+ return noutput_items;
}
-
- } /* namespace zmqblocks */
+
+ } /* namespace zeromq */
} /* namespace gr */
-
diff --git a/gr-zeromq/lib/sink_pubsub_impl.h b/gr-zeromq/lib/sink_pubsub_impl.h
index 5bfd322..5511b99 100644
--- a/gr-zeromq/lib/sink_pubsub_impl.h
+++ b/gr-zeromq/lib/sink_pubsub_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,30 +23,29 @@
#ifndef INCLUDED_ZMQBLOCKS_SINK_PUBSUB_IMPL_H
#define INCLUDED_ZMQBLOCKS_SINK_PUBSUB_IMPL_H
-#include <zmqblocks/sink_pubsub.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/sink_pubsub.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class sink_pubsub_impl : public sink_pubsub
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
-
- public:
- sink_pubsub_impl(size_t itemsize, char *address);
- ~sink_pubsub_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
+
+ public:
+ sink_pubsub_impl(size_t itemsize, char *address);
+ ~sink_pubsub_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
-
- } // namespace zmqblocks
+
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SINK_PUBSUB_IMPL_H */
-
diff --git a/gr-zeromq/lib/sink_pushpull_impl.cc
b/gr-zeromq/lib/sink_pushpull_impl.cc
index 5bdb609..d77dc89 100644
--- a/gr-zeromq/lib/sink_pushpull_impl.cc
+++ b/gr-zeromq/lib/sink_pushpull_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@
#include "sink_pushpull_impl.h"
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
sink_pushpull::sptr
sink_pushpull::make(size_t itemsize, char *address)
@@ -77,6 +76,6 @@ namespace gr {
return noutput_items;
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/sink_pushpull_impl.h
b/gr-zeromq/lib/sink_pushpull_impl.h
index 310aaa8..f88c0e9 100644
--- a/gr-zeromq/lib/sink_pushpull_impl.h
+++ b/gr-zeromq/lib/sink_pushpull_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SINK_PUSHPULL_IMPL_H
#define INCLUDED_ZMQBLOCKS_SINK_PUSHPULL_IMPL_H
-#include <zmqblocks/sink_pushpull.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/sink_pushpull.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class sink_pushpull_impl : public sink_pushpull
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_ZMQ_SINK_PUSHPULL_IMPL_H */
diff --git a/gr-zeromq/lib/sink_reqrep_impl.cc
b/gr-zeromq/lib/sink_reqrep_impl.cc
index 91e3b83..7c61872 100644
--- a/gr-zeromq/lib/sink_reqrep_impl.cc
+++ b/gr-zeromq/lib/sink_reqrep_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@
#include "sink_reqrep_impl.h"
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
sink_reqrep::sptr
sink_reqrep::make(size_t itemsize, char *address)
@@ -93,6 +92,6 @@ namespace gr {
}
return 0;
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/sink_reqrep_impl.h b/gr-zeromq/lib/sink_reqrep_impl.h
index fa74606..968bdb7 100644
--- a/gr-zeromq/lib/sink_reqrep_impl.h
+++ b/gr-zeromq/lib/sink_reqrep_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SINK_REQREP_IMPL_H
#define INCLUDED_ZMQBLOCKS_SINK_REQREP_IMPL_H
-#include <zmqblocks/sink_reqrep.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/sink_reqrep.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class sink_reqrep_impl : public sink_reqrep
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SINK_REQREP_IMPL_H */
diff --git a/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
b/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
index abcf47d..2b901c2 100644
--- a/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
+++ b/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +30,7 @@
#include <iostream>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
sink_reqrep_nopoll::sptr
sink_reqrep_nopoll::make(size_t itemsize, char *address)
@@ -89,6 +88,6 @@ namespace gr {
}
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
b/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
index d91fa9e..c029ff4 100644
--- a/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
+++ b/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SINK_REQREP_NOPOLL_IMPL_H
#define INCLUDED_ZMQBLOCKS_SINK_REQREP_NOPOLL_IMPL_H
-#include <zmqblocks/sink_reqrep_nopoll.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/sink_reqrep_nopoll.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class sink_reqrep_nopoll_impl : public sink_reqrep_nopoll
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SINK_REQREP_NOPOLL_IMPL_H */
diff --git a/gr-zeromq/lib/source_pushpull_feedback_impl.cc
b/gr-zeromq/lib/source_pushpull_feedback_impl.cc
index 9e7836c..535ff1e 100644
--- a/gr-zeromq/lib/source_pushpull_feedback_impl.cc
+++ b/gr-zeromq/lib/source_pushpull_feedback_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@
#include "source_pushpull_feedback_impl.h"
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
source_pushpull_feedback::sptr
source_pushpull_feedback::make(size_t itemsize, char *address)
@@ -92,6 +91,6 @@ namespace gr {
}
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/source_pushpull_feedback_impl.h
b/gr-zeromq/lib/source_pushpull_feedback_impl.h
index 6217d8e..d4b22f5 100644
--- a/gr-zeromq/lib/source_pushpull_feedback_impl.h
+++ b/gr-zeromq/lib/source_pushpull_feedback_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_FEEDBACK_IMPL_H
#define INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_FEEDBACK_IMPL_H
-#include <zmqblocks/source_pushpull_feedback.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/source_pushpull_feedback.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class source_pushpull_feedback_impl : public source_pushpull_feedback
{
@@ -47,7 +46,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_FEEDBACK_IMPL_H */
diff --git a/gr-zeromq/lib/source_pushpull_impl.cc
b/gr-zeromq/lib/source_pushpull_impl.cc
index e8e7a23..1912c63 100644
--- a/gr-zeromq/lib/source_pushpull_impl.cc
+++ b/gr-zeromq/lib/source_pushpull_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@
#include "source_pushpull_impl.h"
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
source_pushpull::sptr
source_pushpull::make(size_t itemsize, char *address)
@@ -91,6 +90,6 @@ namespace gr {
}
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/source_pushpull_impl.h
b/gr-zeromq/lib/source_pushpull_impl.h
index a943326..ed621cf 100644
--- a/gr-zeromq/lib/source_pushpull_impl.h
+++ b/gr-zeromq/lib/source_pushpull_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_IMPL_H
#define INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_IMPL_H
-#include <zmqblocks/source_pushpull.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/source_pushpull.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class source_pushpull_impl : public source_pushpull
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SOURCE_PUSHPULL_IMPL_H */
diff --git a/gr-zeromq/lib/source_reqrep_impl.cc
b/gr-zeromq/lib/source_reqrep_impl.cc
index fb86719..337c221 100644
--- a/gr-zeromq/lib/source_reqrep_impl.cc
+++ b/gr-zeromq/lib/source_reqrep_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@
#include "source_reqrep_impl.h"
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
source_reqrep::sptr
source_reqrep::make(size_t itemsize, char *address)
@@ -94,6 +93,6 @@ namespace gr {
return 0;
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/source_reqrep_impl.h
b/gr-zeromq/lib/source_reqrep_impl.h
index faa17d1..45a3e63 100644
--- a/gr-zeromq/lib/source_reqrep_impl.h
+++ b/gr-zeromq/lib/source_reqrep_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SOURCE_REQREP_IMPL_H
#define INCLUDED_ZMQBLOCKS_SOURCE_REQREP_IMPL_H
-#include <zmqblocks/source_reqrep.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/source_reqrep.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class source_reqrep_impl : public source_reqrep
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SOURCE_REQREP_IMPL_H */
diff --git a/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
b/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
index 449a539..a713351 100644
--- a/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
+++ b/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +29,7 @@
#include <cstring>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
source_reqrep_nopoll::sptr
source_reqrep_nopoll::make(size_t itemsize, char *address)
@@ -84,6 +83,6 @@ namespace gr {
return reply.size()/d_itemsize;
}
- } /* namespace zmqblocks */
+ } /* namespace zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/source_reqrep_nopoll_impl.h
b/gr-zeromq/lib/source_reqrep_nopoll_impl.h
index 837520b..305f8d8 100644
--- a/gr-zeromq/lib/source_reqrep_nopoll_impl.h
+++ b/gr-zeromq/lib/source_reqrep_nopoll_impl.h
@@ -1,9 +1,8 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Institute for Theoretical Information Technology,
- * RWTH Aachen University
+ * Copyright 2013 Free Software Foundation, Inc.
*
- * Authors: Johannes Schmitz <address@hidden>
+ * This file is part of GNU Radio.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +23,11 @@
#ifndef INCLUDED_ZMQBLOCKS_SOURCE_REQREP_NOPOLL_IMPL_H
#define INCLUDED_ZMQBLOCKS_SOURCE_REQREP_NOPOLL_IMPL_H
-#include <zmqblocks/source_reqrep_nopoll.h>
-#include "zmq.hpp"
+#include <gnuradio/zeromq/source_reqrep_nopoll.h>
+#include <zmq.hpp>
namespace gr {
- namespace zmqblocks {
+ namespace zeromq {
class source_reqrep_nopoll_impl : public source_reqrep_nopoll
{
@@ -46,7 +45,7 @@ namespace gr {
gr_vector_void_star &output_items);
};
- } // namespace zmqblocks
+ } // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SOURCE_REQREP_NOPOLL_IMPL_H */
diff --git a/gr-zeromq/lib/test_zmqblocks.cc b/gr-zeromq/lib/test_zmqblocks.cc
deleted file mode 100644
index 3805df5..0000000
--- a/gr-zeromq/lib/test_zmqblocks.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <cppunit/TextTestRunner.h>
-#include <cppunit/XmlOutputter.h>
-
-#include <gnuradio/unittests.h>
-#include "qa_zmqblocks.h"
-#include <iostream>
-
-int
-main (int argc, char **argv)
-{
- CppUnit::TextTestRunner runner;
- std::ofstream xmlfile(get_unittest_path("zmqblocks.xml").c_str());
- CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(),
xmlfile);
-
- runner.addTest(qa_zmqblocks::suite());
- runner.setOutputter(xmlout);
-
- bool was_successful = runner.run("", false);
-
- return was_successful ? 0 : 1;
-}
diff --git a/gr-zeromq/lib/zmq.hpp b/gr-zeromq/lib/zmq.hpp
deleted file mode 100644
index 9be78ba..0000000
--- a/gr-zeromq/lib/zmq.hpp
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- Copyright (c) 2009-2011 250bpm s.r.o.
- Copyright (c) 2011 Botond Ballo
- Copyright (c) 2007-2009 iMatix Corporation
-
- Permission is hereby granted, free of charge, to any person obtaining a
copy
- of this software and associated documentation files (the "Software"), to
- deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- sell copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS
- IN THE SOFTWARE.
-*/
-
-#ifndef __ZMQ_HPP_INCLUDED__
-#define __ZMQ_HPP_INCLUDED__
-
-#include <zmq.h>
-
-#include <algorithm>
-#include <cassert>
-#include <cstring>
-#include <string>
-#include <exception>
-
-// Detect whether the compiler supports C++11 rvalue references.
-#if (defined(__GNUC__) && (__GNUC__ > 4 || \
- (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__))
- #define ZMQ_HAS_RVALUE_REFS
- #define ZMQ_DELETED_FUNCTION = delete
-#elif defined(__clang__)
- #if __has_feature(cxx_rvalue_references)
- #define ZMQ_HAS_RVALUE_REFS
- #endif
-
- #if __has_feature(cxx_deleted_functions)
- #define ZMQ_DELETED_FUNCTION = delete
- #else
- #define ZMQ_DELETED_FUNCTION
- #endif
-#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
- #define ZMQ_HAS_RVALUE_REFS
- #define ZMQ_DELETED_FUNCTION
-#else
- #define ZMQ_DELETED_FUNCTION
-#endif
-
-// In order to prevent unused variable warnings when building in non-debug
-// mode use this macro to make assertions.
-#ifndef NDEBUG
-# define ZMQ_ASSERT(expression) assert(expression)
-#else
-# define ZMQ_ASSERT(expression) (void)(expression)
-#endif
-
-namespace zmq
-{
-
- typedef zmq_free_fn free_fn;
- typedef zmq_pollitem_t pollitem_t;
-
- class error_t : public std::exception
- {
- public:
-
- error_t () : errnum (zmq_errno ()) {}
-
- virtual const char *what () const throw ()
- {
- return zmq_strerror (errnum);
- }
-
- int num () const
- {
- return errnum;
- }
-
- private:
-
- int errnum;
- };
-
- inline int poll (zmq_pollitem_t *items_, int nitems_, long timeout_ = -1)
- {
- int rc = zmq_poll (items_, nitems_, timeout_);
- if (rc < 0)
- throw error_t ();
- return rc;
- }
-
- inline void proxy (void *frontend, void *backend, void *capture)
- {
- int rc = zmq_proxy (frontend, backend, capture);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void version (int *major_, int *minor_, int *patch_)
- {
- zmq_version (major_, minor_, patch_);
- }
-
- class message_t
- {
- friend class socket_t;
-
- public:
-
- inline message_t ()
- {
- int rc = zmq_msg_init (&msg);
- if (rc != 0)
- throw error_t ();
- }
-
- inline explicit message_t (size_t size_)
- {
- int rc = zmq_msg_init_size (&msg, size_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline message_t (void *data_, size_t size_, free_fn *ffn_,
- void *hint_ = NULL)
- {
- int rc = zmq_msg_init_data (&msg, data_, size_, ffn_, hint_);
- if (rc != 0)
- throw error_t ();
- }
-
-#ifdef ZMQ_HAS_RVALUE_REFS
- inline message_t (message_t &&rhs) : msg (rhs.msg)
- {
- int rc = zmq_msg_init (&rhs.msg);
- if (rc != 0)
- throw error_t ();
- }
-
- inline message_t &operator = (message_t &&rhs)
- {
- std::swap (msg, rhs.msg);
- return *this;
- }
-#endif
-
- inline ~message_t ()
- {
- int rc = zmq_msg_close (&msg);
- ZMQ_ASSERT (rc == 0);
- }
-
- inline void rebuild ()
- {
- int rc = zmq_msg_close (&msg);
- if (rc != 0)
- throw error_t ();
- rc = zmq_msg_init (&msg);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void rebuild (size_t size_)
- {
- int rc = zmq_msg_close (&msg);
- if (rc != 0)
- throw error_t ();
- rc = zmq_msg_init_size (&msg, size_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void rebuild (void *data_, size_t size_, free_fn *ffn_,
- void *hint_ = NULL)
- {
- int rc = zmq_msg_close (&msg);
- if (rc != 0)
- throw error_t ();
- rc = zmq_msg_init_data (&msg, data_, size_, ffn_, hint_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void move (message_t *msg_)
- {
- int rc = zmq_msg_move (&msg, &(msg_->msg));
- if (rc != 0)
- throw error_t ();
- }
-
- inline void copy (message_t *msg_)
- {
- int rc = zmq_msg_copy (&msg, &(msg_->msg));
- if (rc != 0)
- throw error_t ();
- }
-
- inline void *data ()
- {
- return zmq_msg_data (&msg);
- }
-
- inline const void* data () const
- {
- return zmq_msg_data (const_cast<zmq_msg_t*>(&msg));
- }
-
- inline size_t size () const
- {
- return zmq_msg_size (const_cast<zmq_msg_t*>(&msg));
- }
-
- private:
-
- // The underlying message
- zmq_msg_t msg;
-
- // Disable implicit message copying, so that users won't use shared
- // messages (less efficient) without being aware of the fact.
- message_t (const message_t&);
- void operator = (const message_t&);
- };
-
- class context_t
- {
- friend class socket_t;
-
- public:
-
- inline explicit context_t (int io_threads_)
- {
- ptr = zmq_init (io_threads_);
- if (ptr == NULL)
- throw error_t ();
- }
-
-#ifdef ZMQ_HAS_RVALUE_REFS
- inline context_t (context_t &&rhs) : ptr (rhs.ptr)
- {
- rhs.ptr = NULL;
- }
- inline context_t &operator = (context_t &&rhs)
- {
- std::swap (ptr, rhs.ptr);
- return *this;
- }
-#endif
-
- inline ~context_t ()
- {
- close();
- }
-
- inline void close()
- {
- if (ptr == NULL)
- return;
- int rc = zmq_term (ptr);
- ZMQ_ASSERT (rc == 0);
- ptr = NULL;
- }
-
- // Be careful with this, it's probably only useful for
- // using the C api together with an existing C++ api.
- // Normally you should never need to use this.
- inline operator void* ()
- {
- return ptr;
- }
-
- private:
-
- void *ptr;
-
- context_t (const context_t&);
- void operator = (const context_t&);
- };
-
- class monitor_t
- {
- public:
- virtual void on_event_connected(const char *addr_) = 0;
- virtual void on_event_connect_delayed(const char *addr_) = 0;
- virtual void on_event_connect_retried(const char *addr_) = 0;
- virtual void on_event_listening(const char *addr_) = 0;
- virtual void on_event_bind_failed(const char *addr_) = 0;
- virtual void on_event_accepted(const char *addr_) = 0;
- virtual void on_event_accept_failed(const char *addr_) = 0;
- virtual void on_event_closed(const char *addr_) = 0;
- virtual void on_event_close_failed(const char *addr_) = 0;
- virtual void on_event_disconnected(const char *addr_) = 0;
- virtual void on_event_unknown(int event) = 0;
- };
-
- class socket_t
- {
- public:
-
- inline socket_t (context_t &context_, int type_)
- {
- ctxptr = context_.ptr;
- ptr = zmq_socket (context_.ptr, type_);
- if (ptr == NULL)
- throw error_t ();
- }
-
-#ifdef ZMQ_HAS_RVALUE_REFS
- inline socket_t(socket_t&& rhs) : ptr(rhs.ptr)
- {
- rhs.ptr = NULL;
- }
- inline socket_t& operator=(socket_t&& rhs)
- {
- std::swap(ptr, rhs.ptr);
- return *this;
- }
-#endif
-
- inline ~socket_t ()
- {
- close();
- }
-
- inline operator void* ()
- {
- return ptr;
- }
-
- inline void close()
- {
- if(ptr == NULL)
- // already closed
- return ;
- int rc = zmq_close (ptr);
- ZMQ_ASSERT (rc == 0);
- ptr = 0 ;
- }
-
- inline void setsockopt (int option_, const void *optval_,
- size_t optvallen_)
- {
- int rc = zmq_setsockopt (ptr, option_, optval_, optvallen_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void getsockopt (int option_, void *optval_,
- size_t *optvallen_)
- {
- int rc = zmq_getsockopt (ptr, option_, optval_, optvallen_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void init_monitor(const char *addr_, int events)
- {
- int rc = zmq_socket_monitor(ptr, addr_, events);
- if (rc != 0)
- throw error_t ();
- monaddr = std::string(addr_);
- }
-
- inline void bind (const char *addr_)
- {
- int rc = zmq_bind (ptr, addr_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void unbind (const char *addr_)
- {
- int rc = zmq_unbind (ptr, addr_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void connect (const char *addr_)
- {
- int rc = zmq_connect (ptr, addr_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline void disconnect (const char *addr_)
- {
- int rc = zmq_disconnect (ptr, addr_);
- if (rc != 0)
- throw error_t ();
- }
-
- inline bool connected()
- {
- return(ptr != NULL);
- }
-
- inline void monitor (monitor_t* mon)
- {
- zmq_event_t event;
- int rc;
-
- assert(mon);
-
- void *s = zmq_socket (ctxptr, ZMQ_PAIR);
- assert (s);
-
- rc = zmq_connect (s, monaddr.c_str());
- assert (rc == 0);
- while (true) {
- zmq_msg_t msg;
- zmq_msg_init (&msg);
- rc = zmq_recvmsg (s, &msg, 0);
- if (rc == -1 && zmq_errno() == ETERM) break;
- assert (rc != -1);
- memcpy (&event, zmq_msg_data (&msg), sizeof (event));
-
- switch (event.event) {
- case ZMQ_EVENT_CONNECTED:
- mon->on_event_connected(event.data.connected.addr);
- break;
- case ZMQ_EVENT_CONNECT_DELAYED:
-
mon->on_event_connect_delayed(event.data.connect_delayed.addr);
- break;
- case ZMQ_EVENT_CONNECT_RETRIED:
-
mon->on_event_connect_retried(event.data.connect_retried.addr);
- break;
- case ZMQ_EVENT_LISTENING:
- mon->on_event_listening(event.data.listening.addr);
- break;
- case ZMQ_EVENT_BIND_FAILED:
-
mon->on_event_bind_failed(event.data.bind_failed.addr);
- break;
- case ZMQ_EVENT_ACCEPTED:
- mon->on_event_accepted(event.data.accepted.addr);
- break;
- case ZMQ_EVENT_ACCEPT_FAILED:
-
mon->on_event_accept_failed(event.data.accept_failed.addr);
- break;
- case ZMQ_EVENT_CLOSED:
- mon->on_event_closed(event.data.closed.addr);
- break;
- case ZMQ_EVENT_CLOSE_FAILED:
-
mon->on_event_close_failed(event.data.close_failed.addr);
- break;
- case ZMQ_EVENT_DISCONNECTED:
-
mon->on_event_disconnected(event.data.disconnected.addr);
- break;
- default:
- mon->on_event_unknown(event.event);
- break;
- }
- zmq_msg_close (&msg);
- }
- zmq_close (s);
- }
-
- inline size_t send (const void *buf_, size_t len_, int flags_ = 0)
- {
- int nbytes = zmq_send (ptr, buf_, len_, flags_);
- if (nbytes >= 0)
- return (size_t) nbytes;
- if (zmq_errno () == EAGAIN)
- return 0;
- throw error_t ();
- }
-
- inline bool send (message_t &msg_, int flags_ = 0)
- {
- int nbytes = zmq_msg_send (&(msg_.msg), ptr, flags_);
- if (nbytes >= 0)
- return true;
- if (zmq_errno () == EAGAIN)
- return false;
- throw error_t ();
- }
-
- inline size_t recv (void *buf_, size_t len_, int flags_ = 0)
- {
- int nbytes = zmq_recv (ptr, buf_, len_, flags_);
- if (nbytes >= 0)
- return (size_t) nbytes;
- if (zmq_errno () == EAGAIN)
- return 0;
- throw error_t ();
- }
-
- inline bool recv (message_t *msg_, int flags_ = 0)
- {
- int nbytes = zmq_msg_recv (&(msg_->msg), ptr, flags_);
- if (nbytes >= 0)
- return true;
- if (zmq_errno () == EAGAIN)
- return false;
- throw error_t ();
- }
-
- private:
- std::string monaddr;
- void *ptr;
- void *ctxptr;
-
- socket_t (const socket_t&) ZMQ_DELETED_FUNCTION;
- void operator = (const socket_t&) ZMQ_DELETED_FUNCTION;
- };
-
-}
-
-#endif
- [Commit-gnuradio] [gnuradio] branch master updated (432e3b7 -> 5974a3e), git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 04/46: zeromq: first cut at compiling lib/ directory,
git <=
- [Commit-gnuradio] [gnuradio] 17/46: wip, renaming and implementing rep_sink, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 11/46: zeromq: Rename "zmqblocks" to zeromq in examples, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 14/46: zeromq: renamed source_pushpull to pull_source, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 15/46: zeromq: renamed sink_pubsub to pub_sink, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 09/46: Fix callback function to work with multiple arguments and return None in case of error., git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 06/46: zeromq: converted SWIG to in-tree build, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 18/46: Add vlen, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 16/46: zeromq: removed feedback source, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 03/46: zeromq: Initial conversion of include/gnuradio/zeromq files, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 19/46: zeromq: renamed source_reqrep to req_source, git, 2014/05/16