commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r3743 - gnuradio/branches/developers/jcorgan/cppwrap/g


From: jcorgan
Subject: [Commit-gnuradio] r3743 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native
Date: Sun, 8 Oct 2006 21:07:48 -0600 (MDT)

Author: jcorgan
Date: 2006-10-08 21:07:48 -0600 (Sun, 08 Oct 2006)
New Revision: 3743

Modified:
   
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 'disconnect' functionality, minor cleanups.


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-09 02:17:45 UTC (rev 3742)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.cc
      2006-10-09 03:07:48 UTC (rev 3743)
@@ -25,9 +25,6 @@
 
 #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()
@@ -99,6 +96,44 @@
        throw std::invalid_argument("gr_flow_graph::check_type_match");
 }
 
+void gr_flow_graph::disconnect(gr_block_sptr src_block, int src_port,
+                              gr_block_sptr dst_block, int dst_port)
+{
+    disconnect_prim(gr_endpoint_t(src_block, src_port),
+                   gr_endpoint_t(dst_block, dst_port));
+}
+
+// More disconnect convenience functions (that resolve into calls to
+// disconnect_prim) go here
+
+void gr_flow_graph::disconnect_prim(gr_endpoint_t src, gr_endpoint_t dst)
+{
+    gr_edge_vector_iterator_t edge;
+    for(edge = d_edges.begin(); edge != d_edges.end(); edge++) {
+       gr_block_sptr src_block = src.first;
+       gr_block_sptr dst_block = dst.first;
+       gr_block_sptr edge_src_block = edge->first.first;
+       gr_block_sptr edge_dst_block = edge->second.first;
+       int src_port = src.second;
+       int dst_port = dst.second;
+       int edge_src_port = edge->first.second;
+       int edge_dst_port = edge->second.second;
+       
+       if (src_block == edge_src_block && src_port == edge_src_port &&
+           dst_block == edge_dst_block && dst_port == edge_dst_port) {
+           d_edges.erase(edge);
+           return;
+       }
+    }
+
+    throw std::invalid_argument("gr_flow_graph::disconnect_prim");
+}
+
+void gr_flow_graph::disconnect_all()
+{
+    d_edges.clear();
+}
+
 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-09 02:17:45 UTC (rev 3742)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/native/gr_flow_graph.h
       2006-10-09 03:07:48 UTC (rev 3743)
@@ -43,15 +43,23 @@
     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);
+
+    void disconnect_prim(gr_endpoint_t src, gr_endpoint_t dst);
         
     gr_edge_vector_t d_edges;
                             
 public:
     ~gr_flow_graph();
-    void connect(gr_block_sptr src_block, int src_portno,
-                gr_block_sptr dst_block, int dst_portno);
+    void connect(gr_block_sptr src_block, int src_port,
+                gr_block_sptr dst_block, int dst_port);
     // more connect convenience functions go here
+
+    void disconnect(gr_block_sptr src_block, int src_port,
+                   gr_block_sptr dst_block, int dst_port);
+    void disconnect_all();
     
+    // more disconnect convenience functions go here
+    
     void run();
 };
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]