summaryrefslogtreecommitdiff
path: root/gruel
diff options
context:
space:
mode:
Diffstat (limited to 'gruel')
-rw-r--r--gruel/src/include/gruel/msg_accepter.h2
-rw-r--r--gruel/src/include/gruel/msg_passing.h16
-rw-r--r--gruel/src/include/gruel/pmt.h13
-rw-r--r--gruel/src/lib/pmt/pmt.cc16
-rw-r--r--gruel/src/lib/pmt/qa_pmt_prims.cc9
-rw-r--r--gruel/src/swig/pmt_swig.i4
6 files changed, 47 insertions, 13 deletions
diff --git a/gruel/src/include/gruel/msg_accepter.h b/gruel/src/include/gruel/msg_accepter.h
index 2dc1a6859..65abd5a6b 100644
--- a/gruel/src/include/gruel/msg_accepter.h
+++ b/gruel/src/include/gruel/msg_accepter.h
@@ -43,7 +43,7 @@ namespace gruel {
* call will not wait for the message either to arrive at the
* destination or to be received.
*/
- virtual void post(pmt::pmt_t msg) = 0;
+ virtual void post(pmt::pmt_t which_port, pmt::pmt_t msg) = 0;
};
typedef boost::shared_ptr<msg_accepter> msg_accepter_sptr;
diff --git a/gruel/src/include/gruel/msg_passing.h b/gruel/src/include/gruel/msg_passing.h
index 0cc0cd111..7230dfc5b 100644
--- a/gruel/src/include/gruel/msg_passing.h
+++ b/gruel/src/include/gruel/msg_passing.h
@@ -45,9 +45,9 @@ namespace gruel {
* \returns msg
*/
static inline pmt::pmt_t
- send(msg_accepter_sptr accepter, const pmt::pmt_t &msg)
+ send(msg_accepter_sptr accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
{
- accepter->post(msg);
+ accepter->post(which_port, msg);
return msg;
}
@@ -64,9 +64,9 @@ namespace gruel {
* \returns msg
*/
static inline pmt::pmt_t
- send(msg_accepter *accepter, const pmt::pmt_t &msg)
+ send(msg_accepter *accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
{
- accepter->post(msg);
+ accepter->post(which_port, msg);
return msg;
}
@@ -83,9 +83,9 @@ namespace gruel {
* \returns msg
*/
static inline pmt::pmt_t
- send(msg_accepter &accepter, const pmt::pmt_t &msg)
+ send(msg_accepter &accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
{
- accepter.post(msg);
+ accepter.post(which_port, msg);
return msg;
}
@@ -102,9 +102,9 @@ namespace gruel {
* \returns msg
*/
static inline pmt::pmt_t
- send(pmt::pmt_t accepter, const pmt::pmt_t &msg)
+ send(pmt::pmt_t accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
{
- return send(pmt_msg_accepter_ref(accepter), msg);
+ return send(pmt_msg_accepter_ref(accepter), which_port, msg);
}
} /* namespace gruel */
diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h
index 1e8b38627..a462155c5 100644
--- a/gruel/src/include/gruel/pmt.h
+++ b/gruel/src/include/gruel/pmt.h
@@ -729,6 +729,10 @@ GRUEL_API pmt_t pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, con
*/
GRUEL_API pmt_t pmt_list_add(pmt_t list, const pmt_t& item);
+/*!
+ * \brief Return \p list with \p item removed from it.
+ */
+GRUEL_API pmt_t pmt_list_rm(pmt_t list, const pmt_t& item);
/*
* ------------------------------------------------------------------------
@@ -805,6 +809,15 @@ GRUEL_API std::string pmt_serialize_str(pmt_t obj);
*/
GRUEL_API pmt_t pmt_deserialize_str(std::string str);
+/*!
+ * \brief Provide a comparator function object to allow pmt use in stl types
+ */
+class pmt_comperator {
+ public:
+ bool operator()(pmt::pmt_t const& p1, pmt::pmt_t const& p2) const
+ { return pmt::pmt_eqv(p1,p2)?false:p1.get()>p2.get(); }
+ };
+
} /* namespace pmt */
#include <gruel/pmt_sugar.h>
diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc
index 1d9125d4e..3eb39ed7b 100644
--- a/gruel/src/lib/pmt/pmt.cc
+++ b/gruel/src/lib/pmt/pmt.cc
@@ -1325,6 +1325,22 @@ pmt_list_add(pmt_t list, const pmt_t& item)
}
pmt_t
+pmt_list_rm(pmt_t list, const pmt_t& item)
+{
+ if(pmt_is_pair(list)){
+ pmt_t left = pmt_car(list);
+ pmt_t right = pmt_cdr(list);
+ if(!pmt_equal(left, item)){
+ return pmt_cons(left, pmt_list_rm(right, item));
+ } else {
+ return pmt_list_rm(right, item);
+ }
+ } else {
+ return list;
+ }
+}
+
+pmt_t
pmt_caar(pmt_t pair)
{
return (pmt_car(pmt_car(pair)));
diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc
index 6212b8ea4..1bf5fcfb1 100644
--- a/gruel/src/lib/pmt/qa_pmt_prims.cc
+++ b/gruel/src/lib/pmt/qa_pmt_prims.cc
@@ -472,7 +472,7 @@ class qa_pmt_msg_accepter_nop : public gruel::msg_accepter {
public:
qa_pmt_msg_accepter_nop(){};
~qa_pmt_msg_accepter_nop();
- void post(pmt_t){};
+ void post(pmt_t,pmt_t){};
};
qa_pmt_msg_accepter_nop::~qa_pmt_msg_accepter_nop(){}
@@ -495,9 +495,10 @@ qa_pmt_prims::test_msg_accepter()
CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(p0), pmt_wrong_type);
// just confirm interfaces on send are OK
- gruel::send(ma0.get(), sym);
- gruel::send(ma0, sym);
- gruel::send(p1, sym);
+ pmt_t port(pmt_intern("port"));
+ gruel::send(ma0.get(), port, sym);
+ gruel::send(ma0, port, sym);
+ gruel::send(p1, port, sym);
}
diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i
index 45cfceadc..d46143424 100644
--- a/gruel/src/swig/pmt_swig.i
+++ b/gruel/src/swig/pmt_swig.i
@@ -696,6 +696,10 @@ pmt_t pmt_list6(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t&
*/
pmt_t pmt_list_add(pmt_t list, const pmt_t& item);
+/*!
+ * \brief Return \p list with \p item removed
+ */
+pmt_t pmt_list_rm(pmt_t list, const pmt_t& item);
/*
* ------------------------------------------------------------------------