00001 /* 00002 * connection_base.h - micros connection base 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_CONNECTION_BASE_H 00020 #define MICROSRTT_CONNECTION_BASE_H 00021 00022 #include "micros_rtt/oro/channel_element_base.hpp" 00023 00024 namespace micros_rtt 00025 { 00026 class ConnectionBase; 00027 typedef boost::shared_ptr<ConnectionBase> ConnectionBasePtr; 00028 typedef std::vector<ConnectionBasePtr> V_ConnectionBase; 00029 00030 class ConnectionBase 00031 { 00032 public: 00033 typedef boost::intrusive_ptr<ConnectionBase> shared_ptr; 00034 00035 private: 00036 std::string topic_; 00037 ChannelElementBase::shared_ptr channel_element; 00038 ChannelElementBase::shared_ptr mq_channel_element; 00039 00040 public: 00041 ConnectionBase() {} 00042 ConnectionBase(std::string topic) : topic_(topic) {} 00043 ~ConnectionBase() {} 00044 00045 std::string getTopic() {return topic_;} 00046 00047 ChannelElementBase::shared_ptr getChannelElement() {return channel_element;} 00048 ChannelElementBase::shared_ptr getMQChannelElement() {return mq_channel_element;} 00049 00050 bool addConnection(ChannelElementBase::shared_ptr channel) 00051 { 00052 channel_element = channel; 00053 return true; 00054 } 00055 bool addMQConnection(ChannelElementBase::shared_ptr channel) 00056 { 00057 mq_channel_element = channel; 00058 return true; 00059 } 00060 00061 virtual bool channelReady(ChannelElementBase::shared_ptr channel) = 0; 00062 virtual bool mqChannelReady(ChannelElementBase::shared_ptr channel) = 0; 00063 }; 00064 00065 } 00066 #endif