00001 /* 00002 * mq_channel_element.hpp - micros message queue transport methods 00003 * Copyright (C) 2015 Zaile Jiang 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef MICROSRTT_MQSENDRECV_HPP 00020 #define MICROSRTT_MQSENDRECV_HPP 00021 00022 #include <ros/ros.h> 00023 #include <mqueue.h> 00024 #include "ros/serialization.h" 00025 #include "micros_rtt/connection_base.h" 00026 #include "micros_rtt/oro/channel_element.hpp" 00027 00028 namespace micros_rtt 00029 { 00030 using namespace ros::serialization; 00031 using ros::SerializedMessage; 00036 class MQSendRecv 00037 { 00038 protected: 00039 00043 mqd_t mqdes; 00051 char* buf; 00055 bool mis_sender; 00059 bool minit_done; 00063 int max_size; 00068 std::string mqname; 00074 int mdata_size; 00075 00076 public: 00081 MQSendRecv(); 00082 00083 void setupStream(ConnectionBasePtr connection, int size, bool is_sender); 00084 00085 ~MQSendRecv(); 00086 00087 void cleanupStream(); 00088 00094 virtual void mqNewSample(int size); 00095 00101 virtual bool mqReady(ChannelElementBase* chan); 00102 00108 bool mqRead(SerializedMessage& m); 00109 00116 bool mqWrite(SerializedMessage& m); 00117 }; 00118 } 00119 00120 #endif /* ORO_MQSENDER_HPP_ */