commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3975 - gnuradio/branches/developers/eb/mb/mblock/src/


From: eb
Subject: [Commit-gnuradio] r3975 - gnuradio/branches/developers/eb/mb/mblock/src/lib
Date: Sun, 12 Nov 2006 16:34:45 -0700 (MST)

Author: eb
Date: 2006-11-12 16:34:45 -0700 (Sun, 12 Nov 2006)
New Revision: 3975

Modified:
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
   gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
   gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
Log:
work-in-progress

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc      
2006-11-12 19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc      
2006-11-12 23:34:45 UTC (rev 3975)
@@ -63,11 +63,13 @@
 ////////////////////////////////////////////////////////////////////////
 
 void
-mb_mblock::define_port(pmt_t port_name,
+mb_mblock::define_port(const std::string &port_name_string,
                       const std::string &protocol_class_name,
                       bool conjugated,
                       mb_port_class::port_type_t port_type)
 {
+  pmt_t port_name = pmt_intern(port_name_string);
+
   if (port_type == mb_port_class::RELAY)
     throw pmt_notimplemented(
         "mb_block_impl::define_port: RELAY ports are not implemented",
@@ -96,32 +98,31 @@
   d_impl->d_components.push_back(mb_component(name, component));
 }
 
-bool
-mb_mblock::connect(const mb_endpoint &endpoint_1, const mb_endpoint 
&endpoint_2)
+void
+mb_mblock::connect(const std::string &comp_name1, const std::string 
&port_name1,
+                  const std::string &comp_name2, const std::string &port_name2)
 {
-  // FIXME
-  return true;
+  //  mb_endpoint ep1 = lookup_endpoint(comp_name1, port_name1);
+  //  mb_endpoint ep2 = lookup_endpoint(comp_name2, port_name2);
 }
 
-bool
-mb_mblock::disconnect(const mb_endpoint &endpoint_1, const mb_endpoint 
&endpoint_2)
+void
+mb_mblock::disconnect(const std::string &comp_name1, const std::string 
&port_name1,
+                     const std::string &comp_name2, const std::string 
&port_name2)
 {
   // FIXME
-  return true;
 }
 
-bool
+void
 mb_mblock::disconnect_component(const std::string component_name)
 {
   // FIXME
-  return true;
 }
 
-bool
+void
 mb_mblock::disconnect_all()
 {
   // FIXME
-  return true;
 }
 
 void

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h       
2006-11-12 19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h       
2006-11-12 23:34:45 UTC (rev 3975)
@@ -34,25 +34,6 @@
 // ----------------------------------------------------------------------
 
 /*!
- * \brief Endpoint specification for connection
- */
-class mb_endpoint
-{
-  std::string  d_component_name;
-  std::string  d_port_name;
-
-public:
-  mb_endpoint(const std::string &component_name,
-             const std::string &port_name)
-    : d_component_name(component_name), d_port_name(port_name) {}
-
-  const std::string &component_name() const { return d_component_name; }
-  const std::string &port_name() const { return d_port_name; }
-};
-
-// ----------------------------------------------------------------------
-
-/*!
  * \brief Parent class for all message passing blocks
  *
  * Subclass this to define your mblocks.
@@ -103,14 +84,14 @@
    * EXTERNAL and RELAY ports are part of our peer interface.
    * INTERNAL ports are used to talk to sub-components.
    *
-   * \param port_name The name [symbol] of the port (must be unique within 
this mblock).
+   * \param port_name    The name of the port (must be unique within this 
mblock).
    * \param protocol_class_name        The name of the protocol class 
associated with
    *                           this port.  It must already be defined.
    * \param conjugated   Are the incoming and outgoing message sets swapped?
    * \param port_type    INTERNAL, EXTERNAL or RELAY.
    */
   void
-  define_port(pmt_t port_name,
+  define_port(const std::string &port_name,
              const std::string &protocol_class_name,
              bool conjugated,
              mb_port_class::port_type_t port_type);
@@ -130,43 +111,51 @@
 
   /*!
    * \brief connect endpoint_1 to endpoint_2
-   * \param endpoint_1  one end of the connection
-   * \param endpoint_2  the other end of the connection
    *
+   * \param comp_name1  component on one of the connection
+   * \param port_name1  the name of the port on comp1
+   * \param comp_name2  component on the other end the connection
+   * \param port_name2  the name of the port on comp2
+   *
    * An endpoint is specified by the component's local name (given as
    * component_name in the call to register_component) and the name of
    * the port on that component.
    *
    * To connect an internal or relay port, use "self" as the component name.
    */
-  bool
-  connect(const mb_endpoint &endpoint_1, const mb_endpoint &endpoint_2);
+  void
+  connect(const std::string &comp_name1, const std::string &port_name1,
+         const std::string &comp_name2, const std::string &port_name2);
 
   /*!
    * \brief disconnect endpoint_1 from endpoint_2
-   * \param endpoint_1  one end of the connection
-   * \param endpoint_2  the other end of the connection
    *
+   * \param comp_name1  component on one of the connection
+   * \param port_name1  the name of the port on comp1
+   * \param comp_name2  component on the other end the connection
+   * \param port_name2  the name of the port on comp2
+   *
    * An endpoint is specified by the component's local name (given as
    * component_name in the call to register_component) and the name of
    * the port on that component.
    *
    * To disconnect an internal or relay port, use "self" as the component name.
    */
-  bool
-  disconnect(const mb_endpoint &endpoint_1, const mb_endpoint &endpoint_2);
+  void
+  disconnect(const std::string &comp_name1, const std::string &port_name1,
+            const std::string &comp_name2, const std::string &port_name2);
 
   /*!
    * \brief disconnect all connections to specified component
    * \param component_name component to disconnect
    */
-  bool
+  void
   disconnect_component(const std::string component_name);
 
   /*!
    * \brief disconnect all connections to all components
    */
-  bool
+  void
   disconnect_all();
 
   /*!

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h  
2006-11-12 19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h  
2006-11-12 23:34:45 UTC (rev 3975)
@@ -36,8 +36,46 @@
   mb_mblock_sptr component() const { return d_component; }
 };
 
+/*!
+ * \brief Endpoint specification for connection
+ */
+class mb_endpoint
+{
+  std::string  d_component_name;
+  std::string  d_port_name;
 
+  mb_port_sptr d_port;                 // the port object that this maps to
+
+public:
+  mb_endpoint(const std::string &component_name,
+             const std::string &port_name,
+             mb_port_sptr port)
+    : d_component_name(component_name),
+      d_port_name(port_name),
+      d_port(port) {}
+
+  const std::string &component_name() const { return d_component_name; }
+  const std::string &port_name() const { return d_port_name; }
+  mb_port_sptr port() const { return d_port; }
+};
+
+
 /*!
+ * \brief Representation of a connection
+ */
+class mb_connection {
+  mb_endpoint  d_ep0;
+  mb_endpoint  d_ep1;
+};
+
+class mb_conn_table {
+  std::vector<mb_connection> d_connections;
+
+public:
+};
+
+
+/*!
  * \brief The private implementation details of the mblock system.
  */
 class mb_mblock_impl : boost::noncopyable

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h 2006-11-12 
19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h 2006-11-12 
23:34:45 UTC (rev 3975)
@@ -32,6 +32,7 @@
 {
   mb_port_class_sptr   d_port_class;
 
+  // FIXME cached shortcut to other end
   // These are only valid if this port is connected
   mb_mblock_sptr       d_remote_mblock;        // mblock bound to other end 
this port
   pmt_t                        d_remote_port_name;     // port_name on other 
end of this port

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc        
2006-11-12 19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc        
2006-11-12 23:34:45 UTC (rev 3975)
@@ -29,6 +29,9 @@
 
 static pmt_t s_cs = pmt_intern("cs");
 static pmt_t s_debug = pmt_intern("debug");
+static pmt_t s_in = pmt_intern("in");
+static pmt_t s_out = pmt_intern("out");
+  
 
 // ================================================================
 
@@ -40,7 +43,6 @@
 };
 
 dp_1::dp_1()
-  : mb_mblock()
 {
 }
 
@@ -56,9 +58,8 @@
 };
 
 dp_2::dp_2()
-  : mb_mblock()
 {
-  define_port(s_cs, "cs-protocol", false, mb_port_class::EXTERNAL);
+  define_port("cs", "cs-protocol", false, mb_port_class::EXTERNAL);
 }
 
 dp_2::~dp_2(){}
@@ -73,10 +74,9 @@
 };
 
 dp_3::dp_3()
-  : mb_mblock()
 {
-  define_port(s_cs, "cs-protocol", false, mb_port_class::EXTERNAL);
-  define_port(s_cs, "cs-protocol", false, mb_port_class::EXTERNAL);    // 
duplicate def
+  define_port("cs", "cs-protocol", false, mb_port_class::EXTERNAL);
+  define_port("cs", "cs-protocol", false, mb_port_class::EXTERNAL);    // 
duplicate def
 }
 
 dp_3::~dp_3(){}
@@ -136,7 +136,6 @@
 };
 
 dc_0::dc_0()
