LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
EventSystem.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008-2015 AURA/LSST.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <https://www.lsstcorp.org/LegalNotices/>.
23  */
24 
34 #ifndef LSST_CTRL_EVENTS_EVENTSYSTEM_H
35 #define LSST_CTRL_EVENTS_EVENTSYSTEM_H
36 
37 #include <stdlib.h>
38 #include <iostream>
39 #include <vector>
40 #include <list>
41 
43 
48 #include "lsst/ctrl/events/Event.h"
52 
54 
55 namespace lsst {
56 namespace ctrl {
57 namespace events {
58 
65 class EventSystem {
66 public:
70  ~EventSystem();
71 
78 
86  void createTransmitter(std::string const& hostName, std::string const& topicName, int hostPort = EventBroker::DEFAULTHOSTPORT);
87 
95  void createEnqueuer(std::string const& hostName, std::string const& queueName, int hostPort = EventBroker::DEFAULTHOSTPORT);
96 
104  void createReceiver(std::string const& hostName, std::string const& topicName, int hostPort = EventBroker::DEFAULTHOSTPORT);
105 
113  void createDequeuer(std::string const& hostName, std::string const& queueName, int hostPort = EventBroker::DEFAULTHOSTPORT);
114 
123  void createReceiver(std::string const& hostName, std::string const& topicName, std::string const& selector, int hostPort = EventBroker::DEFAULTHOSTPORT);
124 
133  void createDequeuer(std::string const& hostName, std::string const& queueName, std::string const& selector, int hostPort = EventBroker::DEFAULTHOSTPORT);
134 
142  void publishEvent(std::string const& destinationName, Event& event);
143 
150  PTR(Event) receiveEvent(std::string const& destinationName);
151 
160  PTR(Event) receiveEvent(std::string const& destinationName, const long timeout);
161 
167 
174 
181 
182 private:
184 
185  PTR(Transmitter) getTransmitter(std::string const& name);
186  PTR(Receiver) getReceiver(std::string const& name);
187 
188 protected:
189  EventSystem();
190 
191 
192  static std::list<PTR(EventTransmitter) >_transmitters;
193  static std::list<PTR(EventReceiver) >_receivers;
194 
195  static std::list<PTR(EventEnqueuer) >_enqueuers;
196  static std::list<PTR(EventDequeuer) >_dequeuers;
197 };
198 
199 }}}
200 
201 #endif /*end LSST_CTRL_EVENTS_EVENTSYSTEM_H*/
static EventSystem & getDefaultEventSystem()
return the default EventSystem object, which can access all previously created Transmitters and recei...
Definition: EventSystem.cc:52
void publishEvent(std::string const &destinationName, Event &event)
send an event to a destination
Definition: EventSystem.cc:117
defines the EventDequeuer class
defines the EventTransmitter class
void createEnqueuer(std::string const &hostName, std::string const &queueName, int hostPort=EventBroker::DEFAULTHOSTPORT)
create a EventQueuer to send messages to the message broker
Definition: EventSystem.cc:72
Receive events from the event bus.
Definition: EventReceiver.h:58
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static std::list< boost::shared_ptr< EventTransmitter > > _transmitters
Definition: EventSystem.h:192
static std::list< boost::shared_ptr< EventDequeuer > > _dequeuers
Definition: EventSystem.h:196
void createReceiver(std::string const &hostName, std::string const &topicName, int hostPort=EventBroker::DEFAULTHOSTPORT)
create an EventReceiver which will receive message
Definition: EventSystem.cc:80
Receive events from the event bus.
Definition: EventDequeuer.h:58
Representation of an LSST Event.
Definition: StatusEvent.h:61
lsst::daf::base::PropertySet PropertySet
Definition: Wcs.cc:59
boost::shared_ptr< StatusEvent > castToStatusEvent(boost::shared_ptr< Event > event)
cast an Event to StatusEvent
Definition: EventSystem.cc:175
Representation of an LSST CommandEvent.
Definition: CommandEvent.h:61
Receive events from the event bus.
Definition: Receiver.h:61
static std::list< boost::shared_ptr< EventReceiver > > _receivers
Definition: EventSystem.h:193
Transmit events to the event bus.
defines the CommandEvent class
void createDequeuer(std::string const &hostName, std::string const &queueName, int hostPort=EventBroker::DEFAULTHOSTPORT)
create a EventDequeuer which will receive message
Definition: EventSystem.cc:90
defines the EventEnqueuer class
defines the Event class
Transmit events to the event bus.
Definition: Transmitter.h:59
boost::shared_ptr< Event > receiveEvent(std::string const &destinationName)
blocking receive for events. Waits until an event is received for the destination specified in the co...
Definition: EventSystem.cc:143
static EventSystem * defaultEventSystem
Definition: EventSystem.h:183
defines the EventReceiver class
static const int DEFAULTHOSTPORT
Definition: EventBroker.h:47
static std::list< boost::shared_ptr< EventEnqueuer > > _enqueuers
Definition: EventSystem.h:195
information about the Event Broker
Representation of an LSST Event.
Definition: Event.h:61
boost::shared_ptr< Transmitter > getTransmitter(std::string const &name)
Definition: EventSystem.cc:127
#define PTR(...)
Definition: base.h:41
Represent process that created an event.
Definition: LocationId.h:52
void createTransmitter(std::string const &hostName, std::string const &topicName, int hostPort=EventBroker::DEFAULTHOSTPORT)
create an EventTransmitter to send messages to the message broker
Definition: EventSystem.cc:64
defines the StatusEvent class
boost::shared_ptr< CommandEvent > castToCommandEvent(boost::shared_ptr< Event > event)
cast an Event to CommandEvent
Definition: EventSystem.cc:179
Interface for PropertySet class.
boost::shared_ptr< Receiver > getReceiver(std::string const &name)
Definition: EventSystem.cc:162
Transmit events to the event bus.
Definition: EventEnqueuer.h:57
This object allows creation of the system&#39;s event transmitters and receivers, which can be specified ...
Definition: EventSystem.h:65
boost::shared_ptr< LocationId > createOriginatorId() const
create an LocationId
Definition: EventSystem.cc:156