summaryrefslogtreecommitdiff
path: root/gruel/src
diff options
context:
space:
mode:
Diffstat (limited to 'gruel/src')
-rw-r--r--gruel/src/include/gruel/msg_accepter.h4
-rw-r--r--gruel/src/include/gruel/msg_passing.h20
-rw-r--r--gruel/src/include/gruel/pmt.h13
-rw-r--r--gruel/src/include/gruel/pmt_sugar.h6
-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/CMakeLists.txt2
-rw-r--r--gruel/src/swig/pmt_swig.i4
8 files changed, 59 insertions, 15 deletions
diff --git a/gruel/src/include/gruel/msg_accepter.h b/gruel/src/include/gruel/msg_accepter.h
index 2dc1a6859..45acb3c78 100644
--- a/gruel/src/include/gruel/msg_accepter.h
+++ b/gruel/src/include/gruel/msg_accepter.h
@@ -37,13 +37,13 @@ namespace gruel {
virtual ~msg_accepter();
/*!
- * \brief send \p msg to \p msg_accepter
+ * \brief send \p msg to \p msg_accepter on port \p which_port
*
* Sending a message is an asynchronous operation. The \p post
* 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..25f30118f 100644
--- a/gruel/src/include/gruel/msg_passing.h
+++ b/gruel/src/include/gruel/msg_passing.h
@@ -36,6 +36,7 @@ namespace gruel {
* \brief send message to msg_accepter
*
* \param accepter is the target of the send.
+ * \param which_port A pmt symbol describing the port by name.
* \param msg is the message to send. It's usually a pmt tuple.
*
* Sending a message is an asynchronous operation. The \p send
@@ -45,9 +46,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;
}
@@ -55,6 +56,7 @@ namespace gruel {
* \brief send message to msg_accepter
*
* \param accepter is the target of the send.
+ * \param which_port A pmt symbol describing the port by name.
* \param msg is the message to send. It's usually a pmt tuple.
*
* Sending a message is an asynchronous operation. The \p send
@@ -64,9 +66,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;
}
@@ -74,6 +76,7 @@ namespace gruel {
* \brief send message to msg_accepter
*
* \param accepter is the target of the send.
+ * \param which_port A pmt symbol describing the port by name.
* \param msg is the message to send. It's usually a pmt tuple.
*
* Sending a message is an asynchronous operation. The \p send
@@ -83,9 +86,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;
}
@@ -93,6 +96,7 @@ namespace gruel {
* \brief send message to msg_accepter
*
* \param accepter is the target of the send. precond: pmt_is_msg_accepter(accepter)
+ * \param which_port A pmt symbol describing the port by name.
* \param msg is the message to send. It's usually a pmt tuple.
*
* Sending a message is an asynchronous operation. The \p send
@@ -102,9 +106,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/include/gruel/pmt_sugar.h b/gruel/src/include/gruel/pmt_sugar.h
index 1d2b38ff1..bde7f716d 100644
--- a/gruel/src/include/gruel/pmt_sugar.h
+++ b/gruel/src/include/gruel/pmt_sugar.h
@@ -50,6 +50,12 @@ namespace pmt {
//! Make pmt long
static inline pmt_t
+ mp(long long unsigned x){
+ return pmt_from_long(x);
+ }
+
+ //! Make pmt long
+ static inline pmt_t
mp(int x){
return pmt_from_long(x);
}
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/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt
index 332d5866f..a5e3f9399 100644
--- a/gruel/src/swig/CMakeLists.txt
+++ b/gruel/src/swig/CMakeLists.txt
@@ -24,7 +24,7 @@ include(GrPython)
include(GrSwig)
set(GR_SWIG_TARGET_DEPS pmt_generated)
-set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
+set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS})
set(GR_SWIG_LIBRARIES gruel)
set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i)
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);
/*
* ------------------------------------------------------------------------