##

SubscribeOptions.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 _SUBSCRIBEOPTIONS_HH_
#define _SUBSCRIBEOPTIONS_HH_
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
#include "gazebo/transport/CallbackHelper.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace transport
{
class GZ_TRANSPORT_VISIBLE SubscribeOptions
{
public: SubscribeOptions()
: latching(false)
{}
public: template<class M>
void Init(const std::string &_topic, NodePtr _node,
bool _latching)
{
google::protobuf::Message *msg = NULL;
M msgtype;
msg = dynamic_cast<google::protobuf::Message *>(&msgtype);
if (!msg)
gzthrow("Subscribe requires a google protobuf type");
this->node = _node;
this->topic = _topic;
this->msgType = msg->GetTypeName();
this->latching = _latching;
}
public: void Init(const std::string &_topic, NodePtr _node,
bool _latching)
{
this->node = _node;
this->topic = _topic;
this->msgType = "raw";
this->latching = _latching;
}
public: NodePtr GetNode() const
{
return this->node;
}
public: std::string GetTopic() const
{
return this->topic;
}
public: std::string GetMsgType() const
{
return this->msgType;
}
public: bool GetLatching() const
{
return this->latching;
}
private: std::string topic;
private: std::string msgType;
private: NodePtr node;
private: bool latching;
};
}
}
#endif
gazebo::transport::SubscribeOptions::GetLatching
bool GetLatching() const
Are we latching?
Definition: SubscribeOptions.hh:101
gazebo::transport::SubscribeOptions
Options for a subscription.
Definition: SubscribeOptions.hh:35
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
NULL
#define NULL
Definition: CommonTypes.hh:31
gzthrow
#define gzthrow(msg)
This macro logs an error to the throw stream and throws an exception that contains the file name and ...
Definition: Exception.hh:39
gazebo::transport::SubscribeOptions::Init
void Init(const std::string &_topic, NodePtr _node, bool _latching)
Initialize the options.
Definition: SubscribeOptions.hh:69
system.hh
CallbackHelper.hh
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::transport::SubscribeOptions::GetTopic
std::string GetTopic() const
Get the topic we're subscribed to.
Definition: SubscribeOptions.hh:87
gazebo::transport::SubscribeOptions::GetMsgType
std::string GetMsgType() const
Get the type of the topic we're subscribed to.
Definition: SubscribeOptions.hh:94
gazebo::transport::SubscribeOptions::SubscribeOptions
SubscribeOptions()
Constructor.
Definition: SubscribeOptions.hh:38
gazebo::transport::SubscribeOptions::Init
void Init(const std::string &_topic, NodePtr _node, bool _latching)
Initialize the options.
Definition: SubscribeOptions.hh:48
transport
transport
Definition: ConnectionManager.hh:35
gazebo::transport::SubscribeOptions::GetNode
NodePtr GetNode() const
Get the node we're subscribed to.
Definition: SubscribeOptions.hh:80