[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/46: zeromq: cleanup and reformatting
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/46: zeromq: cleanup and reformatting |
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 3daa042f0f899a05d722265fd400f1b5775fa9d3
Author: Johnathan Corgan <address@hidden>
Date: Sun Dec 8 13:12:58 2013 -0800
zeromq: cleanup and reformatting
---
gr-zeromq/include/gnuradio/zeromq/sink_pubsub.h | 8 +-
gr-zeromq/include/gnuradio/zeromq/sink_pushpull.h | 8 +-
gr-zeromq/include/gnuradio/zeromq/sink_reqrep.h | 12 +--
.../include/gnuradio/zeromq/sink_reqrep_nopoll.h | 12 +--
.../include/gnuradio/zeromq/source_pushpull.h | 8 +-
.../gnuradio/zeromq/source_pushpull_feedback.h | 8 +-
gr-zeromq/include/gnuradio/zeromq/source_reqrep.h | 6 +-
.../include/gnuradio/zeromq/source_reqrep_nopoll.h | 8 +-
gr-zeromq/lib/sink_pubsub_impl.cc | 20 ++---
gr-zeromq/lib/sink_pubsub_impl.h | 16 ++--
gr-zeromq/lib/sink_pushpull_impl.cc | 41 +++++-----
gr-zeromq/lib/sink_pushpull_impl.h | 29 ++++----
gr-zeromq/lib/sink_reqrep_impl.cc | 87 +++++++++++-----------
gr-zeromq/lib/sink_reqrep_impl.h | 19 +++--
gr-zeromq/lib/sink_reqrep_nopoll_impl.cc | 73 ++++++++----------
gr-zeromq/lib/sink_reqrep_nopoll_impl.h | 27 ++++---
gr-zeromq/lib/source_pushpull_feedback_impl.cc | 75 +++++++++----------
gr-zeromq/lib/source_pushpull_feedback_impl.h | 26 +++----
gr-zeromq/lib/source_pushpull_impl.cc | 68 ++++++++---------
gr-zeromq/lib/source_pushpull_impl.h | 23 +++---
gr-zeromq/lib/source_reqrep_impl.cc | 86 ++++++++++-----------
gr-zeromq/lib/source_reqrep_impl.h | 19 +++--
gr-zeromq/lib/source_reqrep_nopoll_impl.cc | 60 +++++++--------
gr-zeromq/lib/source_reqrep_nopoll_impl.h | 35 +++++----
24 files changed, 368 insertions(+), 406 deletions(-)
diff --git a/gr-zeromq/include/gnuradio/zeromq/sink_pubsub.h
b/gr-zeromq/include/gnuradio/zeromq/sink_pubsub.h
index bba8836..9f9e603 100644
--- a/gr-zeromq/include/gnuradio/zeromq/sink_pubsub.h
+++ b/gr-zeromq/include/gnuradio/zeromq/sink_pubsub.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/include/gnuradio/zeromq/sink_pushpull.h
b/gr-zeromq/include/gnuradio/zeromq/sink_pushpull.h
index 7c6434f..a997a17 100644
--- a/gr-zeromq/include/gnuradio/zeromq/sink_pushpull.h
+++ b/gr-zeromq/include/gnuradio/zeromq/sink_pushpull.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/include/gnuradio/zeromq/sink_reqrep.h
b/gr-zeromq/include/gnuradio/zeromq/sink_reqrep.h
index bcecc8b..0c5377f 100644
--- a/gr-zeromq/include/gnuradio/zeromq/sink_reqrep.h
+++ b/gr-zeromq/include/gnuradio/zeromq/sink_reqrep.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -38,7 +38,7 @@ namespace gr {
{
public:
typedef boost::shared_ptr<sink_reqrep> sptr;
-
+
/*!
* \brief Return a shared_ptr to a new instance of zeromq::sink_reqrep.
*
@@ -49,7 +49,7 @@ namespace gr {
*/
static sptr make(size_t itemsize, char *address);
};
-
+
} // namespace zeromq
} // namespace gr
diff --git a/gr-zeromq/include/gnuradio/zeromq/sink_reqrep_nopoll.h
b/gr-zeromq/include/gnuradio/zeromq/sink_reqrep_nopoll.h
index 943e784..afb2085 100644
--- a/gr-zeromq/include/gnuradio/zeromq/sink_reqrep_nopoll.h
+++ b/gr-zeromq/include/gnuradio/zeromq/sink_reqrep_nopoll.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -38,7 +38,7 @@ namespace gr {
{
public:
typedef boost::shared_ptr<sink_reqrep_nopoll> sptr;
-
+
/*!
* \brief Return a shared_ptr to a new instance of
zeromq::sink_reqrep_nopoll.
*
@@ -49,7 +49,7 @@ namespace gr {
*/
static sptr make(size_t itemsize, char *address);
};
-
+
} // namespace zeromq
} // namespace gr
diff --git a/gr-zeromq/include/gnuradio/zeromq/source_pushpull.h
b/gr-zeromq/include/gnuradio/zeromq/source_pushpull.h
index 076d7a0..32f6bd9 100644
--- a/gr-zeromq/include/gnuradio/zeromq/source_pushpull.h
+++ b/gr-zeromq/include/gnuradio/zeromq/source_pushpull.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/include/gnuradio/zeromq/source_pushpull_feedback.h
b/gr-zeromq/include/gnuradio/zeromq/source_pushpull_feedback.h
index 2bcfe7b..765bab0 100644
--- a/gr-zeromq/include/gnuradio/zeromq/source_pushpull_feedback.h
+++ b/gr-zeromq/include/gnuradio/zeromq/source_pushpull_feedback.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/include/gnuradio/zeromq/source_reqrep.h
b/gr-zeromq/include/gnuradio/zeromq/source_reqrep.h
index a6c3fe6..f0b9c3a 100644
--- a/gr-zeromq/include/gnuradio/zeromq/source_reqrep.h
+++ b/gr-zeromq/include/gnuradio/zeromq/source_reqrep.h
@@ -1,5 +1,5 @@
/* -*- c++ -*- */
-/*
+/*
* Copyright 2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio.
@@ -8,12 +8,12 @@
* 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.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/include/gnuradio/zeromq/source_reqrep_nopoll.h
b/gr-zeromq/include/gnuradio/zeromq/source_reqrep_nopoll.h
index 21da57e..124a49d 100644
--- a/gr-zeromq/include/gnuradio/zeromq/source_reqrep_nopoll.h
+++ b/gr-zeromq/include/gnuradio/zeromq/source_reqrep_nopoll.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
diff --git a/gr-zeromq/lib/sink_pubsub_impl.cc
b/gr-zeromq/lib/sink_pubsub_impl.cc
index 3c6fdd7..0d76d99 100644
--- a/gr-zeromq/lib/sink_pubsub_impl.cc
+++ b/gr-zeromq/lib/sink_pubsub_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -29,14 +29,14 @@
namespace gr {
namespace zeromq {
-
+
sink_pubsub::sptr
sink_pubsub::make(size_t itemsize, char *address)
{
return gnuradio::get_initial_sptr
(new sink_pubsub_impl(itemsize, address));
}
-
+
sink_pubsub_impl::sink_pubsub_impl(size_t itemsize, char *address)
: gr::sync_block("sink_pubsub",
gr::io_signature::make(1, 1, itemsize),
@@ -47,13 +47,13 @@ namespace gr {
d_socket = new zmq::socket_t(*d_context, ZMQ_PUB);
d_socket->bind(address);
}
-
+
sink_pubsub_impl::~sink_pubsub_impl()
{
delete d_socket;
delete d_context;
}
-
+
int
sink_pubsub_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -65,9 +65,9 @@ namespace gr {
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 zeromq */
} /* namespace gr */
diff --git a/gr-zeromq/lib/sink_pubsub_impl.h b/gr-zeromq/lib/sink_pubsub_impl.h
index 5511b99..0e55c79 100644
--- a/gr-zeromq/lib/sink_pubsub_impl.h
+++ b/gr-zeromq/lib/sink_pubsub_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -35,16 +35,16 @@ namespace gr {
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 zeromq
} // namespace gr
diff --git a/gr-zeromq/lib/sink_pushpull_impl.cc
b/gr-zeromq/lib/sink_pushpull_impl.cc
index d77dc89..dec03b7 100644
--- a/gr-zeromq/lib/sink_pushpull_impl.cc
+++ b/gr-zeromq/lib/sink_pushpull_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -37,28 +37,22 @@ namespace gr {
(new sink_pushpull_impl(itemsize, address));
}
- /*
- * The private constructor
- */
sink_pushpull_impl::sink_pushpull_impl(size_t itemsize, char *address)
: gr::sync_block("sink_pushpull",
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_PUSH);
- d_socket->bind (address);
- std::cout << "sink_pushpull on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_PUSH);
+ d_socket->bind (address);
+ std::cout << "sink_pushpull on " << address << std::endl;
}
- /*
- * Our virtual destructor.
- */
sink_pushpull_impl::~sink_pushpull_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete(d_socket);
+ delete(d_context);
}
int
@@ -66,16 +60,15 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const char *in = (const char *) input_items[0];
+ 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);
+ // 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;
+ return noutput_items;
}
} /* namespace zeromq */
} /* namespace gr */
-
diff --git a/gr-zeromq/lib/sink_pushpull_impl.h
b/gr-zeromq/lib/sink_pushpull_impl.h
index f88c0e9..d8a4d26 100644
--- a/gr-zeromq/lib/sink_pushpull_impl.h
+++ b/gr-zeromq/lib/sink_pushpull_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,21 +32,20 @@ namespace gr {
class sink_pushpull_impl : public sink_pushpull
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
- public:
- sink_pushpull_impl(size_t itemsize, char *address);
- ~sink_pushpull_impl();
+ public:
+ sink_pushpull_impl(size_t itemsize, char *address);
+ ~sink_pushpull_impl();
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
} // 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 7c61872..6c5c2c4 100644
--- a/gr-zeromq/lib/sink_reqrep_impl.cc
+++ b/gr-zeromq/lib/sink_reqrep_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -37,61 +37,58 @@ namespace gr {
(new sink_reqrep_impl(itemsize, address));
}
- /*
- * The private constructor
- */
sink_reqrep_impl::sink_reqrep_impl(size_t itemsize, char *address)
: gr::sync_block("sink_reqrep",
- gr::io_signature::make(1, 1, itemsize),
- gr::io_signature::make(0, 0, 0)),
+ 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_REP);
- d_socket->bind (address);
- std::cout << "sink_reqrep on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_REP);
+ d_socket->bind (address);
}
- /*
- * Our virtual destructor.
- */
sink_reqrep_impl::~sink_reqrep_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
int
sink_reqrep_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- const char *in = (const char *) input_items[0];
+ const char *in = (const char *) input_items[0];
- zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
- zmq::poll (&items[0], 1, 1000);
- // If we got a reply, process
- if (items[0].revents & ZMQ_POLLIN) {
- // receive data request
- zmq::message_t request;
- d_socket->recv(&request);
- int req_output_items = *(static_cast<int*>(request.data()));
+ zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
+ zmq::poll (&items[0], 1, 1000);
- // create message copy and send
- if (noutput_items < req_output_items) {
- zmq::message_t msg(d_itemsize*noutput_items);
- memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
- d_socket->send(msg);
- return noutput_items;
- } else {
- zmq::message_t msg(d_itemsize*req_output_items);
- memcpy((void *)msg.data(), in, d_itemsize*req_output_items);
- d_socket->send(msg);
- return req_output_items;
- }
- }
- return 0;
+ // If we got a reply, process
+ if (items[0].revents & ZMQ_POLLIN) {
+ // receive data request
+ zmq::message_t request;
+ d_socket->recv(&request);
+ int req_output_items = *(static_cast<int*>(request.data()));
+
+ // create message copy and send
+ if (noutput_items < req_output_items) {
+ zmq::message_t msg(d_itemsize*noutput_items);
+ memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+ d_socket->send(msg);
+
+ return noutput_items;
+ }
+ else {
+ zmq::message_t msg(d_itemsize*req_output_items);
+ memcpy((void *)msg.data(), in, d_itemsize*req_output_items);
+ d_socket->send(msg);
+
+ return req_output_items;
+ }
+ }
+
+ return 0;
}
} /* namespace zeromq */
} /* namespace gr */
-
diff --git a/gr-zeromq/lib/sink_reqrep_impl.h b/gr-zeromq/lib/sink_reqrep_impl.h
index 968bdb7..ec700f0 100644
--- a/gr-zeromq/lib/sink_reqrep_impl.h
+++ b/gr-zeromq/lib/sink_reqrep_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,11 +32,11 @@ namespace gr {
class sink_reqrep_impl : public sink_reqrep
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
- public:
+ public:
sink_reqrep_impl(size_t itemsize, char *address);
~sink_reqrep_impl();
@@ -49,4 +49,3 @@ namespace gr {
} // 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 2b901c2..767893d 100644
--- a/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
+++ b/gr-zeromq/lib/sink_reqrep_nopoll_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -26,8 +26,6 @@
#include <gnuradio/io_signature.h>
#include "sink_reqrep_nopoll_impl.h"
-#include <cstring>
-#include <iostream>
namespace gr {
namespace zeromq {
@@ -39,55 +37,50 @@ namespace gr {
(new sink_reqrep_nopoll_impl(itemsize, address));
}
- /*
- * The private constructor
- */
sink_reqrep_nopoll_impl::sink_reqrep_nopoll_impl(size_t itemsize, char
*address)
: gr::sync_block("sink_reqrep_nopoll",
- gr::io_signature::make(1, 1, itemsize),
- gr::io_signature::make(0, 0, 0)),
+ 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_REP);
- d_socket->bind (address);
- std::cout << "sink_reqrep_nopoll on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_REP);
+ d_socket->bind (address);
}
- /*
- * Our virtual destructor.
- */
sink_reqrep_nopoll_impl::~sink_reqrep_nopoll_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
int
sink_reqrep_nopoll_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- const char *in = (const char *) input_items[0];
+ const char *in = (const char *) input_items[0];
- zmq::message_t request;
- d_socket->recv(&request);
- int req_output_items = *(static_cast<int*>(request.data()));
+ zmq::message_t request;
+ d_socket->recv(&request);
+ int req_output_items = *(static_cast<int*>(request.data()));
- // create message copy and send
- if (noutput_items < req_output_items) {
- zmq::message_t msg(d_itemsize*noutput_items);
- memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
- d_socket->send(msg);
- return noutput_items;
- } else {
- zmq::message_t msg(d_itemsize*req_output_items);
- memcpy((void *)msg.data(), in, d_itemsize*req_output_items);
- d_socket->send(msg);
- return req_output_items;
- }
+ // create message copy and send
+ if (noutput_items < req_output_items) {
+ zmq::message_t msg(d_itemsize*noutput_items);
+ memcpy((void *)msg.data(), in, d_itemsize*noutput_items);
+ d_socket->send(msg);
+
+ return noutput_items;
+ }
+ else {
+ zmq::message_t msg(d_itemsize*req_output_items);
+ memcpy((void *)msg.data(), in, d_itemsize*req_output_items);
+ d_socket->send(msg);
+
+ return req_output_items;
+ }
}
} /* 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 c029ff4..66ba934 100644
--- a/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
+++ b/gr-zeromq/lib/sink_reqrep_nopoll_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,21 +32,20 @@ namespace gr {
class sink_reqrep_nopoll_impl : public sink_reqrep_nopoll
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
public:
- sink_reqrep_nopoll_impl(size_t itemsize, char *address);
- ~sink_reqrep_nopoll_impl();
+ sink_reqrep_nopoll_impl(size_t itemsize, char *address);
+ ~sink_reqrep_nopoll_impl();
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
} // 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 535ff1e..f1f66e9 100644
--- a/gr-zeromq/lib/source_pushpull_feedback_impl.cc
+++ b/gr-zeromq/lib/source_pushpull_feedback_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -37,28 +37,22 @@ namespace gr {
(new source_pushpull_feedback_impl(itemsize, address));
}
- /*
- * The private constructor
- */
source_pushpull_feedback_impl::source_pushpull_feedback_impl(size_t
itemsize, char *address)
: gr::sync_block("source_pushpull_feedback",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, itemsize)),
d_itemsize(itemsize), d_first_work(true)
{
- d_context = new zmq::context_t(1);
- d_socket = new zmq::socket_t(*d_context, ZMQ_PULL);
- d_socket->connect (address);
- std::cout << "source_pushpull on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_PULL);
+ d_socket->connect (address);
+ std::cout << "source_pushpull on " << address << std::endl;
}
- /*
- * Our virtual destructor.
- */
source_pushpull_feedback_impl::~source_pushpull_feedback_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete(d_socket);
+ delete(d_context);
}
int
@@ -66,31 +60,36 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- char *out = (char*)output_items[0];
+ char *out = (char*)output_items[0];
- zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
- zmq::poll (&items[0], 1, 1000);
- // If we got a reply, process
- if (items[0].revents & ZMQ_POLLIN) {
+ zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
+ zmq::poll (&items[0], 1, 1000);
- // Receive data
- zmq::message_t msg;
- d_socket->recv(&msg);
+ // If we got a reply, process
+ if (items[0].revents & ZMQ_POLLIN) {
- // Copy to ouput buffer and return
- if (msg.size() >= d_itemsize*noutput_items) {
- memcpy(out, (void *)msg.data(), d_itemsize*noutput_items);
- return noutput_items;
- } else {
- memcpy(out, (void *)msg.data(), msg.size());
- return msg.size()/d_itemsize;
- }
- } else {
- memset(out, 0, noutput_items);
- return noutput_items;
- }
+ // Receive data
+ zmq::message_t msg;
+ d_socket->recv(&msg);
+
+ // Copy to ouput buffer and return
+ if (msg.size() >= d_itemsize*noutput_items) {
+ memcpy(out, (void *)msg.data(), d_itemsize*noutput_items);
+
+ return noutput_items;
+ }
+ else {
+ memcpy(out, (void *)msg.data(), msg.size());
+
+ return msg.size()/d_itemsize;
+ }
+ }
+ else {
+ memset(out, 0, noutput_items);
+
+ return noutput_items;
+ }
}
} /* 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 d4b22f5..3a69bee 100644
--- a/gr-zeromq/lib/source_pushpull_feedback_impl.h
+++ b/gr-zeromq/lib/source_pushpull_feedback_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,22 +32,20 @@ namespace gr {
class source_pushpull_feedback_impl : public source_pushpull_feedback
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
- bool d_first_work;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
+ bool d_first_work;
- public:
- source_pushpull_feedback_impl(size_t itemsize, char *address);
- ~source_pushpull_feedback_impl();
+ public:
+ source_pushpull_feedback_impl(size_t itemsize, char *address);
+ ~source_pushpull_feedback_impl();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
-
} // 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 1912c63..6a0fe2b 100644
--- a/gr-zeromq/lib/source_pushpull_impl.cc
+++ b/gr-zeromq/lib/source_pushpull_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -37,19 +37,15 @@ namespace gr {
(new source_pushpull_impl(itemsize, address));
}
- /*
- * The private constructor
- */
source_pushpull_impl::source_pushpull_impl(size_t itemsize, char *address)
: gr::sync_block("source_pushpull",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, itemsize)),
d_itemsize(itemsize)
{
- d_context = new zmq::context_t(1);
- d_socket = new zmq::socket_t(*d_context, ZMQ_PULL);
- d_socket->connect (address);
- std::cout << "source_pushpull on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_PULL);
+ d_socket->connect (address);
}
/*
@@ -57,8 +53,8 @@ namespace gr {
*/
source_pushpull_impl::~source_pushpull_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
int
@@ -66,30 +62,34 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- char *out = (char*)output_items[0];
+ char *out = (char*)output_items[0];
+
+ zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
+ zmq::poll (&items[0], 1, 1000);
- zmq::pollitem_t items[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
- zmq::poll (&items[0], 1, 1000);
- // If we got a reply, process
- if (items[0].revents & ZMQ_POLLIN) {
+ // If we got a reply, process
+ if (items[0].revents & ZMQ_POLLIN) {
- // Receive data
- zmq::message_t msg;
- d_socket->recv(&msg);
+ // Receive data
+ zmq::message_t msg;
+ d_socket->recv(&msg);
- // Copy to ouput buffer and return
- if (msg.size() >= d_itemsize*noutput_items) {
- memcpy(out, (void *)msg.data(), d_itemsize*noutput_items);
- return noutput_items;
- } else {
- memcpy(out, (void *)msg.data(), msg.size());
- return msg.size()/d_itemsize;
- }
- } else {
- return 0;
- }
+ // Copy to ouput buffer and return
+ if (msg.size() >= d_itemsize*noutput_items) {
+ memcpy(out, (void *)msg.data(), d_itemsize*noutput_items);
+
+ return noutput_items;
+ }
+ else {
+ memcpy(out, (void *)msg.data(), msg.size());
+
+ return msg.size()/d_itemsize;
+ }
+ }
+ else {
+ return 0;
+ }
}
} /* namespace zeromq */
} /* namespace gr */
-
diff --git a/gr-zeromq/lib/source_pushpull_impl.h
b/gr-zeromq/lib/source_pushpull_impl.h
index ed621cf..fdb60de 100644
--- a/gr-zeromq/lib/source_pushpull_impl.h
+++ b/gr-zeromq/lib/source_pushpull_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,13 +32,13 @@ namespace gr {
class source_pushpull_impl : public source_pushpull
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
- public:
- source_pushpull_impl(size_t itemsize, char *address);
- ~source_pushpull_impl();
+ public:
+ source_pushpull_impl(size_t itemsize, char *address);
+ ~source_pushpull_impl();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -49,4 +49,3 @@ namespace gr {
} // 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 337c221..1674955 100644
--- a/gr-zeromq/lib/source_reqrep_impl.cc
+++ b/gr-zeromq/lib/source_reqrep_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -37,62 +37,58 @@ namespace gr {
(new source_reqrep_impl(itemsize, address));
}
- /*
- * The private constructor
- */
source_reqrep_impl::source_reqrep_impl(size_t itemsize, char *address)
: gr::sync_block("source_reqrep",
- gr::io_signature::make(0, 0, 0),
- gr::io_signature::make(1, 1, itemsize)),
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(1, 1, itemsize)),
d_itemsize(itemsize)
{
- d_context = new zmq::context_t(1);
- d_socket = new zmq::socket_t(*d_context, ZMQ_REQ);
- d_socket->connect (address);
- std::cout << "source_reqrep on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_REQ);
+ d_socket->connect (address);
}
-
- /*
- * Our virtual destructor.
- */
source_reqrep_impl::~source_reqrep_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
int
source_reqrep_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- char *out = (char*)output_items[0];
+ char *out = (char*)output_items[0];
+
+ zmq::pollitem_t itemsout[] = { { *d_socket, 0, ZMQ_POLLOUT, 0 } };
+ zmq::poll (&itemsout[0], 1, 0);
+
+ // If we got a reply, process
+ if (itemsout[0].revents & ZMQ_POLLOUT) {
+ // Request data, FIXME non portable
+ zmq::message_t request(sizeof(int));
+ memcpy ((void *) request.data (), &noutput_items, sizeof(int));
+ d_socket->send(request);
+ }
+
+ zmq::pollitem_t itemsin[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
+ zmq::poll (&itemsin[0], 1, 0);
- zmq::pollitem_t itemsout[] = { { *d_socket, 0, ZMQ_POLLOUT, 0 } };
- zmq::poll (&itemsout[0], 1, 0);
- // If we got a reply, process
- if (itemsout[0].revents & ZMQ_POLLOUT) {
- // Request data, FIXME non portable
- zmq::message_t request(sizeof(int));
- memcpy ((void *) request.data (), &noutput_items, sizeof(int));
- d_socket->send(request);
- }
- zmq::pollitem_t itemsin[] = { { *d_socket, 0, ZMQ_POLLIN, 0 } };
- zmq::poll (&itemsin[0], 1, 0);
- // If we got a reply, process
- if (itemsin[0].revents & ZMQ_POLLIN) {
- // Receive data
- zmq::message_t reply;
- d_socket->recv(&reply);
+ // If we got a reply, process
+ if (itemsin[0].revents & ZMQ_POLLIN) {
+ // Receive data
+ zmq::message_t reply;
+ d_socket->recv(&reply);
- // Copy to ouput buffer and return
- memcpy(out, (void *)reply.data(), reply.size());
- return reply.size()/d_itemsize;
- }
- return 0;
+ // Copy to ouput buffer and return
+ memcpy(out, (void *)reply.data(), reply.size());
+
+ return reply.size()/d_itemsize;
+ }
+
+ return 0;
}
} /* namespace zeromq */
} /* namespace gr */
-
diff --git a/gr-zeromq/lib/source_reqrep_impl.h
b/gr-zeromq/lib/source_reqrep_impl.h
index 45a3e63..a1e3bc6 100644
--- a/gr-zeromq/lib/source_reqrep_impl.h
+++ b/gr-zeromq/lib/source_reqrep_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -32,11 +32,11 @@ namespace gr {
class source_reqrep_impl : public source_reqrep
{
private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
- public:
+ public:
source_reqrep_impl(size_t itemsize, char *address);
~source_reqrep_impl();
@@ -49,4 +49,3 @@ namespace gr {
} // 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 a713351..2af72a1 100644
--- a/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
+++ b/gr-zeromq/lib/source_reqrep_nopoll_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -26,7 +26,6 @@
#include <gnuradio/io_signature.h>
#include "source_reqrep_nopoll_impl.h"
-#include <cstring>
namespace gr {
namespace zeromq {
@@ -38,51 +37,44 @@ namespace gr {
(new source_reqrep_nopoll_impl(itemsize, address));
}
- /*
- * The private constructor
- */
source_reqrep_nopoll_impl::source_reqrep_nopoll_impl(size_t itemsize, char
*address)
: gr::sync_block("source_reqrep_nopoll",
- gr::io_signature::make(0, 0, 0),
- gr::io_signature::make(1, 1, itemsize)),
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(1, 1, itemsize)),
d_itemsize(itemsize)
{
- d_context = new zmq::context_t(1);
- d_socket = new zmq::socket_t(*d_context, ZMQ_REQ);
- d_socket->connect (address);
- std::cout << "source_reqrep_nopoll on " << address << std::endl;
+ d_context = new zmq::context_t(1);
+ d_socket = new zmq::socket_t(*d_context, ZMQ_REQ);
+ d_socket->connect (address);
}
- /*
- * Our virtual destructor.
- */
source_reqrep_nopoll_impl::~source_reqrep_nopoll_impl()
{
- delete(d_socket);
- delete(d_context);
+ delete d_socket;
+ delete d_context;
}
int
source_reqrep_nopoll_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- char *out = (char*)output_items[0];
+ char *out = (char*)output_items[0];
- // Request data, FIXME non portable
- zmq::message_t request(sizeof(int));
- memcpy ((void *) request.data (), &noutput_items, sizeof(int));
- d_socket->send(request);
+ // Request data, FIXME non portable
+ zmq::message_t request(sizeof(int));
+ memcpy ((void *) request.data (), &noutput_items, sizeof(int));
+ d_socket->send(request);
- // Receive data
- zmq::message_t reply;
- d_socket->recv(&reply);
+ // Receive data
+ zmq::message_t reply;
+ d_socket->recv(&reply);
- // Copy to ouput buffer and return
- memcpy(out, (void *)reply.data(), reply.size());
- return reply.size()/d_itemsize;
+ // Copy to ouput buffer and return
+ memcpy(out, (void *)reply.data(), reply.size());
+
+ return reply.size()/d_itemsize;
}
} /* 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 305f8d8..744a01f 100644
--- a/gr-zeromq/lib/source_reqrep_nopoll_impl.h
+++ b/gr-zeromq/lib/source_reqrep_nopoll_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This software 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 this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -31,22 +31,21 @@ namespace gr {
class source_reqrep_nopoll_impl : public source_reqrep_nopoll
{
- private:
- size_t d_itemsize;
- zmq::context_t *d_context;
- zmq::socket_t *d_socket;
-
- public:
- source_reqrep_nopoll_impl(size_t itemsize, char *address);
- ~source_reqrep_nopoll_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ private:
+ size_t d_itemsize;
+ zmq::context_t *d_context;
+ zmq::socket_t *d_socket;
+
+ public:
+ source_reqrep_nopoll_impl(size_t itemsize, char *address);
+ ~source_reqrep_nopoll_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
} // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZMQBLOCKS_SOURCE_REQREP_NOPOLL_IMPL_H */
-
- [Commit-gnuradio] [gnuradio] 18/46: Add vlen, (continued)
- [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
- [Commit-gnuradio] [gnuradio] 20/46: zeromq: remove nopoll req/rep blocks, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 21/46: zeromq: cleanup copyright, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 13/46: zeromq: renamed sink_pushpull push_sink, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 08/46: Fix ZeroMQ cmake module., git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 10/46: zeromq: Fix typo in CMakeLists to link against libzmq, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 07/46: zeromq: first try at enabling Python. Segfaults in SWIG code., git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 05/46: zeromq: cleanup and reformatting,
git <=
- [Commit-gnuradio] [gnuradio] 12/46: zeromq: fix import in example, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 30/46: zeromq: set ZMQ_LINGER to 0 for all blocks, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 22/46: zeromq: rename include guards, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 33/46: zeromq: Timeout needs to be in milliseconds for zmq 3.0, close sockets correctly, cleanup, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 24/46: zeromq: Fix doxygen and memcpy for vlen, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 28/46: zeromq: removed stray debug code and cleanup, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 32/46: zeromq: Add parameters to xml, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 27/46: Merge remote-tracking branch 'iohannez/vlen' into zeromq, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 34/46: zeromq: Remove ZMQ_NOBLOCK as we are using polling, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 29/46: zeromq: cleanup QA code, still needs have ZMQ_LINGER set to zero, git, 2014/05/16