8 : _eventService(eventService), _name(name)
14 auto topic =
"bridge/events/" + suffix;
32 if (event.name() ==
_name)
44 message.
GetMutableParameters().mutable_pairs()->insert(event.parameters().begin(),
event.parameters().end());
51 throw Exception(
"Trying to deliver unknown event");
63 throw Exception(
"Trying to query event descriptor for unknown event");
bool HasHeader() const
Checks whether the message fits the requirements of a message with a header.
The Event service is responsible for triggering, handling and monitoring events.
void publish(const boost::shared_ptr< M > &message) const
const std::string & GetCanonicalDefinition() const
Get the canonical definition of the message.
virtual swarmio::data::discovery::Schema DescribeEvent(const std::string &name) override
Describe the event based on the configuration of this instance.
std::string _name
Event name.
swarmio::data::Map & GetMutableParameters()
Get mutable event parameters.
void RegisterHandler(const std::string &name, Handler *handler)
Subscribe to events.
const std::string & GetHash() const
Get the MD5 hash of the message definition file.
static const MessageSerializer & MessageSerializerForType(const std::string &type, const std::string &parentPackage)
Look up or build a reader for a message type.
Exception base class for swarmros exceptions.
virtual void EventWasTriggered(const swarmio::Node *node, const swarmio::data::event::Notification &event) override
Publish the event in the ROS topic.
void SetName(const std::string &name)
Set event name.
EventMessage implements an interface with the ROS type system to send and receive events...
void SetType(const std::string &type)
Set the type of the object and fetch its serializer.
const introspection::MessageSerializer * _serializer
Event name.
static bool IsEventSerializer(const introspection::MessageSerializer &serializer)
Checks whether a serializer has the correct layout.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
EventPublisher(ros::NodeHandle &nodeHandle, const std::string &suffix, const std::string &message, swarmio::services::event::Service &eventService, const std::string &name)
Construct a new EventPublisher object.
virtual const std::string & GetUUID() const =0
Returns the unique identifier of the node.
Exception thrown when the expected type of a message does not match the actual type.
virtual ~EventPublisher() override
Destructor.
ros::Publisher _publisher
Publisher.
Represents a Node the Endpoint knows about and can send messages to.
void UnregisterHandler(const std::string &name)
Unsubscribe from events.
virtual const std::string & GetFullName() const override
Get the fully qualified name for the type behind the serializer.
swarmio::services::event::Service & _eventService
Event service.
swarmio::data::discovery::Schema GetSchemaDescriptor(unsigned skipCount) const
Build a field descriptor for the underlying type, with or without its header.
void SetNode(const std::string &node)
Set node UUID.