summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blossom2010-09-25 23:23:17 -0700
committerEric Blossom2010-09-27 14:56:43 -0700
commit3339d8dc40a90986f33ea095baa0a861fed32bb6 (patch)
tree4e6a76ab7cfcf56c58face855f40f26be3d2ca14
parent503931d4e719bbfd74e67d1cbd4a91b9cc812144 (diff)
downloadgnuradio-3339d8dc40a90986f33ea095baa0a861fed32bb6.tar.gz
gnuradio-3339d8dc40a90986f33ea095baa0a861fed32bb6.tar.bz2
gnuradio-3339d8dc40a90986f33ea095baa0a861fed32bb6.zip
Add ostream output for expanded_header.
-rw-r--r--vrt/include/vrt/expanded_header.h9
-rw-r--r--vrt/include/vrt/expanded_if_context_section.h16
-rw-r--r--vrt/include/vrt/types.h2
-rw-r--r--vrt/lib/expanded_header.cc42
4 files changed, 63 insertions, 6 deletions
diff --git a/vrt/include/vrt/expanded_header.h b/vrt/include/vrt/expanded_header.h
index 299faa01e..8ff750859 100644
--- a/vrt/include/vrt/expanded_header.h
+++ b/vrt/include/vrt/expanded_header.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stddef.h>
#include <vrt/bits.h>
+#include <iosfwd>
namespace vrt {
@@ -101,6 +102,12 @@ namespace vrt {
const uint32_t **payload, // out
size_t *n32_bit_words_payload); // out
+ /*!
+ * Write a written representation to the given \p port.
+ */
+ void write(std::ostream &port) const;
+
+
private:
static unsigned char s_if_data[16];
static unsigned char s_ext_data[16];
@@ -110,6 +117,8 @@ namespace vrt {
};
+ std::ostream& operator<<(std::ostream &os, const expanded_header &obj);
+
}; // vrt
diff --git a/vrt/include/vrt/expanded_if_context_section.h b/vrt/include/vrt/expanded_if_context_section.h
index 57adb581e..ada88e3b9 100644
--- a/vrt/include/vrt/expanded_if_context_section.h
+++ b/vrt/include/vrt/expanded_if_context_section.h
@@ -21,9 +21,6 @@
#ifndef INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H
#define INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H
-#include <string>
-#include <vector>
-
/*!
* Expanded (unpacked) version of Context Section, defined in VRT section 7.1.5
*/
@@ -31,7 +28,10 @@
#include <stdint.h>
#include <stddef.h>
#include <vrt/bits.h>
-#include <vrt/types.h>
+#include <string>
+#include <vector>
+#include <iosfwd>
+
namespace vrt {
@@ -103,8 +103,16 @@ namespace vrt {
static bool unpack(const uint32_t *context_section, // in
size_t n32_bit_words, // in
expanded_if_context_section *cntx); // out
+
+ /*!
+ * Write a written representation to the given \p port.
+ */
+ void write(std::ostream &port);
+
};
+ std::ostream& operator<<(std::ostream &os, const expanded_if_context_section &obj);
+
}; // namespace vrt
#endif /* INCLUDED_VRT_EXPANDED_IF_CONTEXT_SECTION_H */
diff --git a/vrt/include/vrt/types.h b/vrt/include/vrt/types.h
index 2b2920266..606d7c9fe 100644
--- a/vrt/include/vrt/types.h
+++ b/vrt/include/vrt/types.h
@@ -25,7 +25,7 @@ extern "C" {
#include <stdint.h>
/* macros for dealing with fixed point numbers */
-#define _FXPT_C(_type, _x, _rp) ((_type)((_x)*(1ll << _rp)))
+#define _FXPT_C(_type, _x, _rp) ((_type)((_x)*(1LL << _rp)))
#define _FXPT_TO_INT(_x, _one) (((_x) + ((_one)/2))/(_one))
#define _FXPT_TO_DOUBLE(_x, _one) ((double)(_x) * (1.0/(_one)))
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index fc4bfc1c2..1fddac8cb 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -24,7 +24,11 @@
#endif
#include <vrt/expanded_header.h>
#include <gruel/inet.h>
-//#include <stdio.h>
+#include <boost/format.hpp>
+
+using boost::format;
+using boost::io::group;
+
namespace vrt {
@@ -132,5 +136,41 @@ namespace vrt {
return true;
}
+ std::string
+ pkt_type_name(const vrt::expanded_header *hdr)
+ {
+ if (hdr->if_data_p())
+ return "IF-Data";
+ if (hdr->ext_data_p())
+ return "Ext-Data";
+ if (hdr->if_context_p())
+ return "IF-Context";
+ if (hdr->ext_context_p())
+ return "Ext-Context";
+ else
+ return "<unknown pkt type>";
+ }
+
+ void
+ expanded_header::write(std::ostream &port) const
+ {
+ port << format("%s:\n") % pkt_type_name(this);
+ if (1)
+ port << format(" header: 0x%08x\n") % header;
+ if (stream_id_p())
+ port << format(" stream_id: %#10x\n") % stream_id;
+ if (class_id_p())
+ port << format(" class_id: 0x%016llx\n") % class_id;
+ if (integer_secs_p())
+ port << format(" int secs: %10d\n") % integer_secs;
+ if (fractional_secs_p())
+ port << format(" frac secs: %10d\n") % fractional_secs;
+ }
+
+ std::ostream& operator<<(std::ostream &os, const expanded_header &obj)
+ {
+ obj.write(os);
+ return os;
+ }
}; // vrt