LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 #include <boost/shared_ptr.hpp>
42 
43 #include "lsst/utils/Utils.h"
45 #include "lsst/ctrl/events.h"
46 #include "lsst/ctrl/events/Event.h"
50 
52 
53 using namespace std;
54 
55 namespace lsst {
56 namespace ctrl {
57 namespace events {
58 
65 class EventSystem {
66 public:
70  ~EventSystem();
71 
77  static EventSystem& getDefaultEventSystem();
78 
86  void createTransmitter(std::string const& hostName, std::string const& topicName, int hostPort = EventBroker::DEFAULTHOSTPORT);
87 
88 
96  void createReceiver(std::string const& hostName, std::string const& topicName, int hostPort = EventBroker::DEFAULTHOSTPORT);
97 
105  void createReceiver(std::string const& hostName, std::string const& topicName, std::string const& selector, int hostPort = EventBroker::DEFAULTHOSTPORT);
106 
114  void publishEvent(std::string const& topicName, Event& event);
115 
122  Event* receiveEvent(std::string const& topicName);
123 
132  Event* receiveEvent(std::string const& topicName, const long timeout);
133 
138  LocationId::Ptr createOriginatorId() const;
139 
145  StatusEvent* castToStatusEvent(Event* event);
146 
152  CommandEvent* castToCommandEvent(Event* event);
153 
154 private:
156 
157  boost::shared_ptr<EventTransmitter> getTransmitter(std::string const& name);
158  boost::shared_ptr<EventReceiver> getReceiver(std::string const& name);
159 
160 protected:
161  EventSystem();
162 
163 
164  static list<boost::shared_ptr<EventTransmitter> >_transmitters;
165  static list<boost::shared_ptr<EventReceiver> >_receivers;
166 };
167 
168 }}}
169 
170 #endif /*end LSST_CTRL_EVENTS_EVENTSYSTEM_H*/
171 
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< LocationId > Ptr
Definition: LocationId.h:52
static list< boost::shared_ptr< EventReceiver > > _receivers
Definition: EventSystem.h:165
Representation of an LSST Event.
Definition: StatusEvent.h:62
lsst::daf::base::PropertySet PropertySet
Definition: Wcs.cc:58
Representation of an LSST CommandEvent.
Definition: CommandEvent.h:63
static list< boost::shared_ptr< EventTransmitter > > _transmitters
Definition: EventSystem.h:164
provides access to primary application interface classes for sending and receiving events...
defines the CommandEvent class
defines the Event class
static EventSystem * defaultEventSystem
Definition: EventSystem.h:155
information about the Event Broker
Representation of an LSST Event.
Definition: Event.h:62
defines the StatusEvent class
Interface for PropertySet class.
This object allows creation of the system&#39;s event transmitters and receivers, which can be specified ...
Definition: EventSystem.h:65