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
CommandEvent.cc
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 
36 
37 using namespace std;
38 
39 namespace lsst {
40 namespace ctrl {
41 namespace events {
42 
43 const std::string CommandEvent::ORIG_HOSTNAME = "ORIG_HOSTNAME";
44 const std::string CommandEvent::ORIG_PROCESSID = "ORIG_PROCESSID";
45 const std::string CommandEvent::ORIG_LOCALID = "ORIG_LOCALID";
46 
47 const std::string CommandEvent::DEST_HOSTNAME = "DEST_HOSTNAME";
48 const std::string CommandEvent::DEST_PROCESSID = "DEST_PROCESSID";
49 const std::string CommandEvent::DEST_LOCALID = "DEST_LOCALID";
50 
51 CommandEvent::CommandEvent() : Event() {
52  _init();
53 }
54 
55 
59  _keywords.insert(ORIG_HOSTNAME);
60  _keywords.insert(ORIG_PROCESSID);
61  _keywords.insert(ORIG_LOCALID);
62 
63  _keywords.insert(DEST_HOSTNAME);
64  _keywords.insert(DEST_PROCESSID);
65  _keywords.insert(DEST_LOCALID);
66 }
67 
68 CommandEvent::CommandEvent(cms::TextMessage *msg) : Event(msg) {
69  _init();
70 
71 
72  _psp->set(ORIG_HOSTNAME, (std::string)msg->getStringProperty(ORIG_HOSTNAME));
73  _psp->set(ORIG_PROCESSID, (int)msg->getIntProperty(ORIG_PROCESSID));
74  _psp->set(ORIG_LOCALID, (int)msg->getIntProperty(ORIG_LOCALID));
75 
76  _psp->set(DEST_HOSTNAME, (std::string)msg->getStringProperty(DEST_HOSTNAME));
77  _psp->set(DEST_PROCESSID, (int)msg->getIntProperty(DEST_PROCESSID));
78  _psp->set(DEST_LOCALID, (int)msg->getIntProperty(DEST_LOCALID));
79 
80 }
81 
82 CommandEvent::CommandEvent(LocationId const& originator, LocationId const& destination, CONST_PTR(PropertySet)& psp) : Event(*psp) {
83  _constructor(originator, destination);
84 }
85 
86 CommandEvent::CommandEvent(LocationId const& originator, LocationId const& destination, PropertySet const& ps) : Event(ps) {
87  _constructor(originator, destination);
88 }
89 
90 CommandEvent::CommandEvent(LocationId const& originator, LocationId const& destination, PropertySet const& ps, PropertySet const& filterable) : Event(ps, filterable) {
91  _constructor(originator, destination);
92 }
93 
94 CommandEvent::CommandEvent(std::string const& runId, LocationId const& originator, LocationId const& destination, CONST_PTR(PropertySet)& psp) : Event(runId, *psp) {
95  _constructor(originator, destination);
96 }
97 
98 CommandEvent::CommandEvent( std::string const& runId, LocationId const& originator, LocationId const& destination, PropertySet const& ps) : Event(runId, ps) {
99  _constructor(originator, destination);
100 }
101 
102 CommandEvent::CommandEvent(std::string const& runId, LocationId const& originator, LocationId const& destination, PropertySet const& ps, PropertySet const& filterable) : Event(runId, ps, filterable) {
103  _constructor(originator, destination);
104 }
105 
110 void CommandEvent::_constructor(LocationId const& originator, LocationId const& destination) {
111  _init();
112 
113  _psp->set(ORIG_HOSTNAME, originator.getHostName());
114  _psp->set(ORIG_PROCESSID, originator.getProcessID());
115  _psp->set(ORIG_LOCALID, originator.getLocalID());
116 
117  _psp->set(DEST_HOSTNAME, destination.getHostName());
118  _psp->set(DEST_PROCESSID, destination.getProcessID());
119  _psp->set(DEST_LOCALID, destination.getLocalID());
120 
122 
123 }
124 
125 void CommandEvent::populateHeader(cms::TextMessage* msg) const {
127 
128  msg->setStringProperty(ORIG_HOSTNAME, _psp->get<std::string>(ORIG_HOSTNAME));
129  msg->setIntProperty(ORIG_PROCESSID, _psp->get<int>(ORIG_PROCESSID));
130  msg->setIntProperty(ORIG_LOCALID, _psp->get<int>(ORIG_LOCALID));
131 
132  msg->setStringProperty(DEST_HOSTNAME, _psp->get<std::string>(DEST_HOSTNAME));
133  msg->setIntProperty(DEST_PROCESSID, _psp->get<int>(DEST_PROCESSID));
134  msg->setIntProperty(DEST_LOCALID, _psp->get<int>(DEST_LOCALID));
135 }
136 
137 PTR(LocationId) CommandEvent::getOriginator() const {
138  std::string hostname = _psp->get<std::string>(ORIG_HOSTNAME);
139  int pid = _psp->get<int>(ORIG_PROCESSID);
140  int local = _psp->get<int>(ORIG_LOCALID);
141  return PTR(LocationId)(new LocationId(hostname, pid, local));
142 }
143 
144 PTR(LocationId) CommandEvent::getDestination() const {
145  std::string hostname = _psp->get<std::string>(DEST_HOSTNAME);
146  int pid = _psp->get<int>(DEST_PROCESSID);
147  int local = _psp->get<int>(DEST_LOCALID);
148  return PTR(LocationId)(new LocationId(hostname, pid, local));
149 }
150 
152 }
153 
154 }}}
static const std::string DEST_LOCALID
Definition: CommandEvent.h:71
CommandEvent()
Creates CommandEvent which contains a PropertySet consisting of an origination location ID and a dest...
Definition: CommandEvent.cc:51
static const std::string ORIG_HOSTNAME
Definition: CommandEvent.h:65
static const std::string ORIG_PROCESSID
Definition: CommandEvent.h:66
std::set< std::string > _keywords
Definition: Event.h:243
defines EventTypes
#define CONST_PTR(...)
Definition: base.h:47
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Representation of an LSST CommandEvent.
Definition: CommandEvent.h:61
static const std::string DEST_PROCESSID
Definition: CommandEvent.h:70
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: Event.cc:230
void _constructor(LocationId const &originator, LocationId const &destination)
defines the CommandEvent class
static const std::string ORIG_LOCALID
Definition: CommandEvent.h:67
virtual ~CommandEvent()
destructor
static const std::string TYPE
Definition: Event.h:64
Representation of an LSST Event.
Definition: Event.h:61
Class for storing generic metadata.
Definition: PropertySet.h:82
#define PTR(...)
Definition: base.h:41
Represent process that created an event.
Definition: LocationId.h:52
static const std::string DEST_HOSTNAME
Definition: CommandEvent.h:69
std::string getHostName() const
Retrieve the host name.
Definition: LocationId.cc:68
boost::shared_ptr< PropertySet > _psp
Definition: Event.h:241
static const std::string COMMAND
Definition: EventTypes.h:49
int getProcessID() const
Retrieve the process id.
Definition: LocationId.cc:72
int getLocalID() const
Retrieve the local id.
Definition: LocationId.cc:76