connection_factory.cpp
Go to the documentation of this file.
00001 /* 
00002  *  connection_factory.cpp - micros connection factory
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 #include "micros_rtt/oro/connection_factory.hpp"
00020 
00021 namespace micros_rtt
00022 {
00023   
00024 bool ConnFactory::createAndCheckConnection(ConnectionBasePtr publication, 
00025           ConnectionBasePtr subscription, ChannelElementBase::shared_ptr channel_input)
00026 {
00027   // Register the subscription to the publication.
00028   if ( publication->addConnection(channel_input) ) 
00029   {
00030     ROS_DEBUG("micros connection factory adds input_end of channel to publication:%s.", publication->getTopic().c_str());
00031     // notify input that the connection is now complete.
00032     if ( subscription->channelReady( channel_input->getOutputEndPoint() ) == false ) 
00033     {
00034       ROS_WARN("micros connection factory checks channel ready failed, subscription:%s", subscription->getTopic().c_str());
00035       return false;
00036     }
00037     return true;
00038   }
00039   // setup failed.
00040   return false;
00041 }
00042 
00043 bool ConnFactory::createAndCheckStream(ConnectionBasePtr connection, 
00044         ChannelElementBase::shared_ptr chan, bool is_sender)
00045 {
00046   if (is_sender)
00047   {
00048     if ( connection->addMQConnection(chan) ) 
00049     {
00050       ROS_DEBUG("micros connection factory adds input_end of stream to publication:%s.", connection->getTopic().c_str());
00051       return true;
00052     }
00053     // setup failed.
00054     ROS_WARN("micros connection factory fail to add input_end of stream to publication:%s.", connection->getTopic().c_str());
00055     return false;
00056   }
00057   else
00058   {
00059     if ( connection->mqChannelReady( chan->getOutputEndPoint() ) == true ) 
00060     {
00061       ROS_DEBUG("micros connection factory adds output_end of stream to subscription:%s.", connection->getTopic().c_str());
00062       return true;
00063     }
00064     // setup failed: manual cleanup.
00065     chan = 0; 
00066     ROS_WARN("micros connection factory fail to add output_end of stream to subscription:%s.", connection->getTopic().c_str());
00067     return false;
00068   }
00069 }
00070 
00071 }


micros_rtt
Author(s): Zaile Jiang , Xiaodong Yi , Minglong Li
autogenerated on Sat Jun 8 2019 19:02:21