summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blossom2010-09-29 12:19:38 -0700
committerEric Blossom2010-09-29 12:19:38 -0700
commitc7219d7aced26483ffe9c935fd1033dc3803891b (patch)
treed1bb8045799f35c71bdd495d39007cb5fee50d24
parentdf0cfb734e5acf698d286e03ba6abccc13d9c586 (diff)
downloadgnuradio-c7219d7aced26483ffe9c935fd1033dc3803891b.tar.gz
gnuradio-c7219d7aced26483ffe9c935fd1033dc3803891b.tar.bz2
gnuradio-c7219d7aced26483ffe9c935fd1033dc3803891b.zip
Change data_handler::operator() return type to bool to simplify things.
-rw-r--r--vrt/lib/data_handler.h16
-rw-r--r--vrt/lib/rx.cc10
-rw-r--r--vrt/lib/socket_rx_buffer.cc8
-rw-r--r--vrt/lib/socket_rx_buffer.h8
4 files changed, 17 insertions, 25 deletions
diff --git a/vrt/lib/data_handler.h b/vrt/lib/data_handler.h
index c041e48be..cbae9a714 100644
--- a/vrt/lib/data_handler.h
+++ b/vrt/lib/data_handler.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009 Free Software Foundation, Inc.
+ * Copyright 2008,2009,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -33,18 +33,12 @@ namespace vrt {
{
public:
- enum result_bits {
- DONE = 0x0002, //< do not call this object again
- };
-
- typedef int result; //< bitmask of result_bits
-
/*!
- * \param base points to the beginning of the data
- * \param len is the length in bytes of the data
- * \returns bitmask composed of DONE
+ * \param base points to the beginning of the data.
+ * \param len is the length of the data in bytes.
+ * \returns true if it wants to be called again, else false.
*/
- virtual result operator()(const void *base, size_t len) = 0;
+ virtual bool operator()(const void *base, size_t len) = 0;
virtual ~data_handler();
};
diff --git a/vrt/lib/rx.cc b/vrt/lib/rx.cc
index ca1be9fa4..f44077568 100644
--- a/vrt/lib/rx.cc
+++ b/vrt/lib/rx.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -80,13 +80,13 @@ namespace vrt {
~vrt_data_handler();
- result operator()(const void *base, size_t len);
+ bool operator()(const void *base, size_t len);
};
vrt_data_handler::~vrt_data_handler(){}
// N.B., There may be more than 1 VRT packet in a frame (usually IF-Context packets)
- data_handler::result
+ bool
vrt_data_handler::operator()(const void *base, size_t len)
{
const uint32_t *word_base = (const uint32_t *) base;
@@ -103,13 +103,13 @@ namespace vrt {
fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n");
print_words(stderr, 0, word_base, word_len);
}
- return 0;
+ return true;
}
want_more = (*d_handler)(payload, n32_bit_words, &hdr);
word_base += hdr.pkt_size();
word_len -= hdr.pkt_size();
}
- return !want_more ? data_handler::DONE : 0;
+ return want_more;
}
diff --git a/vrt/lib/socket_rx_buffer.cc b/vrt/lib/socket_rx_buffer.cc
index 93d3e097d..87c36375c 100644
--- a/vrt/lib/socket_rx_buffer.cc
+++ b/vrt/lib/socket_rx_buffer.cc
@@ -126,8 +126,8 @@ namespace vrt {
// Got first packet. Call handler
- data_handler::result r = (*f)(buf, rr);
- if (r & data_handler::DONE)
+ bool want_more = (*f)(buf, rr);
+ if (!want_more)
return EB_OK;
// Now do as many as we can without blocking
@@ -141,8 +141,8 @@ namespace vrt {
return EB_ERROR;
}
- r = (*f)(buf, rr);
- if (r & data_handler::DONE)
+ want_more = (*f)(buf, rr);
+ if (!want_more)
break;
}
return EB_OK;
diff --git a/vrt/lib/socket_rx_buffer.h b/vrt/lib/socket_rx_buffer.h
index 36c18c1a5..146fe97fe 100644
--- a/vrt/lib/socket_rx_buffer.h
+++ b/vrt/lib/socket_rx_buffer.h
@@ -79,11 +79,9 @@ namespace vrt {
* invoked.
*
* \p f will be called on each frame that is available.
- * \p f returns a bit mask with one of the following set or cleared:
- *
- * data_handler::DONE - return from rx_frames now even though more frames
- * might be available; otherwise continue if more
- * frames are ready.
+ * \p f returns a bool. If false, return from rx_frames now even
+ * though more frames may be available; if true, continue if
+ * more frames are ready.
*
* \returns EB_OK if at least one frame was received
* \returns EB_WOULD_BLOCK if \p timeout is 0 and the call would have blocked