summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Blum2012-08-19 14:27:11 -0700
committerJosh Blum2012-08-26 16:03:51 -0700
commitfa25d15ed1a7b85869229055ef32166ef1d8bef2 (patch)
tree0f39ab553dce30e9c8c11ab20f820d5753d5bf47 /include
parent87be8242fd5855a8e8f6a76fddf40275b711c784 (diff)
downloadsandhi-fa25d15ed1a7b85869229055ef32166ef1d8bef2.tar.gz
sandhi-fa25d15ed1a7b85869229055ef32166ef1d8bef2.tar.bz2
sandhi-fa25d15ed1a7b85869229055ef32166ef1d8bef2.zip
runtime: work on unit tests
Diffstat (limited to 'include')
-rw-r--r--include/gnuradio/block.hpp12
-rw-r--r--include/gnuradio/element.hpp15
-rw-r--r--include/gnuradio/gr_block.h11
-rw-r--r--include/gnuradio/gr_hier_block2.h8
-rw-r--r--include/gnuradio/gr_top_block.h17
-rw-r--r--include/gnuradio/gr_unittests.h43
-rw-r--r--include/gnuradio/hier_block.hpp1
-rw-r--r--include/gnuradio/top_block.hpp16
8 files changed, 99 insertions, 24 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp
index 418657f..42f5f8d 100644
--- a/include/gnuradio/block.hpp
+++ b/include/gnuradio/block.hpp
@@ -75,18 +75,6 @@ struct GR_RUNTIME_API Block : Element
* Basic routines from basic block
******************************************************************/
- long unique_id(void) const;
-
- std::string name(void) const;
-
- size_t input_size(const size_t which_input) const;
-
- size_t output_size(const size_t which_output) const;
-
- void set_input_size(const size_t size, const size_t which_input);
-
- void set_output_size(const size_t size, const size_t which_output);
-
size_t history(const size_t which_input = 0) const;
void set_history(const size_t history, const size_t which_input = 0);
diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp
index dc153fe..849323a 100644
--- a/include/gnuradio/element.hpp
+++ b/include/gnuradio/element.hpp
@@ -19,6 +19,7 @@
#include <gnuradio/runtime_api.h>
#include <gruel/pmt.h>
+#include <gr_io_signature.h>
namespace gnuradio
{
@@ -29,6 +30,8 @@ struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl>
//! Create an empty element
Element(void);
+ Element(const std::string &name);
+
/*!
* Create an element from a shared pointer to an element.
* Good for that factory function/shared ptr paradigm.
@@ -38,6 +41,18 @@ struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl>
boost::shared_ptr<ElementImpl>(*reinterpret_cast<const Element*>(elem.get()))
{ }
+ long unique_id(void) const;
+
+ std::string name(void) const;
+
+ void set_output_signature(gr_io_signature_sptr);
+
+ void set_input_signature(gr_io_signature_sptr);
+
+ gr_io_signature_sptr input_signature(void) const;
+
+ gr_io_signature_sptr output_signature(void) const;
+
};
} //namespace gnuradio
diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h
index 7418e3d..92f613a 100644
--- a/include/gnuradio/gr_block.h
+++ b/include/gnuradio/gr_block.h
@@ -19,7 +19,6 @@
#include <gnuradio/runtime_api.h>
#include <gnuradio/block.hpp>
-#include <gr_io_signature.h>
#include <gr_sptr_magic.h>
#include <gr_types.h>
#include <gr_tags.h>
@@ -38,14 +37,6 @@ struct GR_RUNTIME_API gr_block : gnuradio::Block
template <typename T> void set_msg_handler(T msg_handler){/*LOL*/}
- void set_output_signature(gr_io_signature_sptr);
-
- void set_input_signature(gr_io_signature_sptr);
-
- gr_io_signature_sptr input_signature(void) const;
-
- gr_io_signature_sptr output_signature(void) const;
-
//! implements work -> calls general work
int work(
const InputItems &input_items,
@@ -74,4 +65,6 @@ struct GR_RUNTIME_API gr_block : gnuradio::Block
) = 0;
};
+typedef boost::shared_ptr<gr_block> gr_block_sptr;
+
#endif /*INCLUDED_GNURADIO_GR_BLOCK_H*/
diff --git a/include/gnuradio/gr_hier_block2.h b/include/gnuradio/gr_hier_block2.h
index dd8fdae..7bf1ae9 100644
--- a/include/gnuradio/gr_hier_block2.h
+++ b/include/gnuradio/gr_hier_block2.h
@@ -39,4 +39,12 @@ struct GR_RUNTIME_API gr_hier_block2 : gnuradio::HierBlock
};
+typedef boost::shared_ptr<gr_hier_block2> gr_hier_block2_sptr;
+
+GR_RUNTIME_API gr_hier_block2_sptr gr_make_hier_block2(
+ const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature
+);
+
#endif /*INCLUDED_GNURADIO_GR_HIER_BLOCK2_H*/
diff --git a/include/gnuradio/gr_top_block.h b/include/gnuradio/gr_top_block.h
index 199d7b5..8630606 100644
--- a/include/gnuradio/gr_top_block.h
+++ b/include/gnuradio/gr_top_block.h
@@ -18,15 +18,30 @@
#define INCLUDED_GNURADIO_GR_TOP_BLOCK_H
#include <gnuradio/runtime_api.h>
+#include <gnuradio/top_block.hpp>
#include <gr_hier_block2.h>
-struct GR_RUNTIME_API gr_top_block : gr_hier_block2
+struct GR_RUNTIME_API gr_top_block : gnuradio::TopBlock
{
gr_top_block(void);
gr_top_block(const std::string &name);
+ void lock(void)
+ {
+ //NOP
+ }
+
+ void unlock(void)
+ {
+ this->update();
+ }
+
};
+typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr;
+
+GR_RUNTIME_API gr_top_block_sptr gr_make_top_block(const std::string &name);
+
#endif /*INCLUDED_GNURADIO_GR_TOP_BLOCK_H*/
diff --git a/include/gnuradio/gr_unittests.h b/include/gnuradio/gr_unittests.h
new file mode 100644
index 0000000..9fbf228
--- /dev/null
+++ b/include/gnuradio/gr_unittests.h
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2011 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 <gr_core_api.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string>
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+
+static std::string get_unittest_path(const std::string &filename){
+ boost::filesystem::path path = boost::filesystem::current_path() / ".unittests";
+ if (!boost::filesystem::is_directory(path)) boost::filesystem::create_directory(path);
+ return (path / filename).string();
+}
diff --git a/include/gnuradio/hier_block.hpp b/include/gnuradio/hier_block.hpp
index 1518af5..55f996e 100644
--- a/include/gnuradio/hier_block.hpp
+++ b/include/gnuradio/hier_block.hpp
@@ -19,7 +19,6 @@
#include <gnuradio/runtime_api.h>
#include <gnuradio/element.hpp>
-#include <gruel/pmt.h>
namespace gnuradio
{
diff --git a/include/gnuradio/top_block.hpp b/include/gnuradio/top_block.hpp
index c131c7d..eb5f6b5 100644
--- a/include/gnuradio/top_block.hpp
+++ b/include/gnuradio/top_block.hpp
@@ -19,7 +19,6 @@
#include <gnuradio/runtime_api.h>
#include <gnuradio/hier_block.hpp>
-#include <gruel/pmt.h>
namespace gnuradio
{
@@ -27,6 +26,21 @@ namespace gnuradio
struct GR_RUNTIME_API TopBlock : HierBlock
{
TopBlock(void);
+
+ TopBlock(const std::string &name);
+
+ void update(void);
+
+ void run(void)
+ {
+ this->start();
+ this->stop();
+ this->wait();
+ }
+
+ void start(void);
+ void stop(void);
+ void wait(void);
};
} //namespace gnuradio