Merge branch 'maint'
[debian/gnuradio] / gnuradio-core / src / lib / io / gr_message_source.cc
index 4ce0e4292cf2655db2afc6d6985ec5fbd38cf32b..0fa24f2f9c758864e4defbdb5da29e2476560cdc 100644 (file)
@@ -1,12 +1,12 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2005 Free Software Foundation, Inc.
+ * Copyright 2005,2010 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 2, or (at your option)
+ * 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,
@@ -32,6 +32,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdexcept>
+#include <string.h>
 
 
 // public constructor that returns a shared_ptr
 gr_message_source_sptr
 gr_make_message_source(size_t itemsize, int msgq_limit)
 {
-  return gr_message_source_sptr(new gr_message_source(itemsize, msgq_limit));
+  return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq_limit));
+}
+
+// public constructor that takes existing message queue
+gr_message_source_sptr
+gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq)
+{
+  return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq));
 }
 
 gr_message_source::gr_message_source (size_t itemsize, int msgq_limit)
@@ -50,6 +58,14 @@ gr_message_source::gr_message_source (size_t itemsize, int msgq_limit)
 {
 }
 
+gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq)
+  : gr_sync_block("message_source",
+                 gr_make_io_signature(0, 0, 0),
+                 gr_make_io_signature(1, 1, itemsize)),
+    d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false)
+{
+}
+
 gr_message_source::~gr_message_source()
 {
 }