[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4881 - gnuradio/branches/developers/eb/ibu/mblock/src
From: |
eb |
Subject: |
[Commit-gnuradio] r4881 - gnuradio/branches/developers/eb/ibu/mblock/src/lib |
Date: |
Wed, 4 Apr 2007 21:55:12 -0600 (MDT) |
Author: eb
Date: 2007-04-04 21:55:12 -0600 (Wed, 04 Apr 2007)
New Revision: 4881
Added:
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.cc
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.h
Modified:
gnuradio/branches/developers/eb/ibu/mblock/src/lib/Makefile.am
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.cc
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.h
gnuradio/branches/developers/eb/ibu/mblock/src/lib/qa_mblock_send.cc
Log:
work-in-progress
Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/Makefile.am
2007-04-05 03:42:49 UTC (rev 4880)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/Makefile.am
2007-04-05 03:55:12 UTC (rev 4881)
@@ -33,6 +33,7 @@
# These are the source files that go into the mblock shared library
libmblock_la_SOURCES = \
+ mb_class_registry.cc \
mb_connection.cc \
mb_endpoint.cc \
mb_exception.cc \
@@ -62,6 +63,7 @@
-lstdc++
include_HEADERS = \
+ mb_class_registry.h \
mb_common.h \
mb_exception.h \
mb_mblock.h \
Added: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.cc
(rev 0)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.cc
2007-04-05 03:55:12 UTC (rev 4881)
@@ -0,0 +1,47 @@
+/* -*- 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_class_registry.h>
+#include <map>
+
+static std::map<std::string, mb_mblock_maker_t> s_registry;
+
+bool
+mb_class_registry::register_maker(const std::string &name, mb_mblock_maker_t
maker)
+{
+ s_registry[name] = maker;
+ return true;
+}
+
+bool
+mb_class_registry::lookup_maker(const std::string &name, mb_mblock_maker_t
*maker)
+{
+ if (s_registry.count(name) == 0){ // not registered
+ *maker = (mb_mblock_maker_t) 0;
+ return false;
+ }
+
+ *maker = s_registry[name];
+ return true;
+}
Added: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.h
(rev 0)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_class_registry.h
2007-04-05 03:55:12 UTC (rev 4881)
@@ -0,0 +1,43 @@
+/* -*- 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_CLASS_REGISTRY_H
+#define INCLUDED_MB_CLASS_REGISTRY_H
+
+#include <mb_common.h>
+
+typedef mb_mblock_sptr (*mb_mblock_maker_t)(); // conceptually, pointer to
constructor
+
+class mb_class_registry : public boost::noncopyable {
+public:
+ static bool register_maker(const std::string &name, mb_mblock_maker_t maker);
+ static bool lookup_maker(const std::string &name, mb_mblock_maker_t *maker);
+};
+
+template<class mblock>
+mb_mblock_sptr mb_mblock_maker()
+{
+ return mb_mblock_sptr(new mblock());
+}
+
+#define REGISTER_MBLOCK_CLASS(name) \
+ bool __RBC__ ## name = mb_class_registry::register_maker(#name,
&mb_mblock_maker<name>)
+
+#endif /* INCLUDED_MB_CLASS_REGISTRY_H */
Modified:
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.cc
===================================================================
---
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.cc
2007-04-05 03:42:49 UTC (rev 4880)
+++
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.cc
2007-04-05 03:55:12 UTC (rev 4881)
@@ -25,8 +25,11 @@
#include <mb_runtime_thread_per_mblock.h>
#include <mb_mblock.h>
#include <mb_mblock_impl.h>
+#include <omnithread.h>
+
+
mb_runtime_thread_per_mblock::mb_runtime_thread_per_mblock()
{
// nop for now
@@ -63,3 +66,4 @@
return true;
}
+
Modified:
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.h
===================================================================
---
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.h
2007-04-05 03:42:49 UTC (rev 4880)
+++
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_mblock.h
2007-04-05 03:55:12 UTC (rev 4881)
@@ -24,7 +24,7 @@
#include <mb_runtime.h>
/*!
- * \brief Concrete runtime that uses a single thread for all work.
+ * \brief Concrete runtime that uses a thread per mblock
*/
class mb_runtime_thread_per_mblock : public mb_runtime
{
Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/qa_mblock_send.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/qa_mblock_send.cc
2007-04-05 03:42:49 UTC (rev 4880)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/qa_mblock_send.cc
2007-04-05 03:55:12 UTC (rev 4881)
@@ -35,6 +35,7 @@
#include <mb_message.h>
#include <mb_mblock_impl.h>
#include <mb_msg_accepter.h>
+#include <mb_class_registry.h>
#include <stdio.h>
static pmt_t s_data = pmt_intern("data");
@@ -98,6 +99,8 @@
d_p2->send(s_status, pmt_list3(our_name, s_p2, pmt_from_long(1)));
}
+REGISTER_MBLOCK_CLASS(sr1);
+
// ----------------------------------------------------------------
// top-level container block for test_simple_routing
@@ -113,9 +116,15 @@
sr0::sr0()
{
+ mb_mblock_maker_t maker;
+
d_p0 = define_port("p0", "qa-send-cs", false, mb_port::INTERNAL);
- define_component("mb1", mb_mblock_sptr(new sr1()));
+ //define_component("mb1", mb_mblock_sptr(new sr1()));
+ //define_component("mb1", mb_mblock_maker<sr1>()); // experiment w/ maker
+ mb_class_registry::lookup_maker("sr1", &maker);
+ define_component("mb1", maker()); // experiment w/ maker
+
define_component("mb2", mb_mblock_sptr(new sr1()));
connect("self", "p0", "mb1", "p1");
@@ -449,3 +458,4 @@
CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c0/c0"), s_p1,
pmt_from_long(1)),
msg->data()));
}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4881 - gnuradio/branches/developers/eb/ibu/mblock/src/lib,
eb <=