##

Master.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _MASTER_HH_
#define _MASTER_HH_
#include <string>
#include <list>
#include <deque>
#include <utility>
#include <map>
#include <boost/shared_ptr.hpp>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/Connection.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
// Forward declare private data class
struct MasterPrivate;
class GAZEBO_VISIBLE Master
{
public: typedef
std::map<unsigned int, transport::ConnectionPtr> Connection_M;
public: typedef
std::list< std::pair<msgs::Publish, transport::ConnectionPtr> >
PubList;
public: typedef
std::list< std::pair<msgs::Subscribe, transport::ConnectionPtr> >
SubList;
public: Master();
public: virtual ~Master();
public: void Init(uint16_t _port);
public: void Run();
public: void RunThread();
public: void RunOnce();
public: void Stop();
public: void Fini();
private: void SendSubscribers(const std::string &_topic,
const std::string &_buffer);
private: void ProcessMessage(const unsigned int _connectionIndex,
const std::string &_data);
private: void OnRead(const unsigned int _connectionIndex,
const std::string &_data);
private: void OnAccept(transport::ConnectionPtr _newConnection);
private: msgs::Publish GetPublisher(const std::string &_topic);
private: transport::ConnectionPtr FindConnection(const std::string &_host,
uint16_t _port);
private: void RemoveConnection(Connection_M::iterator _connIter);
private: void RemovePublisher(const msgs::Publish _pub);
private: void RemoveSubscriber(const msgs::Subscribe _sub);
private: std::unique_ptr<MasterPrivate> dataPtr;
};
}
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::Master::SubList
std::list< std::pair< msgs::Subscribe, transport::ConnectionPtr > > SubList
Definition: Master.hh:53
Connection.hh
system.hh
gazebo::Master::PubList
std::list< std::pair< msgs::Publish, transport::ConnectionPtr > > PubList
Definition: Master.hh:48
msgs.hh
gazebo::Master::Connection_M
std::map< unsigned int, transport::ConnectionPtr > Connection_M
Definition: Master.hh:43
gazebo::transport::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:50
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::Master
A manager that directs topic connections, enables each gazebo network client to locate one another fo...
Definition: Master.hh:39
GAZEBO_VISIBLE
#define GAZEBO_VISIBLE
Definition: system.hh:59