[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3360 - gnuradio/branches/developers/eb/mb/mblock/src/
From: |
eb |
Subject: |
[Commit-gnuradio] r3360 - gnuradio/branches/developers/eb/mb/mblock/src/lib |
Date: |
Sun, 20 Aug 2006 18:16:38 -0600 (MDT) |
Author: eb
Date: 2006-08-20 18:16:37 -0600 (Sun, 20 Aug 2006)
New Revision: 3360
Added:
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
Modified:
gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_common.h
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_protocol_class.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.h
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-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
2006-08-21 00:16:37 UTC (rev 3360)
@@ -32,7 +32,10 @@
# These are the source files that go into the mblock shared library
libmblock_la_SOURCES = \
+ mb_mblock.cc \
mb_message.cc \
+ mb_port.cc \
+ mb_port_class.cc \
mb_protocol_class.cc
@@ -48,6 +51,8 @@
mb_mblock.h \
mb_common.h \
mb_message.h \
+ mb_port.h \
+ mb_port_class.h \
mb_protocol_class.h
noinst_HEADERS = \
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_common.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_common.h
2006-08-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_common.h
2006-08-21 00:16:37 UTC (rev 3360)
@@ -22,8 +22,19 @@
#define INCLUDED_MB_COMMON_H
#include <pmt.h>
+#include <vector>
+#include <stdexcept>
typedef unsigned int mb_pri_t;
static const mb_pri_t MB_PRI_DEFAULT = 5;
+
+
+class mb_port_class;
+typedef boost::shared_ptr<mb_port_class> mb_port_class_sptr;
+
+class mb_port;
+typedef boost::shared_ptr<mb_port> mb_port_sptr;
+
+
#endif /* INCLUDED_MB_COMMON_H */
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-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
2006-08-21 00:16:37 UTC (rev 3360)
@@ -24,47 +24,66 @@
#endif
#include <mb_mblock.h>
+#include <mb_protocol_class.h>
-// ----------------------------------------------------------------------
-// mb_port_class
-// ----------------------------------------------------------------------
+mb_mblock::mb_mblock()
+{
+ // FIXME
+}
-mb_port_class_sptr
-mb_make_port_class(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port::port_type_t port_type,
- int min_replic, int max_replic)
+mb_mblock::~mb_mblock()
{
- return mb_port_class_sptr(new mb_port_class(port_name,
- protocol_class_name,
- conjugated,
- port_type,
- min_replic,
- max_replic));
+ // FIXME
}
-mb_port_class::mb_port_class(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port::port_type_t port_type,
- int min_replic, int max_replic)
- : d_port_name(port_name),
- d_conjugated(conjugated), d_port_type(port_type),
+bool
+mb_mblock::connect_components()
{
- mb_protocol_class_sptr pc =
- mb_protocol_class::lookup(pmt_intern(protocol_class_name));
- if (!pc){
- throw FIXME;
- }
- d_protocol_class = pc;
- if (min_replic < 0 || min_replic > max_replic){
- throw FIXME;
- }
- if (max_replic < 1){
- throw FIXME;
- }
- d_min_replic = min_replic;
- d_max_replic = max_replic;
+ // default implementation returns true
+ return true;
}
+void
+mb_mblock::init_fsm()
+{
+ // default implementation does nothing
+}
+
+void
+mb_mblock::handle_message(mb_message_sptr msg)
+{
+ // 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)
+{
+ // FIXME
+ return true;
+}
+
+bool
+mb_mblock::register_component(const std::string &component_name,
+ mb_mblock_sptr component)
+{
+ // FIXME
+ return true;
+}
+
+bool
+mb_mblock::connect(const std::string &endpoint_1, const std::string
&endpoint_2)
+{
+ // FIXME
+ return true;
+}
+
+const std::vector<mb_port_class>
+mb_mblock::peer_interface() const
+{
+ // FIXME
+ std::vector<mb_port_class> r;
+ return r;
+}
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-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
2006-08-21 00:16:37 UTC (rev 3360)
@@ -22,167 +22,144 @@
#define INCLUDED_MB_MBLOCK_H
#include <mb_common.h>
+#include <mb_message.h>
+#include <mb_port_class.h>
+#include <mb_port.h>
// ----------------------------------------------------------------------
// forward declarations...
// ----------------------------------------------------------------------
+class mb_runtime;
+
class mb_mblock;
typedef boost::shared_ptr<mb_mblock> mb_mblock_sptr;
-class mb_port_class;
-typedef boost::shared_ptr<mb_port_class> mb_port_class_sptr;
-
-class mb_port;
-typedef boost::shared_ptr<mb_port> mb_port_sptr;
-
// ----------------------------------------------------------------------
-// mb_port_class
+// mb_mblock -- subclass this to define your mblocks.
// ----------------------------------------------------------------------
/*!
- * \brief public constructor for mb_port_class
- *
- * \param port_name the port's name
- * \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
+ * \brief Parent class for all message passing blocks (mblock)
*/
-mb_port_class_sptr
-mb_make_port_class(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port::port_type_t port_type,
- int min_replic = 1, int max_replic = 1);
-/*!
- * \brief Public port characteristics
- */
-class mb_port_class
-{
-public:
- //! port classification
- enum { EXTERNAL, //< Externally visible
- RELAY, //< Externally visible but really connected to a
sub-component
- INTERNAL //< Visible to self only
- } port_type_t;
-
-private:
- const std::string d_port_name;
- mb_protocol_class_sptr 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,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port::port_type_t port_type,
- int min_replic, int max_replic);
-
- // public constructor
- friend mb_port_class_sptr
- mb_make_port_class(const std::string &port_name,
- const std::string &protocol_class_name,
- bool conjugated,
- mb_port::port_type_t port_type,
- int min_replic, int max_replic);
-
-public:
- const std::string& port_name() const { return d_port_name; }
- mb_portocol_class_sptr 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; }
-};
-
-// ----------------------------------------------------------------------
-// mb_port and friends
-// ----------------------------------------------------------------------
-
-class mb_port
-{
- mb_port_class_sptr d_port_class;
- // FIXME add internals...
-
-public:
-
- // delegations to d_port_class
-
- const std::string& port_name() const { return d_port_class->port_name();
}
- mb_portocol_class_sptr protocol_class() const { return
d_port_class->protocol_class(); }
- bool conjugated() const { return
d_port_class->conjugated(); }
- 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:
- //! Send pre-built message to connected port.
- virtual void send(mb_message_sptr message);
-};
-
-class mb_replicated_port : public mb_port
-{
-public:
- //! Send pre-built message to all connected ports.
- virtual void send(mb_message_sptr message);
-};
-
-// ----------------------------------------------------------------------
-// mb_mblock
-// ----------------------------------------------------------------------
class mb_mblock
{
private:
+ friend class mb_runtime;
+
// NOT IMPLEMENTED
mb_mblock (const mb_mblock &rhs); // no copy constructor
mb_mblock &operator= (const mb_mblock &rhs); // no assignment operator
protected:
+ /*!
+ * \brief mblock constructor.
+ *
+ * This is step 1 of the 3 step start up procedure.
+ *
+ * Initializing all mblocks in the system is a 3 step procedure.
+ *
+ * Step 1: The top level mblock's constructor is run. That
+ * constructor constructs any subcomponents it may have and
+ * registers them using the register_component method. Thus, all
+ * mblocks in the system are recursively constructed and the runtime
+ * system is informed of the hierarchy.
+ *
+ * Step 2: After step 1 is complete, the runtime system invokes the
+ * connect_components method of each mblock. If an mblock has
+ * component mblocks, it must issue all connect calls at this time.
+ *
+ * Step 3: After step 2 is complete, the runtime system fires the initial
+ * transition of each mblock by invoking it's init_fsm method.
+ *
+ * At this point the system is live.
+ */
mb_mblock();
- mb_port_sptr
+ /*!
+ * \brief Called by the runtime system to instruct this mblock to
+ * connect up any subcomponents it may have.
+ *
+ * This is step 2 of the 3 step start up procedure.
+ */
+ virtual bool connect_components();
+
+ /*!
+ * \brief Called by the runtime system to execute the initial transition of
the
+ * finite state machine.
+ *
+ * This is step 3 of the 3 step start up proceedure.
+ */
+ virtual void init_fsm();
+
+ /*!
+ * \brief Called by the runtime system when there's a message to handle.
+ *
+ * Override this to define your behavior.
+ *
+ * Do not issue any potentially blocking calls in this method. This
+ * includes things such reads or writes on sockets, pipes or slow
+ * i/o devices.
+ */
+ virtual void handle_message(mb_message_sptr msg);
+
+ /*!
+ * \brief Create and register 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
+ * 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::port_type_t port_type,
- int min_replic = 1, int max_replic = 1);
+ mb_port_class::port_type_t port_type);
- void
+ /*!
+ * \brief Register 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.
+ */
+ bool
register_component(const std::string &component_name,
- mb_block_sptr component);
+ mb_mblock_sptr component);
+ /*!
+ * \brief connect endpoint_1 to endpoint_2
+ * \param endpoint_1 "component_name/port_name"
+ * \param endpoint_2 "component_name/port_name"
+ *
+ * An endpoint is specified by a string composed of the component's
+ * local name (given as component_name in the call to
+ * register_component) a "/" and the name of the port on that component.
+ *
+ * E.g., "my_subcomponent/control" would refer to the port called
+ * "control" on the nested mblock called "my_subcomponent". To
+ * connect to an internal or relay port, use "self" for the
+ * component name.
+ */
bool
- connect(const std::string &c1_comp_name, const std::string &c1_port_name,
- const std::string &c2_comp_name, const std::string &c2_port_name);
+ connect(const std::string &endpoint_1, const std::string &endpoint_2);
- virtual bool connect_components();
- virtual bool start_fsm(pmt_t data, pmt_t metadata) = 0;
-
public:
virtual ~mb_mblock();
- const std::vector<mb_port_class> &peer_interface() const;
+ /*!
+ * \brief Return a vector that describes this mblock's peer-interface
+ */
+ const std::vector<mb_port_class> peer_interface() const;
};
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
2006-08-21 00:16:37 UTC (rev 3360)
@@ -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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <mb_port.h>
+
+////////////////////////////////////////////////////////////////////////
+// mb_port //
+////////////////////////////////////////////////////////////////////////
+
+mb_port::~mb_port()
+{
+ // FIXME nop for now
+}
+
+void
+mb_port::send(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
+{
+ 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
+}
Property changes on:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h 2006-08-21
00:16:37 UTC (rev 3360)
@@ -0,0 +1,80 @@
+/* -*- 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_PORT_H
+#define INCLUDED_MB_PORT_H
+
+#include <mb_common.h>
+#include <mb_port_class.h>
+#include <mb_message.h>
+
+// ----------------------------------------------------------------------
+// mb_port and friends
+// ----------------------------------------------------------------------
+
+class mb_port
+{
+ mb_port_class_sptr d_port_class;
+ // FIXME add internals...
+
+public:
+ virtual ~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(); }
+ 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 */
Property changes on: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
2006-08-21 00:16:37 UTC (rev 3360)
@@ -0,0 +1,66 @@
+/* -*- 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_port_class.h>
+#include <mb_protocol_class.h>
+
+mb_port_class_sptr
+mb_make_port_class(const std::string &port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type,
+ int min_replic, int max_replic)
+{
+ return mb_port_class_sptr(new mb_port_class(port_name,
+ protocol_class_name,
+ conjugated,
+ port_type,
+ min_replic,
+ max_replic));
+}
+
+mb_port_class::mb_port_class(const std::string &port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type,
+ int min_replic, int max_replic)
+ : d_port_name(port_name),
+ d_conjugated(conjugated), d_port_type(port_type)
+{
+ pmt_t pc = mb_protocol_class_lookup(pmt_intern(protocol_class_name));
+ if (pmt_is_null(pc)){
+ 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;
+}
Property changes on:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
(rev 0)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
2006-08-21 00:16:37 UTC (rev 3360)
@@ -0,0 +1,90 @@
+/* -*- 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_PORT_CLASS_H
+#define INCLUDED_MB_PORT_CLASS_H
+
+#include <mb_common.h>
+
+/*!
+ * \brief Public port characteristics
+ */
+class mb_port_class
+{
+public:
+
+ //! port classification
+ enum port_type_t {
+ EXTERNAL, //< Externally visible
+ RELAY, //< Externally visible but really connected to a sub-component
+ INTERNAL //< Visible to self only
+ };
+
+private:
+ const std::string d_port_name;
+ 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,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type,
+ int min_replic, int max_replic);
+
+ // public constructor
+ friend mb_port_class_sptr
+ mb_make_port_class(const std::string &port_name,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type,
+ int min_replic, int max_replic);
+
+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; }
+};
+
+/*!
+ * \brief public constructor for mb_port_class
+ *
+ * \param port_name the port's name
+ * \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,
+ const std::string &protocol_class_name,
+ bool conjugated,
+ mb_port_class::port_type_t port_type,
+ int min_replic = 1, int max_replic = 1);
+
+
+#endif /* INCLUDED_MB_PORT_CLASS_H */
Property changes on:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_port_class.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.cc
2006-08-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.cc
2006-08-21 00:16:37 UTC (rev 3360)
@@ -25,25 +25,58 @@
#include <mb_protocol_class.h>
+static pmt_t s_ALL_PROTOCOL_CLASSES = PMT_NIL;
-mb_protocol_class_sptr
+pmt_t
mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing)
{
- return mb_protocol_class_sptr(new mb_protocol_class(name, incoming,
outgoing));
+ // (protocol-class <name> <incoming> <outgoing>)
+
+ if (!pmt_is_symbol(name))
+ throw pmt_wrong_type("mb_make_protocol_class: NAME must be symbol", name);
+ if (!(pmt_is_pair(incoming) || pmt_is_null(incoming)))
+ throw pmt_wrong_type("mb_make_protocol_class: INCOMING must be a list",
name);
+ if (!(pmt_is_pair(outgoing) || pmt_is_null(outgoing)))
+ throw pmt_wrong_type("mb_make_protocol_class: OUTGOING must be a list",
name);
+
+ pmt_t t = pmt_cons(pmt_intern("protocol-class"),
+ pmt_cons(name,
+ pmt_cons(incoming,
+ pmt_cons(outgoing, PMT_NIL))));
+
+ // Remember this protocol class.
+ s_ALL_PROTOCOL_CLASSES = pmt_cons(t, s_ALL_PROTOCOL_CLASSES);
+ return t;
}
-mb_protocol_class::mb_protocol_class(pmt_t name, pmt_t incoming, pmt_t
outgoing)
- : d_name(name), d_incoming(incoming), d_outgoing(outgoing)
+pmt_t
+mb_protocol_class_name(pmt_t pc)
{
+ return pmt_nth(1, pc);
}
-mb_protocol_class::~mb_protocol_class()
+pmt_t
+mb_protocol_class_incoming(pmt_t pc)
{
- // NOP
+ return pmt_nth(2, pc);
}
-mb_protocol_class_sptr
-mb_protocol_class::lookup(pmt_t name)
+pmt_t
+mb_protocol_class_outgoing(pmt_t pc)
{
- return 0; // FIXME
+ return pmt_nth(3, pc);
}
+
+pmt_t
+mb_protocol_class_lookup(pmt_t name)
+{
+ pmt_t lst = s_ALL_PROTOCOL_CLASSES;
+
+ while (pmt_is_pair(lst)){
+ if (pmt_eq(name, mb_protocol_class_name(pmt_car(lst))))
+ return pmt_car(lst);
+ lst = pmt_cdr(lst);
+ }
+
+ return PMT_NIL;
+}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.h
2006-08-20 18:08:05 UTC (rev 3359)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_protocol_class.h
2006-08-21 00:16:37 UTC (rev 3360)
@@ -23,41 +23,20 @@
#include <mb_common.h>
-// FIXME maybe this should just be a pmt_t aggregate???
-
-class mb_protocol_class;
-typedef boost::shared_ptr<mb_protocol_class> mb_protocol_class_sptr;
-
/*!
- * \brief construct a protocol_class and return boost::shared_ptr
+ * \brief construct a protocol_class
*
* \param name the name of the class (symbol)
- * \param incoming incoming message set (dict: keys are message types)
- * \param outgoing outgoing message set (dict: keys are message types)
+ * \param incoming incoming message set (list of symbols)
+ * \param outgoing outgoing message set (list of symbols)
*/
-mb_protocol_class_sptr
-mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing);
+pmt_t mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing);
-class mb_protocol_class {
- pmt_t d_name;
- pmt_t d_incoming;
- pmt_t d_outgoing;
+// Accessors
+pmt_t mb_protocol_class_name(pmt_t pc); //< return name of
protocol class
+pmt_t mb_protocol_class_incoming(pmt_t pc); //< return incoming message set
+pmt_t mb_protocol_class_outgoing(pmt_t pc); //< return outgoing message set
- friend mb_protocol_class_sptr
- mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing);
+pmt_t mb_protocol_class_lookup(pmt_t name); //< lookup an existing protocol
class by name
- // private constructor
- mb_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing);
-
-public:
- ~mb_protocol_class();
-
- pmt_t name() const { return d_name; }
- pmt_t incoming() const { return d_incoming; }
- pmt_t outgoing() const { return d_outgoing; }
-
- //! look for a protocol class by name
- static mb_protocol_class_sptr lookup(pmt_t name);
-};
-
#endif /* INCLUDED_MB_PROTOCOL_CLASS_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3360 - gnuradio/branches/developers/eb/mb/mblock/src/lib,
eb <=