[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4365 - gnuradio/branches/developers/eb/mb/mblock/src/
From: |
eb |
Subject: |
[Commit-gnuradio] r4365 - gnuradio/branches/developers/eb/mb/mblock/src/lib |
Date: |
Sat, 3 Feb 2007 19:40:19 -0700 (MST) |
Author: eb
Date: 2007-02-03 19:40:19 -0700 (Sat, 03 Feb 2007)
New Revision: 4365
Added:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.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_runtime.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.h
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_util.cc
gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_send.cc
Log:
work-in-progress on mblocks
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/Makefile.am
2007-02-04 02:40:19 UTC (rev 4365)
@@ -44,6 +44,7 @@
mb_port_simple.cc \
mb_protocol_class.cc \
mb_runtime.cc \
+ mb_runtime_single_threaded.cc \
mb_util.cc
@@ -67,6 +68,7 @@
mb_port_simple.h \
mb_protocol_class.h \
mb_runtime.h \
+ mb_runtime_single_threaded.h \
mb_util.h
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -27,6 +27,12 @@
#include <mb_mblock_impl.h>
+mb_visitor::~mb_visitor()
+{
+ // nop base case for virtual destructor.
+}
+
+
mb_mblock::mb_mblock()
: d_impl(mb_mblock_impl_sptr(new mb_mblock_impl(this)))
{
@@ -113,3 +119,9 @@
{
return d_impl->walk_tree(visitor, path);
}
+
+std::string
+mb_mblock::fullname() const
+{
+ return d_impl->fullname();
+}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock.h
2007-02-04 02:40:19 UTC (rev 4365)
@@ -35,8 +35,7 @@
{
public:
virtual ~mb_visitor();
- bool operator()(mb_mblock *mblock, const std::string &path) { return
visit(mblock, path); }
- virtual bool visit(mb_mblock *mblock, const std::string &path) = 0;
+ virtual bool operator()(mb_mblock *mblock, const std::string &path) = 0;
};
// ----------------------------------------------------------------------
@@ -69,6 +68,7 @@
*/
mb_mblock();
+public:
/*!
* \brief Called by the runtime system to execute the initial
* transition of the finite state machine.
@@ -77,6 +77,7 @@
*/
virtual void init_fsm();
+protected:
/*!
* \brief Called by the runtime system when there's a message to handle.
*
@@ -178,13 +179,16 @@
public:
virtual ~mb_mblock();
+ //! Return full name of this block
+ std::string fullname() const;
+
/*!
* \brief Perform a pre-order depth-first traversal of the hierarchy.
*
* The traversal stops and returns false if any call to visitor returns
false.
*/
bool
- walk_tree(mb_visitor *visitor, const std::string &path="");
+ walk_tree(mb_visitor *visitor, const std::string &path="top");
//! \implementation
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
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -51,7 +51,7 @@
////////////////////////////////////////////////////////////////////////
mb_mblock_impl::mb_mblock_impl(mb_mblock *mb)
- : d_mb(mb), d_mb_parent(0)
+ : d_mb(mb), d_mb_parent(0), d_fullname("top")
{
}
@@ -90,8 +90,10 @@
if (comp_is_defined(name)) // check for duplicate name
throw mbe_duplicate_component(d_mb, name);
- component->d_impl->d_mb_parent = d_mb; // set component's parent link
+ component->d_impl->d_mb_parent = d_mb; // set component's parent link
d_comp_map[name] = component;
+
+ component->d_impl->set_fullname(this->fullname() + "/" + name); // set
hierarchical name
}
void
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
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_mblock_impl.h
2007-02-04 02:40:19 UTC (rev 4365)
@@ -40,6 +40,8 @@
mb_mblock *d_mb; // pointer to our associated
mblock
mb_mblock *d_mb_parent; // pointer to our parent
+ std::string d_fullname; // hierarchical name
+
mb_port_map_t d_port_map; // our ports
mb_comp_map_t d_comp_map; // our components
mb_conn_table d_conn_table; // our connections
@@ -145,6 +147,9 @@
mb_msg_queue &
msgq() { return d_msgq; }
+ //! Return full name of this block
+ std::string fullname() const { return d_fullname; }
+
/*
* Our implementation methods
*/
@@ -166,6 +171,8 @@
static bool
ports_are_compatible(mb_port_sptr p0, mb_port_sptr p1);
+ //! Set the name of this block
+ void set_fullname(const std::string &name){ d_fullname = name; }
};
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.cc
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -24,27 +24,15 @@
#endif
#include <mb_runtime.h>
+#include <mb_runtime_single_threaded.h>
mb_runtime_sptr
mb_make_runtime()
{
- return mb_runtime_sptr(new mb_runtime());
+ return mb_runtime_sptr(new mb_runtime_single_threaded());
}
-mb_runtime::mb_runtime()
-{
- // FIXME
-
-}
-
mb_runtime::~mb_runtime()
{
- // FIXME
+ // nop
}
-
-bool
-mb_runtime::run()
-{
- // FIXME
- return true;
-}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.h
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.h
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime.h
2007-02-04 02:40:19 UTC (rev 4365)
@@ -24,38 +24,31 @@
#include <mb_common.h>
/*!
- * \brief Public constructor for mb_runtime.
+ * \brief Public constructor (factory) for mb_runtime objects.
*/
mb_runtime_sptr mb_make_runtime();
/*!
- * \brief Runtime support for m-blocks
+ * \brief Abstract runtime support for m-blocks
*
* There should generally be only a single instance of this class.
- *
- * It should be created by the top-level initialization code,
- * and that instance should be passed into the constructor of the
- * top-level mblock.
*/
class mb_runtime : boost::noncopyable
{
-private:
- mb_runtime();
-
- friend mb_runtime_sptr mb_make_runtime();
-
public:
- ~mb_runtime();
+ mb_runtime(){}
+ virtual ~mb_runtime();
/*!
- * \brief Run the mblocks...
+ * \brief Run the mblock hierarchy rooted at \p top
*
* This routine turns into the m-block scheduler, and
* blocks until the system is shutdown.
*
+ * \param top top-level mblock
* \returns true if the system ran successfully.
*/
- bool run();
+ virtual bool run(mb_mblock_sptr top) = 0;
};
#endif /* INCLUDED_MB_RUNTIME_H */
Added:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.cc
===================================================================
---
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.cc
(rev 0)
+++
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -0,0 +1,59 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_runtime_single_threaded.h>
+#include <mb_mblock.h>
+
+
+mb_runtime_single_threaded::mb_runtime_single_threaded()
+{
+ // nop for now
+}
+
+mb_runtime_single_threaded::~mb_runtime_single_threaded()
+{
+ // nop for now
+}
+
+bool
+mb_runtime_single_threaded::run(mb_mblock_sptr top)
+{
+ class initial_visitor : public mb_visitor
+ {
+ public:
+ bool operator()(mb_mblock *mblock, const std::string &path)
+ {
+ mblock->init_fsm();
+ return true;
+ }
+ };
+
+ initial_visitor visitor;
+
+ d_top = top; // remember top of tree
+
+ d_top->walk_tree(&visitor);
+
+ return true;
+}
Added:
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.h
===================================================================
---
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.h
(rev 0)
+++
gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_runtime_single_threaded.h
2007-02-04 02:40:19 UTC (rev 4365)
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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_RUNTIME_SINGLE_THREADED_H
+#define INCLUDED_MB_RUNTIME_SINGLE_THREADED_H
+
+#include <mb_runtime.h>
+
+/*!
+ * \brief Concrete runtime that uses a single thread for all work.
+ */
+class mb_runtime_single_threaded : public mb_runtime
+{
+ mb_mblock_sptr d_top; // top mblock
+
+public:
+ mb_runtime_single_threaded();
+ ~mb_runtime_single_threaded();
+
+ bool run(mb_mblock_sptr top);
+};
+
+
+
+#endif /* INCLUDED_MB_RUNTIME_SINGLE_THREADED_H */
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_util.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_util.cc
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/mb_util.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -30,5 +30,5 @@
mb_util::join_names(const std::string &comp_name,
const std::string &port_name)
{
- return comp_name + "/" + port_name;
+ return comp_name + ":" + port_name;
}
Modified: gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_send.cc
===================================================================
--- gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_send.cc
2007-02-04 02:14:23 UTC (rev 4364)
+++ gnuradio/branches/developers/eb/mb/mblock/src/lib/qa_mblock_send.cc
2007-02-04 02:40:19 UTC (rev 4365)
@@ -74,6 +74,7 @@
sr1::init_fsm()
{
// FIXME send two messages to each port
+ std::cout << fullname() << "[sr1]: init_fsm\n";
}
// ----------------------------------------------------------------
@@ -93,11 +94,20 @@
{
d_p0 = define_port("p0", "simple-send", false, mb_port::INTERNAL);
- define_component("mb1", mb_mblock_sptr(new sr1()));
- define_component("mb2", mb_mblock_sptr(new sr1()));
+ mb_mblock_sptr mb1;
+ mb_mblock_sptr mb2;
+ define_component("mb1", mb1 = mb_mblock_sptr(new sr1()));
+ define_component("mb2", mb2 = mb_mblock_sptr(new sr1()));
connect("self", "p0", "mb1", "p1");
connect("mb1", "p2", "mb2", "p2");
+
+ if (0){
+ std::cout << '\n';
+ std::cout << fullname() << '\n';
+ std::cout << mb1->fullname() << '\n';
+ std::cout << mb2->fullname() << '\n';
+ }
}
sr0::~sr0(){}
@@ -106,6 +116,7 @@
sr0::init_fsm()
{
// FIXME send two messages to p0
+ std::cout << fullname() << "[sr0]: init_fsm\n";
}
// ----------------------------------------------------------------
@@ -123,6 +134,7 @@
mb_mblock_sptr mb0 = mb_mblock_sptr(new sr0());
- // FIXME create runtime, have it fire the initial transitions
+ mb_runtime_sptr rt = mb_make_runtime();
+ rt->run(mb0);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4365 - gnuradio/branches/developers/eb/mb/mblock/src/lib,
eb <=