-  : mb_mblock()
 {
 }
 
@@ -152,7 +151,6 @@
 };
 
 dc_ok::dc_ok()
-  : mb_mblock()
 {
   define_component("c0", mb_mblock_sptr(new dc_0()));
   define_component("c1", mb_mblock_sptr(new dc_0()));
@@ -185,9 +183,96 @@
 qa_mblock_prims::test_define_components()
 {
   mb_runtime_sptr      rt = mb_make_runtime();
-  mb_mblock_sptr       mb1 = mb_mblock_sptr(new dc_ok());
+  mb_mblock_sptr       mb1 = mb_mblock_sptr(new dc_ok());      // OK
 
   // raises pmt_exception because of duplicate component definition of "c0"
   CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dc_not_ok()), pmt_exception);
 }
 
+// ================================================================
+
+class tc_in : public mb_mblock
+{
+public:
+  tc_in(){
+    define_port("data", "data", false, mb_port_class::EXTERNAL);
+  }
+
+  ~tc_in();
+};
+
+tc_in::~tc_in(){}
+
+////////////////////////////////////////////////////////////////
+
+class tc_out : public mb_mblock
+{
+public:
+  tc_out(){
+    define_port("data", "data", true, mb_port_class::EXTERNAL);
+  }
+
+  ~tc_out();
+};
+
+tc_out::~tc_out(){}
+
+////////////////////////////////////////////////////////////////
+
+class tc_0 : public mb_mblock
+{
+public:
+  tc_0(){
+    define_component("cin0", mb_mblock_sptr(new tc_in()));
+    define_component("cin1", mb_mblock_sptr(new tc_in()));
+    define_component("cout0", mb_mblock_sptr(new tc_out()));
+
+    // OK
+    connect("cin0", "data", "cout0", "data");
+
+    // No:  No such component name
+    CPPUNIT_ASSERT_THROW(connect("foo", "data", "cout0", "data"), 
std::invalid_argument);
+
+    // No:  No such port name
+    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cout0", "foo"), 
std::invalid_argument);
+
+    // No: incompatible ports
+    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cin1", "data"), 
std::invalid_argument);
+  }
+
+  ~tc_0();
+};
+
+tc_0::~tc_0(){}
+
+////////////////////////////////////////////////////////////////
+
+class tc_1 : public mb_mblock
+{
+public:
+  tc_1(){
+    define_component("c0", mb_mblock_sptr(new tc_in()));
+    define_component("c1", mb_mblock_sptr(new tc_in()));
+
+    connect("c0", "in", "c1", "in");
+  }
+
+  ~tc_1();
+};
+
+tc_1::~tc_1(){}
+
+////////////////////////////////////////////////////////////////
+
+void
+qa_mblock_prims::test_connect()
+{
+  // define the protocol class
+  pmt_t pc = mb_make_protocol_class(pmt_intern("data"),                        
        // name of class
+                                   pmt_cons(pmt_intern("data"), PMT_NIL),      
// in
+                                   PMT_NIL);                                   
// out
+
+
+  mb_runtime_sptr      rt = mb_make_runtime();
+  mb_mblock_sptr       mb0 = mb_mblock_sptr(new tc_0());
+}

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h 
2006-11-12 19:52:15 UTC (rev 3974)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h 
2006-11-12 23:34:45 UTC (rev 3975)
@@ -30,11 +30,13 @@
   CPPUNIT_TEST_SUITE(qa_mblock_prims);
   CPPUNIT_TEST(test_define_ports);
   CPPUNIT_TEST(test_define_components);
+  CPPUNIT_TEST(test_connect);
   CPPUNIT_TEST_SUITE_END();
 
  private:
   void test_define_ports();
   void test_define_components();
+  void test_connect();
 };
 
 #endif /* INCLUDED_QA_MBLOCK_PRIMS_H */





reply via email to

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