Skip to content
Browse files

switch to signals2, use boost::function for error callback

  • Loading branch information...
1 parent 6c44646 commit 4221157422ee03c64e7a18a9596c3fc7df791042 @jmesmon committed Mar 22, 2012
Showing with 18 additions and 10 deletions.
  1. +4 −3 include/jaguar/can_bridge.h
  2. +4 −3 include/jaguar/jaguar_bridge.h
  3. +3 −1 src/jaguar_bridge.cc
  4. +7 −3 src/unbrick.cc
View
7 include/jaguar/can_bridge.h
@@ -34,9 +34,10 @@ class CANMessage {
class CANBridge {
public:
- typedef boost::function<void (CANMessage::Ptr)> Callback;
- typedef boost::function<void (CANMessage::Ptr)> recv_callback;
- typedef void (error_callback)(char const *func, char const *file, unsigned line, std::string const &msg);
+ typedef void recv_callback_sig(CANMessage::Ptr);
+ typedef boost::function<recv_callback_sig> recv_callback;
+ typedef void error_callback_sig(char const *func, char const *file, unsigned line, std::string const &msg);
+ typedef boost::function<error_callback_sig> error_callback;
virtual void send(CANMessage const &message) = 0;
virtual TokenPtr recv(uint32_t id) = 0;
View
7 include/jaguar/jaguar_bridge.h
@@ -5,7 +5,7 @@
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/signal.hpp>
+#include <boost/signals2.hpp>
#include <boost/thread.hpp>
#include <map>
#include <vector>
@@ -76,7 +76,8 @@ class JaguarBridge : public CANBridge
//virtual bool detach_callback(uint32_t id, recv_callback cb);
private:
- typedef boost::signal<void (boost::shared_ptr<CANMessage>)> callback_signal;
+ typedef boost::signals2::signal<recv_callback_sig>
+ callback_signal;
typedef boost::shared_ptr<callback_signal> callback_signal_ptr;
typedef std::map<uint32_t, callback_signal_ptr> callback_table;
@@ -94,7 +95,7 @@ class JaguarBridge : public CANBridge
boost::asio::io_service io_;
boost::asio::serial_port serial_;
- boost::signal<error_callback> error_signal_;
+ boost::signals2::signal<error_callback_sig> error_signal_;
boost::thread recv_thread_;
std::vector<uint8_t> recv_buffer_;
View
4 src/jaguar_bridge.cc
@@ -110,7 +110,9 @@ void JaguarBridge::attach_callback(uint32_t id, uint32_t id_mask, recv_callback
);
}
-void JaguarBridge::attach_callback(error_callback cb)
+/* FIXME: should be
+ * void JaguarBridge::attack_callback(error_callback cb)
+void JaguarBridge::attach_callback(boost::function<error_callback_sig> cb)
{
error_signal_.connect(cb);
}
View
10 src/unbrick.cc
@@ -2,7 +2,6 @@
#include <iostream>
#include <fstream>
#include <boost/assert.hpp>
-#include <boost/lambda/lambda.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/foreach.hpp>
@@ -105,9 +104,14 @@ int main(int argc, char *argv[])
fw_buf << fw_stream.rdbuf();
std::string const fw(fw_buf.str());
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using boost::phoenix::arg_names::arg3;
+ using boost::phoenix::arg_names::arg4;
+
/* XXX: spy on all recv'd data */
- can.attach_callback(0, 0,
- boost::lambda::var(std::cerr) << boost::lambda::_1);
+ can.attach_callback(0, 0, std::cerr << arg1);
+ can.attach_callback(std::cerr << arg1 << arg2 << arg3 << arg4);
/* send PING */
can::TokenPtr ping_token = bl.recv(jaguar::FirmwareUpdate::kPing);

0 comments on commit 4221157

Please sign in to comment.
Something went wrong with that request. Please try again.