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
StatusEvent.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 namespace lsst {
38 namespace ctrl {
39 namespace events {
40 
41 std::string const StatusEvent::ORIG_HOSTNAME = "ORIG_HOSTNAME";
42 std::string const StatusEvent::ORIG_PROCESSID = "ORIG_PROCESSID";
43 std::string const StatusEvent::ORIG_LOCALID = "ORIG_LOCALID";
44 
46  _init();
47 }
48 
49 
51  _keywords.insert(ORIG_HOSTNAME);
52  _keywords.insert(ORIG_PROCESSID);
53  _keywords.insert(ORIG_LOCALID);
54 }
55 
56 StatusEvent::StatusEvent(cms::TextMessage *msg) : Event(msg) {
57  _init();
58 
59  _psp->set(ORIG_HOSTNAME, (std::string)msg->getStringProperty(ORIG_HOSTNAME));
60  _psp->set(ORIG_PROCESSID, (int)msg->getIntProperty(ORIG_PROCESSID));
61  _psp->set(ORIG_LOCALID, (int)msg->getIntProperty(ORIG_LOCALID));
62 }
63 
65  PropertySet const& ps) : Event(ps) {
66  _constructor(originatorID);
67 }
68 
70  PropertySet const& ps,
71  PropertySet const& filterable) : Event(ps, filterable) {
72  _constructor(originatorID);
73 }
74 
75 StatusEvent::StatusEvent(std::string const& runID,
76  LocationId const& originatorID,
77  CONST_PTR(PropertySet) psp) : Event(runID, *psp) {
78  _constructor(originatorID);
79 }
80 
81 StatusEvent::StatusEvent(std::string const& runID,
82  LocationId const& originatorID,
84  PropertySet const& filterable) : Event(runID, *psp, filterable) {
85  _constructor(originatorID);
86 }
87 
88 StatusEvent::StatusEvent(std::string const& runID,
89  LocationId const& originatorID,
90  PropertySet const& ps) : Event(runID, ps) {
91  _constructor(originatorID);
92 }
93 
94 StatusEvent::StatusEvent(std::string const& runID,
95  LocationId const& originatorID,
96  PropertySet const& ps,
97  PropertySet const& filterable) : Event(runID, ps, filterable) {
98  _constructor(originatorID);
99 }
100 
101 void StatusEvent::_constructor(LocationId const& originatorID) {
102  _init();
103 
104  _psp->set(ORIG_HOSTNAME, originatorID.getHostName());
105  _psp->set(ORIG_PROCESSID, originatorID.getProcessID());
106  _psp->set(ORIG_LOCALID, originatorID.getLocalID());
108 
109 }
110 
111 void StatusEvent::populateHeader(cms::TextMessage* msg) const {
113 
114  msg->setStringProperty(ORIG_HOSTNAME, _psp->get<std::string>(ORIG_HOSTNAME));
115  msg->setIntProperty(ORIG_PROCESSID, _psp->get<int>(ORIG_PROCESSID));
116  msg->setIntProperty(ORIG_LOCALID, _psp->get<int>(ORIG_LOCALID));
117 }
118 
120  std::string hostname = _psp->get<std::string>(ORIG_HOSTNAME);
121  int pid = _psp->get<int>(ORIG_PROCESSID);
122  int local = _psp->get<int>(ORIG_LOCALID);
123  return new LocationId(hostname, pid, local);
124 }
125 
127 }
128 
129 }}}
StatusEvent()
Constructor to create a StatusEvent.
Definition: StatusEvent.cc:45
std::set< std::string > _keywords
Definition: Event.h:243
defines EventTypes
static std::string const ORIG_LOCALID
Definition: StatusEvent.h:67
#define CONST_PTR(...)
Definition: base.h:47
static std::string const ORIG_PROCESSID
Definition: StatusEvent.h:66
void _constructor(LocationId const &originator)
Definition: StatusEvent.cc:101
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: Event.cc:230
LocationId * getOriginator()
accessor to get originator information
Definition: StatusEvent.cc:119
static std::string const ORIG_HOSTNAME
Definition: StatusEvent.h:65
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
Represent process that created an event.
Definition: LocationId.h:52
defines the StatusEvent class
static const std::string STATUS
Definition: EventTypes.h:48
std::string getHostName() const
Retrieve the host name.
Definition: LocationId.cc:68
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: StatusEvent.cc:111
boost::shared_ptr< PropertySet > _psp
Definition: Event.h:241
int getProcessID() const
Retrieve the process id.
Definition: LocationId.cc:72
int getLocalID() const
Retrieve the local id.
Definition: LocationId.cc:76