##

EventSource.hh
Go to the documentation of this file.
/*
* Copyright (C) 2014 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 GAZEBO_PLUGINS_EVENTSOURCE_HH_
#define GAZEBO_PLUGINS_EVENTSOURCE_HH_
#include <memory>
#include <string>
#include "gazebo/gazebo.hh"
#include "gazebo/physics/physics.hh"
#include "gazebo/common/common.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "SimEventsException.hh"
namespace gazebo
{
class EventSource
{
public: EventSource(transport::PublisherPtr _pub,
const std::string &_type,
physics::WorldPtr _world);
public: virtual ~EventSource();
public: void Emit(const std::string& _data) const;
public: virtual void Load(const sdf::ElementPtr _sdf);
public: virtual void Init();
public: virtual bool IsActive() const;
protected: std::string name;
protected: std::string type;
protected: physics::WorldPtr world;
protected: bool active;
protected: transport::PublisherPtr pub;
};
typedef std::shared_ptr<EventSource> EventSourcePtr;
class SimEventConnector
{
public: template<typename T>
static event::ConnectionPtr
ConnectSpawnModel(T _subscriber)
{ return spawnModel.Connect(_subscriber); }
public: static event::EventT<void (std::string, bool)> spawnModel;
};
}
#endif
gazebo::EventSource::Init
virtual void Init()
Initialize the event.
gazebo::EventSource::EventSource
EventSource(transport::PublisherPtr _pub, const std::string &_type, physics::WorldPtr _world)
Constructor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::EventSource::IsActive
virtual bool IsActive() const
An event source can be used to enable other events.
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
TransportTypes.hh
Forward declarations for transport.
gazebo::SimEventConnector::ConnectSpawnModel
static event::ConnectionPtr ConnectSpawnModel(T _subscriber)
Connect a callback to the spawn model event.
Definition: EventSource.hh:91
gazebo.hh
gazebo::EventSourcePtr
std::shared_ptr< EventSource > EventSourcePtr
Definition: EventSource.hh:81
gazebo::event::EventT
A class for event processing.
Definition: Event.hh:97
gazebo::EventSource::~EventSource
virtual ~EventSource()
Destructor.
gazebo::event::EventT::Connect
ConnectionPtr Connect(const std::function< T > &_subscriber)
Connect a callback to this event.
Definition: Event.hh:558
gazebo::SimEventConnector
Gazebo events to detect model creation/deletion.
Definition: EventSource.hh:84
gazebo::EventSource::Emit
void Emit(const std::string &_data) const
emit an event with data to the internal publisher (and using the internal type)
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::EventSource::type
std::string type
Type of event.
Definition: EventSource.hh:68
gazebo::EventSource
The base class for emitting SimEvents.
Definition: EventSource.hh:34
gazebo::EventSource::pub
transport::PublisherPtr pub
a way to send messages to the other topics (to the REST)
Definition: EventSource.hh:78
gazebo::SimEventConnector::spawnModel
static event::EventT< void(std::string, bool)> spawnModel
A model has been completed and uploaded onto the server.
Definition: EventSource.hh:95
gazebo::EventSource::active
bool active
True if the event source is active.
Definition: EventSource.hh:75
gazebo::EventSource::Load
virtual void Load(const sdf::ElementPtr _sdf)
Load from an sdf element (with possible configuration data)
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::EventSource::world
physics::WorldPtr world
Pointer to the world.
Definition: EventSource.hh:71
SimEventsException.hh
gazebo::EventSource::name
std::string name
Name of the event.
Definition: EventSource.hh:65