commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r3979 - gnuradio/branches/developers/eb/mb/mblock/src/lib
Date: Mon, 13 Nov 2006 15:52:04 -0700 (MST)

Author: eb
Date: 2006-11-13 15:52:03 -0700 (Mon, 13 Nov 2006)
New Revision: 3979

Added:
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.cc
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.h
Modified:
   gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
   gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc
   gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
Log:
and the beat goes on...

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am       
2006-11-13 21:22:13 UTC (rev 3978)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am       
2006-11-13 22:52:03 UTC (rev 3979)
@@ -33,6 +33,7 @@
 # These are the source files that go into the mblock shared library
 libmblock_la_SOURCES =                 \
        mb_connection.cc                \
+       mb_exception.cc                 \
        mb_mblock.cc                    \
        mb_mblock_impl.cc               \
        mb_message.cc                   \
@@ -52,8 +53,9 @@
        -lstdc++                        
 
 include_HEADERS =                      \
+       mb_common.h                     \
+       mb_exception.h                  \
        mb_mblock.h                     \
-       mb_common.h                     \
        mb_message.h                    \
        mb_port.h                       \
        mb_port_class.h                 \

Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.cc           
                (rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.cc   
2006-11-13 22:52:03 UTC (rev 3979)
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <mb_exception.h>
+#include <mb_mblock.h>
+
+mbe_base::mbe_base(mb_mblock *mb, const std::string &msg)
+  : logic_error(msg)   // FIXME extract block class name and id and add to msg
+{
+}
+
+mbe_no_such_component::mbe_no_such_component(mb_mblock *mb, const std::string 
&component_name)
+  : mbe_base(mb, "No such component: " + component_name)
+{
+}
+
+
+mbe_duplicate_component::mbe_duplicate_component(mb_mblock *mb, const 
std::string &component_name)
+  : mbe_base(mb, "Duplicate component: " + component_name)
+{
+}
+
+mbe_no_such_port::mbe_no_such_port(mb_mblock *mb, const std::string &port_name)
+  : mbe_base(mb, "No such port: " + port_name)
+{
+}
+
+mbe_duplicate_port::mbe_duplicate_port(mb_mblock *mb, const std::string 
&port_name)
+  : mbe_base(mb, "Duplicate port: " + port_name)
+{
+}
+
+mbe_already_connected::mbe_already_connected(mb_mblock *mb,
+                                            const std::string &comp_name,
+                                            const std::string &port_name)
+  : mbe_base(mb, "Port already connected: " + comp_name + "/" + port_name)
+{
+}
+
+
+

Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.h            
                (rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_exception.h    
2006-11-13 22:52:03 UTC (rev 3979)
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_MB_EXCEPTION_H
+#define INCLUDED_MB_EXCEPTION_H
+
+#include <stdexcept>
+
+class mb_mblock;
+
+
+class mbe_base : public std::logic_error
+{
+public:
+  mbe_base(mb_mblock *mb, const std::string &msg);
+};
+
+
+
+class mbe_no_such_component : public mbe_base
+{
+public:
+  mbe_no_such_component(mb_mblock *, const std::string &component_name);
+};
+
+class mbe_duplicate_component : public mbe_base
+{
+public:
+  mbe_duplicate_component(mb_mblock *, const std::string &component_name);
+};
+
+class mbe_no_such_port : public mbe_base
+{
+public:
+  mbe_no_such_port(mb_mblock *, const std::string &port_name);
+};
+
+class mbe_duplicate_port : public mbe_base
+{
+public:
+  mbe_duplicate_port(mb_mblock *, const std::string &port_name);
+};
+
+class mbe_already_connected : public mbe_base
+{
+public:
+  mbe_already_connected(mb_mblock *, const std::string &comp_name,
+                       const std::string &port_name);
+};
+
+
+
+#endif /* INCLUDED_MB_EXCEPTION_H */

Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc 
2006-11-13 21:22:13 UTC (rev 3978)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc 
2006-11-13 22:52:03 UTC (rev 3979)
@@ -26,48 +26,13 @@
 #include <mb_mblock.h>
 #include <mb_protocol_class.h>
 #include <mb_port.h>
+#include <mb_exception.h>
 
+
 static pmt_t s_self = pmt_intern("self");
 
 ////////////////////////////////////////////////////////////////////////
 
-static void
-no_such_comp(const std::string &comp_name)
-{
-  std::string msg = "No such component: " + comp_name;
-  throw std::invalid_argument(msg);
-}
-
-static void
-no_such_port(const std::string &port_name)
-{
-  std::string msg = "No such port: " + port_name;
-  throw std::invalid_argument(msg);
-}
-
-static void
-already_connected(const std::string &comp_name, const std::string &port_name)
-{
-  std::string msg = "Port is already connected: " + comp_name + ":" + 
port_name;
-  throw std::invalid_argument(msg);
-}
-
-static void
-port_already_defined(const std::string &port_name)
-{
-  std::string msg = "Port is already defined: " + port_name;
-  throw std::invalid_argument(msg);
-}
-
-static void
-comp_already_defined(const std::string &comp_name)
-{
-  std::string msg = "Component is already defined: " + comp_name;
-  throw std::invalid_argument(msg);
-}
-
-////////////////////////////////////////////////////////////////////////
-
 bool 
 mb_mblock_impl::port_is_defined(const std::string &name)
 {
@@ -89,7 +54,7 @@
 
 mb_mblock_impl::~mb_mblock_impl()
 {
-  d_mb = 0;
+  d_mb = 0;    // we don't own it
 }
 
 
@@ -100,11 +65,10 @@
                            mb_port_class::port_type_t port_type)
 {
   if (port_type == mb_port_class::RELAY)
-    throw std::invalid_argument(
-        "mb_block_impl::define_port: RELAY ports are not implemented: " + 
port_name);
+    throw mbe_base(d_mb, "mb_block_impl::define_port: RELAY ports are not 
implemented: " + port_name);
   
   if (port_is_defined(port_name))
-    port_already_defined(port_name);
+    throw mbe_duplicate_port(d_mb, port_name);
 
   mb_port_sptr p = mb_port_sptr(new mb_port(port_name, protocol_class_name,
                                            conjugated, port_type));
@@ -121,7 +85,7 @@
 
   // Is this endpoint already bound?
   if (d_conn_table.lookup_conn_by_name(comp_name, port_name, &it, &which_ep))
-    already_connected(comp_name, port_name);
+    throw mbe_already_connected(d_mb, comp_name, port_name);
 
   return mb_endpoint(comp_name, port_name, port);
 }
@@ -132,14 +96,15 @@
 {
   if (comp_name == "self"){
     if (!port_is_defined(port_name))
-      no_such_port(port_name);
+      throw mbe_no_such_port(d_mb, port_name);
     return d_port_map[port_name];
   }
   else {
-    no_such_port();
+    // FIXME
+    throw mbe_no_such_port(d_mb, port_name);
   }
 
-  return port;
+  // return mb_port_sptr();
 }
 
 
@@ -149,7 +114,7 @@
                                 mb_mblock_sptr component)
 {
   if (comp_is_defined(name))   // check for duplicate name
-    comp_already_defined(name);
+    throw mbe_duplicate_component(d_mb, name);
 
   d_comp_map[name] = component;
 }

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-13 21:22:13 UTC (rev 3978)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc        
2006-11-13 22:52:03 UTC (rev 3979)
@@ -25,6 +25,7 @@
 #include <mb_mblock.h>
 #include <mb_runtime.h>
 #include <mb_protocol_class.h>
+#include <mb_exception.h>
 #include <stdio.h>
 
 static pmt_t s_cs = pmt_intern("cs");
@@ -113,7 +114,7 @@
 
 
   // raises pmt_exception because of duplicate port definition of "cs"
-  CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dp_3()), std::invalid_argument);
+  CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dp_3()), mbe_duplicate_port);
 
 #if 0
   try {
@@ -186,7 +187,7 @@
   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()), std::invalid_argument);
+  CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dc_not_ok()), 
mbe_duplicate_component);
 }
 
 // ================================================================
@@ -231,14 +232,14 @@
     connect("cin0", "data", "cout0", "data");
 
     // No:  No such component name
-    CPPUNIT_ASSERT_THROW(connect("foo", "data", "cout0", "data"), 
std::invalid_argument);
+    CPPUNIT_ASSERT_THROW(connect("foo", "data", "cout0", "data"), 
mbe_no_such_component);
 
-#if 1
     // No:  No such port name
-    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cout0", "foo"), 
std::invalid_argument);
+    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cout0", "foo"), 
mbe_no_such_port);
 
+#if 0
     // No: incompatible ports
-    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cin1", "data"), 
std::invalid_argument);
+    CPPUNIT_ASSERT_THROW(connect("cin0", "data", "cin1", "data"), 
mbe_incompatible_ports);
 #endif
   }
 





reply via email to

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