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
Event.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_EVENT_H
35 #define LSST_CTRL_EVENTS_EVENT_H
36 
37 #include <cms/Connection.h>
38 #include <cms/Session.h>
39 #include <cms/Message.h>
40 
41 #include <stdlib.h>
42 #include <iostream>
43 #include <set>
44 
45 #include "lsst/base.h"
47 
48 #include "boost/property_tree/ptree.hpp"
49 
51 
52 namespace lsst {
53 namespace ctrl {
54 namespace events {
55 
61 class Event
62 {
63 public:
64  static const std::string TYPE;
65  static const std::string EVENTTIME;
66  static const std::string RUNID;
67  static const std::string STATUS;
68  static const std::string TOPIC;
69  static const std::string QUEUE;
70  static const std::string PUBTIME;
71  static const std::string UNINITIALIZED;
72 
76  Event();
77 
82  Event(PropertySet const& properties);
83 
90  Event(PropertySet const& properties, PropertySet const& filterable);
91 
97  Event(std::string const& runid, CONST_PTR(PropertySet) properties);
98 
104  Event(std::string const& runid, PropertySet const& properties);
105 
113  Event(std::string const& runid, PropertySet const& properties, PropertySet const& filterable);
118  Event(cms::TextMessage *msg);
119 
123  virtual ~Event();
124 
129  PTR(PropertySet) getPropertySet() const;
130 
134  std::string getPubDate();
135 
140  long long getPubTime();
141 
145  void setPubTime(long long t);
146 
151  long long getEventTime();
152 
156  void setEventTime(long long nsecs);
157 
161  void updateEventTime();
162 
167  std::string getEventDate();
168 
173  std::string getRunId();
174 
179  void setRunId(std::string runid);
180 
185  std::string getType();
186 
191  std::string getStatus();
192 
197  void setStatus(std::string status);
198 
203  void setTopic(std::string topic);
204 
209  std::string getTopic();
210 
215  std::vector<std::string> getFilterablePropertyNames();
216 
221  std::vector<std::string> getCustomPropertyNames();
222 
228 
233  virtual void populateHeader(cms::TextMessage* msg) const;
234 
238  void marshall(cms::TextMessage *msg);
239 
240 protected:
243  std::set<std::string> _keywords;
244  void _init();
245  void _constructor(std::string const& runid, PropertySet const& properties, PropertySet const& filterable);
246 
247  template<typename T>void add(std::string const& name, std::string const& tag, PropertySet const& properties, boost::property_tree::ptree& child);
248 
249 
250 private:
251  std::string marshall(PropertySet const& properties);
252  PTR(PropertySet) processTextMessage(cms::TextMessage *textMessage);
253  PTR(PropertySet) unmarshall(std::string const& text);
254  PTR(PropertySet) parsePropertySet(boost::property_tree::ptree child);
255  bool addDataItem(std::string const& typeInfo, boost::property_tree::ptree& item, std::string const& key, PropertySet& properties);
256 };
257 
258 }
259 }
260 }
261 
262 
263 #endif /*end LSST_CTRL_EVENTS_EVENT_H*/
static const std::string STATUS
Definition: Event.h:67
static const std::string TOPIC
Definition: Event.h:68
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::string getPubDate()
get the publication date of this Event, in ASCII
Definition: Event.cc:305
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:187
static const std::string RUNID
Definition: Event.h:66
boost::shared_ptr< PropertySet > processTextMessage(cms::TextMessage *textMessage)
Definition: Event.cc:409
std::vector< std::string > getCustomPropertyNames()
return all custom property names
Definition: Event.cc:146
std::set< std::string > _keywords
Definition: Event.h:243
static const std::string EVENTTIME
Definition: Event.h:65
boost::shared_ptr< PropertySet > parsePropertySet(boost::property_tree::ptree child)
Definition: Event.cc:462
static const std::string QUEUE
Definition: Event.h:69
#define CONST_PTR(...)
Definition: base.h:47
void updateEventTime()
update the Event time to the current time
Definition: Event.cc:265
std::vector< std::string > getFilterablePropertyNames()
return all filterable property names
Definition: Event.cc:138
lsst::daf::base::PropertySet PropertySet
Definition: Wcs.cc:59
boost::shared_ptr< PropertySet > _filterable
Definition: Event.h:242
long long getPubTime()
get the publication time of this Event
Definition: Event.cc:301
void setRunId(std::string runid)
set the RunId for this Event
Definition: Event.cc:322
static const std::string PUBTIME
Definition: Event.h:70
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: Event.cc:230
Event()
Constructor for Event with no properties.
Definition: Event.cc:70
virtual ~Event()
destructor
Definition: Event.cc:511
long long getEventTime()
get the event creation time
Definition: Event.cc:257
bool addDataItem(std::string const &typeInfo, boost::property_tree::ptree &item, std::string const &key, PropertySet &properties)
Definition: Event.cc:426
std::string getRunId()
get the RunId for this Event
Definition: Event.cc:316
int status
void setEventTime(long long nsecs)
set the event creation time
Definition: Event.cc:261
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
boost::shared_ptr< PropertySet > getCustomPropertySet() const
return all custom property set
Definition: Event.cc:279
void setStatus(std::string status)
set the Event status
Definition: Event.cc:335
static const std::string UNINITIALIZED
Definition: Event.h:71
Interface for PropertySet class.
std::string getTopic()
get the Event topic
Definition: Event.cc:343
void marshall(cms::TextMessage *msg)
marshall values in this event into a cms::TextMessage
Definition: Event.cc:347
std::string getEventDate()
get the Event Date
Definition: Event.cc:270
boost::shared_ptr< PropertySet > _psp
Definition: Event.h:241
std::string getType()
get the Event type
Definition: Event.cc:327
void setTopic(std::string topic)
set the Event topic
Definition: Event.cc:339
boost::shared_ptr< PropertySet > getPropertySet() const
retrieve the PropertySet for this Event
Definition: Event.cc:288
boost::shared_ptr< PropertySet > unmarshall(std::string const &text)
Definition: Event.cc:483
std::string getStatus()
get the Event status
Definition: Event.cc:331
void setPubTime(long long t)
set the publication time of this Event
Definition: Event.cc:297
void add(std::string const &name, std::string const &tag, PropertySet const &properties, boost::property_tree::ptree &child)
Definition: Event.cc:356