[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3408 - gnuradio/branches/developers/eb/mb/mblock/src/
From: |
eb |
Subject: |
[Commit-gnuradio] r3408 - gnuradio/branches/developers/eb/mb/mblock/src/lib |
Date: |
Fri, 25 Aug 2006 02:06:43 -0600 (MDT) |
Author: eb
Date: 2006-08-25 02:06:43 -0600 (Fri, 25 Aug 2006)
New Revision: 3408
Added:
gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
Modified:
gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
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.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock.cc
Log:
work in progress
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
2006-08-25 08:06:43 UTC (rev 3408)
@@ -63,13 +63,15 @@
noinst_HEADERS = \
mb_mblock_impl.h \
mb_runtime_impl.h \
- qa_mblock.h
+ qa_mblock.h \
+ qa_mblock_prims.h
# Build the qa code into its own library
libmblock_qa_la_SOURCES = \
- qa_mblock.cc
+ qa_mblock.cc \
+ qa_mblock_prims.cc
# magic flags
@@ -77,7 +79,6 @@
# link the library against the c++ standard library
libmblock_qa_la_LIBADD = \
- qa_mblock.cc \
libmblock.la \
$(CPPUNIT_LIBS) \
-lstdc++
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -24,10 +24,12 @@
#endif
#include <mb_mblock.h>
+#include <mb_mblock_impl.h>
#include <mb_protocol_class.h>
mb_mblock::mb_mblock(mb_runtime_sptr runtime)
- : d_runtime(runtime)
+ : d_impl(mb_mblock_impl_sptr(new mb_mblock_impl())),
+ d_runtime(runtime)
{
// FIXME
}
@@ -56,42 +58,41 @@
// default implementation does nothing
}
-bool
-mb_mblock::register_port(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port_class::port_type_t port_type)
+////////////////////////////////////////////////////////////////////////
+// delegate to mb_mblock_impl //
+////////////////////////////////////////////////////////////////////////
+
+void
+mb_mblock::define_port(pmt_t port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type)
{
- // FIXME
- return true;
+ d_impl->define_port(port_name, protocol_class_name, conjugated, port_type);
}
-bool
-mb_mblock::register_component(const std::string &component_name,
- mb_mblock_sptr component)
+void
+mb_mblock::define_component(const std::string &component_name,
+ mb_mblock_sptr component)
{
- // FIXME
- return true;
+ d_impl->define_component(component_name, component);
}
bool
mb_mblock::connect(const mb_endpoint &endpoint_1, const mb_endpoint
&endpoint_2)
{
- // FIXME
- return true;
+ return d_impl->connect(endpoint_1, endpoint_2);
}
bool
mb_mblock::disconnect(const mb_endpoint &endpoint_1, const mb_endpoint
&endpoint_2)
{
- // FIXME
- return true;
+ return d_impl->disconnect(endpoint_1, endpoint_2);
}
-const std::vector<mb_port_class>
+const std::vector<mb_port_class_sptr>
mb_mblock::peer_interface() const
{
- // FIXME
- std::vector<mb_port_class> r;
- return r;
+ return d_impl->peer_interface();
}
+
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
2006-08-25 08:06:43 UTC (rev 3408)
@@ -78,9 +78,9 @@
* Initializing all mblocks in the system is a 3 step procedure.
*
* Step 1: The top level mblock's constructor is run. That
- * constructor (a) registers all of its ports using register_port
+ * constructor (a) registers all of its ports using define_port
* and (b) constructs and registers any subcomponents it may have
- * via the register_component method. Thus, all mblocks in the
+ * via the define_component method. Thus, all mblocks in the
* system are recursively constructed and the runtime system is
* informed of the hierarchy and all ports on all mblocks.
*
@@ -129,25 +129,25 @@
virtual void handle_message(mb_message_sptr msg);
/*!
- * \brief Create and register a port.
+ * \brief Define a port.
*
* EXTERNAL and RELAY ports are part of our peer interface.
* INTERNAL ports are used to talk to sub-components.
*
- * \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
+ * \param port_name The name [symbol] 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.
*/
- bool
- register_port(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port_class::port_type_t port_type);
+ void
+ define_port(pmt_t port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type);
/*!
- * \brief Register a subcomponent by name.
+ * \brief Define a subcomponent by name.
*
* Called within the constructor to tell the system the
* names and identities of our sub-component mblocks.
@@ -155,9 +155,9 @@
* \param component_name The name of the sub-component (must be unique with
this mblock).
* \param component The sub-component instance.
*/
- bool
- register_component(const std::string &component_name,
- mb_mblock_sptr component);
+ void
+ define_component(const std::string &component_name,
+ mb_mblock_sptr component);
/*!
* \brief connect endpoint_1 to endpoint_2
@@ -187,6 +187,22 @@
bool
disconnect(const mb_endpoint &endpoint_1, const mb_endpoint &endpoint_2);
+ /*!
+ * \brief send a message
+ *
+ * \param port_name name of the port via which we send the message
+ * \param signal the event name
+ * \param data optional data
+ * \param metadata optional metadata
+ * \param priority the urgency at which the message is sent
+ */
+ void
+ send(pmt_t port_name,
+ pmt_t signal,
+ pmt_t data = PMT_NIL,
+ pmt_t metadata = PMT_NIL,
+ mb_pri_t priority = MB_PRI_DEFAULT);
+
public:
virtual ~mb_mblock();
@@ -194,7 +210,7 @@
/*!
* \brief Return a vector that describes this mblock's peer-interface
*/
- const std::vector<mb_port_class> peer_interface() const;
+ const std::vector<mb_port_class_sptr> peer_interface() const;
};
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-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -22,8 +22,8 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-
#include <mb_mblock_impl.h>
+#include <mb_port.h>
mb_mblock_impl::mb_mblock_impl()
{
@@ -34,3 +34,70 @@
{
// FIXME
}
+
+void
+mb_mblock_impl::define_port(pmt_t port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type)
+{
+ if (lookup_port(port_name))
+ throw pmt_exception("mb_mblock_impl::define_port: port_name already
defined", port_name);
+
+ mb_port_sptr p = mb_port_sptr(new mb_port(port_name, protocol_class_name,
+ conjugated, port_type));
+ d_ports.push_back(p);
+}
+
+void
+mb_mblock_impl::define_component(const std::string &component_name,
+ mb_mblock_sptr component)
+{
+ // FIXME
+}
+
+bool
+mb_mblock_impl::connect(const mb_endpoint &endpoint_1, const mb_endpoint
&endpoint_2)
+{
+ // FIXME
+ return true;
+}
+
+bool
+mb_mblock_impl::disconnect(const mb_endpoint &endpoint_1, const mb_endpoint
&endpoint_2)
+{
+ // FIXME
+ return true;
+}
+
+void
+mb_mblock_impl::send(pmt_t port_name, pmt_t signal,
+ pmt_t data, pmt_t metadata, mb_pri_t priority)
+{
+ // FIXME
+}
+
+mb_port_sptr
+mb_mblock_impl::lookup_port(pmt_t port_name)
+{
+ for (std::vector<mb_port_sptr>::iterator p = d_ports.begin();
+ p != d_ports.end(); p++){
+ if (pmt_eq(port_name, (*p)->port_name()))
+ return *p;
+ }
+
+ return mb_port_sptr();
+}
+
+
+
+const std::vector<mb_port_class_sptr>
+mb_mblock_impl::peer_interface() const
+{
+ // FIXME
+ std::vector<mb_port_class_sptr> r;
+ return r;
+}
+
+
+
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-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h
2006-08-25 08:06:43 UTC (rev 3408)
@@ -21,7 +21,7 @@
#ifndef INCLUDED_MB_MBLOCK_IMPL_H
#define INCLUDED_MB_MBLOCK_IMPL_H
-#include <mb_common.h>
+#include <mb_mblock.h>
/*!
* \brief The private implementation details of the mblock system.
@@ -30,6 +30,9 @@
{
private:
+ std::vector<mb_port_sptr> d_ports; // our ports
+
+
// NOT IMPLEMENTED
mb_mblock_impl(const mb_mblock_impl &rhs); // no copy constructor
mb_mblock_impl &operator=(const mb_mblock_impl &rhs); // no assignment
operator
@@ -38,8 +41,93 @@
friend class mb_mblock;
+ /*!
+ * \brief Define a port.
+ *
+ * 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 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,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type);
+
+ /*!
+ * \brief Define a subcomponent by name.
+ *
+ * Called within the constructor to tell the system the
+ * names and identities of our sub-component mblocks.
+ *
+ * \param component_name The name of the sub-component (must be unique with
this mblock).
+ * \param component The sub-component instance.
+ */
+ void
+ define_component(const std::string &component_name,
+ mb_mblock_sptr component);
+
+ /*!
+ * \brief connect endpoint_1 to endpoint_2
+ * \param endpoint_1 one end of the connection
+ * \param endpoint_2 the other end of the connection
+ *
+ * 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);
+
+ /*!
+ * \brief disconnect endpoint_1 from endpoint_2
+ * \param endpoint_1 one end of the connection
+ * \param endpoint_2 the other end of the connection
+ *
+ * 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);
+
+ /*!
+ * \brief send a message
+ *
+ * \param port_name name of the port via which we send the message
+ * \param signal the event name
+ * \param data optional data
+ * \param metadata optional metadata
+ * \param priority the urgency at which the message is sent
+ */
+ void
+ send(pmt_t port_name,
+ pmt_t signal,
+ pmt_t data = PMT_NIL,
+ pmt_t metadata = PMT_NIL,
+ mb_pri_t priority = MB_PRI_DEFAULT);
+
+ ////////////////////////////////////////////////////////////////////////
+
+ mb_port_sptr
+ lookup_port(pmt_t port_name);
+
public:
~mb_mblock_impl();
+
+ /*!
+ * \brief Return a vector that describes this mblock's peer-interface
+ */
+ const std::vector<mb_port_class_sptr> peer_interface() const;
};
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -28,43 +28,17 @@
// mb_port //
////////////////////////////////////////////////////////////////////////
-mb_port::~mb_port()
+mb_port::mb_port(pmt_t port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type)
+ : d_port_class(mb_make_port_class(port_name, protocol_class_name,
+ conjugated, port_type))
{
- // FIXME nop for now
}
-void
-mb_port::send(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
+mb_port::~mb_port()
{
- send(mb_make_message(signal, data, metadata, priority));
-}
-
-////////////////////////////////////////////////////////////////////////
-// mb_simple_port //
-////////////////////////////////////////////////////////////////////////
-
-mb_simple_port::~mb_simple_port()
-{
// FIXME nop for now
}
-void
-mb_simple_port::send(mb_message_sptr message)
-{
- // FIXME nop for now
-}
-
-////////////////////////////////////////////////////////////////////////
-// mb_replicated_port //
-////////////////////////////////////////////////////////////////////////
-
-mb_replicated_port::~mb_replicated_port()
-{
- // FIXME nop for now
-}
-
-void
-mb_replicated_port::send(mb_message_sptr message)
-{
- // FIXME nop for now
-}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h 2006-08-25
03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h 2006-08-25
08:06:43 UTC (rev 3408)
@@ -23,7 +23,6 @@
#include <mb_common.h>
#include <mb_port_class.h>
-#include <mb_message.h>
// ----------------------------------------------------------------------
// mb_port and friends
@@ -35,46 +34,20 @@
// FIXME add internals...
public:
- virtual ~mb_port();
+ mb_port(pmt_t port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type);
+ ~mb_port();
+
// delegations to d_port_class
- const std::string& port_name() const { return d_port_class->port_name(); }
- pmt_t protocol_class() const { return
d_port_class->protocol_class(); }
- bool conjugated() const { return
d_port_class->conjugated(); }
+ pmt_t port_name() const { return
d_port_class->port_name(); }
+ pmt_t protocol_class() const { return
d_port_class->protocol_class(); }
+ bool conjugated() const { return
d_port_class->conjugated(); }
mb_port_class::port_type_t port_type() const { return
d_port_class->port_type(); }
- int min_replic() const { return d_port_class->min_replic();
}
- int max_replic() const { return d_port_class->max_replic();
}
-
- // our functionality
-
- //! build message and send
- void send(pmt_t signal,
- pmt_t data = PMT_NIL,
- pmt_t metadata = PMT_NIL,
- mb_pri_t priority = MB_PRI_DEFAULT);
-
- //! Send pre-built message
- virtual void send(mb_message_sptr message) = 0;
};
-class mb_simple_port : public mb_port
-{
-public:
- ~mb_simple_port();
- //! Send pre-built message to connected port.
- virtual void send(mb_message_sptr message);
-};
-
-class mb_replicated_port : public mb_port
-{
-public:
- ~mb_replicated_port();
-
- //! Send pre-built message to all connected ports.
- virtual void send(mb_message_sptr message);
-};
-
-
#endif /* INCLUDED_MB_PORT_H */
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -27,25 +27,21 @@
#include <mb_protocol_class.h>
mb_port_class_sptr
-mb_make_port_class(const std::string &port_name,
+mb_make_port_class(pmt_t port_name,
const std::string &protocol_class_name,
bool conjugated,
- mb_port_class::port_type_t port_type,
- int min_replic, int max_replic)
+ mb_port_class::port_type_t port_type)
{
return mb_port_class_sptr(new mb_port_class(port_name,
protocol_class_name,
conjugated,
- port_type,
- min_replic,
- max_replic));
+ port_type));
}
-mb_port_class::mb_port_class(const std::string &port_name,
+mb_port_class::mb_port_class(pmt_t port_name,
const std::string &protocol_class_name,
bool conjugated,
- mb_port_class::port_type_t port_type,
- int min_replic, int max_replic)
+ mb_port_class::port_type_t port_type)
: d_port_name(port_name),
d_conjugated(conjugated), d_port_type(port_type)
{
@@ -54,13 +50,4 @@
throw std::runtime_error("mb_port_class: unknown protocol class '" +
protocol_class_name + "'");
}
d_protocol_class = pc;
- if (min_replic < 0 || min_replic > max_replic){
- throw std::invalid_argument(
- "mb_port_class: min_replic must be >= 0 and min_replic must be <=
max_replic");
- }
- if (max_replic < 1){
- throw std::invalid_argument("mb_port_class: max_replic must be >= 1");
- }
- d_min_replic = min_replic;
- d_max_replic = max_replic;
}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
2006-08-25 08:06:43 UTC (rev 3408)
@@ -38,53 +38,44 @@
};
private:
- const std::string d_port_name;
+ pmt_t d_port_name; // symbol
pmt_t d_protocol_class;
bool d_conjugated;
port_type_t d_port_type;
- int d_min_replic;
- int d_max_replic;
// private constructor
- mb_port_class(const std::string &port_name,
+ mb_port_class(pmt_t port_name,
const std::string &protocol_class_name,
bool conjugated,
- mb_port_class::port_type_t port_type,
- int min_replic, int max_replic);
+ mb_port_class::port_type_t port_type);
// public constructor
friend mb_port_class_sptr
- mb_make_port_class(const std::string &port_name,
+ mb_make_port_class(pmt_t port_name,
const std::string &protocol_class_name,
bool conjugated,
- mb_port_class::port_type_t port_type,
- int min_replic, int max_replic);
+ mb_port_class::port_type_t port_type);
public:
- const std::string& port_name() const { return d_port_name; }
- pmt_t protocol_class() const { return
d_protocol_class; }
- bool conjugated() const { return d_conjugated; }
- port_type_t port_type() const { return d_port_type; }
- int min_replic() const { return d_min_replic; }
- int max_replic() const { return d_max_replic; }
+ pmt_t port_name() const { return d_port_name; }
+ pmt_t protocol_class() const { return d_protocol_class; }
+ bool conjugated() const { return d_conjugated; }
+ port_type_t port_type() const { return d_port_type; }
};
/*!
* \brief public constructor for mb_port_class
*
- * \param port_name the port's name
+ * \param port_name the port's name [symbol]
* \param protocol_class_name the name of the associated protocol class
* \param conjugated true if incoming and outgoing mesages sets are swapped
* \param port_type EXTERNAL, RELAY or INTERNAL
- * \param min_replic minimum number of replications of this port
- * \param max_replic maximum number of replications of this port
*/
mb_port_class_sptr
-mb_make_port_class(const std::string &port_name,
+mb_make_port_class(pmt_t port_name,
const std::string &protocol_class_name,
bool conjugated,
- mb_port_class::port_type_t port_type,
- int min_replic = 1, int max_replic = 1);
+ mb_port_class::port_type_t port_type);
#endif /* INCLUDED_MB_PORT_CLASS_H */
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock.cc
2006-08-25 03:28:17 UTC (rev 3407)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -25,14 +25,14 @@
*/
#include <qa_mblock.h>
-// #include <qa_mblock_prims.h>
+#include <qa_mblock_prims.h>
CppUnit::TestSuite *
qa_mblock::suite()
{
CppUnit::TestSuite *s = new CppUnit::TestSuite("mblock");
- // s->addTest (qa_mblock_prims::suite());
+ s->addTest (qa_mblock_prims::suite());
return s;
}
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.cc
2006-08-25 08:06:43 UTC (rev 3408)
@@ -0,0 +1,92 @@
+/* -*- 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <qa_mblock_prims.h>
+#include <cppunit/TestAssert.h>
+#include <mb_mblock.h>
+#include <mb_runtime.h>
+#include <mb_protocol_class.h>
+#include <stdio.h>
+
+static pmt_t s_cs = pmt_intern("cs");
+static pmt_t s_debug = pmt_intern("debug");
+
+class dp_1 : public mb_mblock
+{
+public:
+ dp_1(mb_runtime_sptr runtime);
+ ~dp_1();
+};
+
+dp_1::dp_1(mb_runtime_sptr runtime)
+ : mb_mblock(runtime)
+{
+}
+
+dp_1::~dp_1(){}
+
+class dp_2 : public mb_mblock
+{
+public:
+ dp_2(mb_runtime_sptr runtime);
+ ~dp_2();
+};
+
+dp_2::dp_2(mb_runtime_sptr runtime)
+ : mb_mblock(runtime)
+{
+ define_port(s_cs, "cs_protocol", false, mb_port_class::EXTERNAL);
+}
+
+dp_2::~dp_2(){}
+
+void
+qa_mblock_prims::test_define_ports()
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ std::vector<mb_port_class_sptr> intf;
+
+ mb_mblock_sptr mb1 = mb_mblock_sptr(new dp_1(rt));
+
+ intf = mb1->peer_interface();
+ CPPUNIT_ASSERT_EQUAL(size_t(0), intf.size());
+
+ // raises runtime_error because of unknown protocol "cs_protocol"
+ CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dp_2(rt)), std::runtime_error);
+
+ // define the protocol class
+ pmt_t pc = mb_make_protocol_class(pmt_intern("cs_protocol"),
+ pmt_cons(pmt_intern("start"),
+ pmt_cons(pmt_intern("stop"),
+ PMT_NIL)),
+ PMT_NIL);
+
+ std::cout << "pc = " << pc;
+
+ try {
+ mb_mblock_sptr mb2 = mb_mblock_sptr(new dp_2(rt));
+ }
+ catch (pmt_exception &e){
+ std::cerr << e.msg() << '\n';
+ }
+
+}
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_prims.h
2006-08-25 08:06:43 UTC (rev 3408)
@@ -0,0 +1,39 @@
+/* -*- 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef INCLUDED_QA_MBLOCK_PRIMS_H
+#define INCLUDED_QA_MBLOCK_PRIMS_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_mblock_prims : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_mblock_prims);
+ CPPUNIT_TEST(test_define_ports);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void test_define_ports();
+};
+
+#endif /* INCLUDED_QA_MBLOCK_PRIMS_H */
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3408 - gnuradio/branches/developers/eb/mb/mblock/src/lib,
eb <=