[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3742 - gnuradio/branches/developers/jcorgan/cppwrap/g
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r3742 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native |
Date: |
Sun, 8 Oct 2006 20:17:45 -0600 (MDT) |
Author: jcorgan
Date: 2006-10-08 20:17:45 -0600 (Sun, 08 Oct 2006)
New Revision: 3742
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/dialtone.cc
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.cc
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.h
Log:
Work in progress.
Implemented flow graph 'connect' functionality.
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/dialtone.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/dialtone.cc
2006-10-08 22:10:23 UTC (rev 3741)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/dialtone.cc
2006-10-09 02:17:45 UTC (rev 3742)
@@ -1,3 +1,24 @@
+/*
+ * Copyright 2006 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)
+ * 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.
+ */
+
#include <gnuradio/gr_sig_source_f.h>
#include <gnuradio/audio_alsa_sink.h>
#include <gr_flow_graph.h>
@@ -15,6 +36,7 @@
fg = gr_make_flow_graph();
fg->connect(SRC0, 0, SINK, 0);
fg->connect(SRC1, 0, SINK, 1);
+
fg->run();
return 0;
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.cc
2006-10-08 22:10:23 UTC (rev 3741)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.cc
2006-10-09 02:17:45 UTC (rev 3742)
@@ -1,6 +1,35 @@
+/*
+ * Copyright 2006 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)
+ * 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.
+ */
+
#include <gr_flow_graph.h>
#include <gr_block_detail.h>
+#include <gr_io_signature.h>
+#include <utility>
+
+typedef std::pair<gr_block_sptr, int> gr_endpoint_t;
+typedef std::pair<gr_endpoint_t, gr_endpoint_t> gr_edge_t;
+typedef std::vector<gr_edge_t> gr_edge_vector_t;
+typedef std::vector<gr_edge_t>::iterator gr_edge_vector_iterator_t;
+
gr_flow_graph_sptr gr_make_flow_graph()
{
return gr_flow_graph_sptr(new gr_flow_graph());
@@ -16,12 +45,61 @@
// NOP
}
-void gr_flow_graph::connect(gr_block_sptr block_from, int from_portno,
- gr_block_sptr block_to, int to_portno)
+void gr_flow_graph::connect(gr_block_sptr src_block, int src_port,
+ gr_block_sptr dst_block, int dst_port)
{
+ connect_prim(gr_endpoint_t(src_block, src_port),
+ gr_endpoint_t(dst_block, dst_port));
}
+// More connect convenience functions (that resolve into calls to
+// connect_prim) go here
+
+void gr_flow_graph::connect_prim(gr_endpoint_t src, gr_endpoint_t dst)
+{
+ check_valid_port(src.first->output_signature(), src.second);
+ check_valid_port(dst.first->input_signature(), dst.second);
+ check_dst_not_used(dst);
+ check_type_match(src, dst);
+
+ d_edges.push_back(gr_edge_t(src, dst));
+}
+
+void gr_flow_graph::check_valid_port(gr_io_signature_sptr sig, int port)
+{
+ if (port < 0)
+ throw std::out_of_range("gr_flow_graph::check_valid_port");
+
+ if (sig->max_streams() >= 0 && port >= sig->max_streams())
+ throw std::out_of_range("gr_flow_graph::check_valid_port");
+}
+
+void gr_flow_graph::check_dst_not_used(gr_endpoint_t dst)
+{
+ gr_edge_vector_iterator_t edge;
+ for(edge = d_edges.begin(); edge != d_edges.end(); edge++) {
+ gr_block_sptr dst_block = dst.first;
+ gr_block_sptr edge_block = edge->second.first;
+ int dst_port = dst.second;
+ int edge_port = edge->second.second;
+
+ if (dst_block == edge_block && dst_port == edge_port)
+ throw std::invalid_argument("gr_flow_graph::check_dst_not_used");
+ }
+}
+
+void gr_flow_graph::check_type_match(gr_endpoint_t src, gr_endpoint_t dst)
+{
+ gr_io_signature_sptr src_sig = src.first->output_signature();
+ gr_io_signature_sptr dst_sig = dst.first->input_signature();
+ int src_size = src_sig->sizeof_stream_item(src.second);
+ int dst_size = dst_sig->sizeof_stream_item(dst.second);
+
+ if (src_size != dst_size)
+ throw std::invalid_argument("gr_flow_graph::check_type_match");
+}
+
void gr_flow_graph::run()
{
+ printf("If this were a real program, something interesting would now
happen.\n");
}
-
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.h
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.h
2006-10-08 22:10:23 UTC (rev 3741)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.h
2006-10-09 02:17:45 UTC (rev 3742)
@@ -1,3 +1,24 @@
+/*
+ * Copyright 2006 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)
+ * 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.
+ */
+
#ifndef INCLUDED_GR_FLOW_GRAPH_H
#define INCLUDED_GR_FLOW_GRAPH_H
@@ -3,4 +24,8 @@
#include <gr_block.h>
+typedef std::pair<gr_block_sptr, int> gr_endpoint_t;
+typedef std::pair<gr_endpoint_t, gr_endpoint_t> gr_edge_t;
+typedef std::vector<gr_edge_t> gr_edge_vector_t;
+
class gr_flow_graph;
typedef boost::shared_ptr<gr_flow_graph> gr_flow_graph_sptr;
@@ -13,12 +38,20 @@
private:
gr_flow_graph();
friend gr_flow_graph_sptr gr_make_flow_graph();
+
+ void connect_prim(gr_endpoint_t src, gr_endpoint_t dst);
+ void check_valid_port(gr_io_signature_sptr sig, int port);
+ void check_dst_not_used(gr_endpoint_t dst);
+ void check_type_match(gr_endpoint_t src, gr_endpoint_t dst);
+
+ gr_edge_vector_t d_edges;
public:
~gr_flow_graph();
- void connect(gr_block_sptr block_from, int portno_from,
- gr_block_sptr block_to, int portno_to);
-
+ void connect(gr_block_sptr src_block, int src_portno,
+ gr_block_sptr dst_block, int dst_portno);
+ // more connect convenience functions go here
+
void run();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3742 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native,
jcorgan <=