LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
lsst::ctrl::events::Event Class Reference

Representation of an LSST Event. More...

#include <Event.h>

Inheritance diagram for lsst::ctrl::events::Event:
lsst::ctrl::events::CommandEvent lsst::ctrl::events::LogEvent lsst::ctrl::events::StatusEvent

Public Member Functions

 Event ()
 Constructor for Event with no properties. More...
 
 Event (PropertySet const &properties)
 Constructor for Event. More...
 
 Event (PropertySet const &properties, PropertySet const &filterable)
 Constructor for Event. More...
 
 Event (std::string const &runid, PropertySet::Ptr const properties)
 Constructor for Event. More...
 
 Event (std::string const &runid, PropertySet const &properties)
 Constructor for Event. More...
 
 Event (std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
 Constructor for Event. More...
 
 Event (cms::TextMessage *msg)
 Constructor for Event. More...
 
virtual ~Event ()
 destructor More...
 
PropertySet::Ptr getPropertySet () const
 retrieve the PropertySet for this Event More...
 
std::string getPubDate ()
 get the publication date of this Event, in ASCII More...
 
long long getPubTime ()
 get the publication time of this Event More...
 
void setPubTime (long long t)
 set the publication time of this Event More...
 
long long getEventTime ()
 get the event creation time More...
 
void setEventTime (long long nsecs)
 set the event creation time More...
 
void updateEventTime ()
 update the Event time to the current time More...
 
std::string getEventDate ()
 get the Event Date More...
 
std::string getRunId ()
 get the RunId for this Event More...
 
std::string getType ()
 get the Event type More...
 
std::string getStatus ()
 get the Event status More...
 
void setStatus (std::string status)
 set the Event status More...
 
void setTopic (std::string topic)
 set the Event topic More...
 
std::string getTopic ()
 get the Event topic More...
 
vector< std::string > getFilterablePropertyNames ()
 return all filterable property names More...
 
vector< std::string > getCustomPropertyNames ()
 return all custom property names More...
 
PropertySet::Ptr getCustomPropertySet () const
 return all custom property set More...
 
virtual void populateHeader (cms::TextMessage *msg) const
 populate a cms::TextMessage header with properties More...
 
void marshall (cms::TextMessage *msg)
 marshall values in this event into a cms::TextMessage More...
 

Static Public Attributes

static const std::string TYPE = "TYPE"
 
static const std::string EVENTTIME = "EVENTTIME"
 
static const std::string RUNID = "RUNID"
 
static const std::string STATUS = "STATUS"
 
static const std::string TOPIC = "TOPIC"
 
static const std::string PUBTIME = "PUBTIME"
 
static const std::string UNINITIALIZED = "uninitialized"
 

Protected Member Functions

void _init ()
 
void _constructor (std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
 
template<typename T >
void add (std::string const &name, std::string const &tag, PropertySet const &properties, boost::property_tree::ptree &child)
 

Protected Attributes

PropertySet::Ptr _psp
 
PropertySet::Ptr _filterable
 
set< std::string > _keywords
 

Private Member Functions

std::string marshall (PropertySet const &properties)
 
PropertySet::Ptr processTextMessage (cms::TextMessage *textMessage)
 
PropertySet::Ptr unmarshall (std::string const &text)
 
PropertySet::Ptr parsePropertySet (boost::property_tree::ptree child)
 
bool addDataItem (std::string const &typeInfo, boost::property_tree::ptree &item, std::string const &key, PropertySet &properties)
 

Detailed Description

Representation of an LSST Event.

Definition at line 62 of file Event.h.

Constructor & Destructor Documentation

lsst::ctrl::events::Event::Event ( )

Constructor for Event with no properties.

Definition at line 81 of file Event.cc.

81  {
82  _init();
83 }
lsst::ctrl::events::Event::Event ( PropertySet const &  properties)

Constructor for Event.

Parameters
[in]propertiesthe PropertySet to use to populate the event

Definition at line 173 of file Event.cc.

173  {
174  const std::string empty;
175  PropertySet p;
176  _constructor(empty, ps, p);
177 }
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:198
Class for storing generic metadata.
Definition: PropertySet.h:82
lsst::ctrl::events::Event::Event ( PropertySet const &  properties,
PropertySet const &  filterable 
)

Constructor for Event.

Parameters
[in]propertiesthe PropertySet to use to populate the event
[in]filterablePropertySet of types to be added to the header so they can be filtered.

Definition at line 179 of file Event.cc.

179  {
180  const std::string empty;
181  _constructor(empty, ps, filterable);
182 }
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:198
lsst::ctrl::events::Event::Event ( std::string const &  runid,
PropertySet::Ptr const  properties 
)

Constructor for Event.

Parameters
[in]runidA "run id" to place in the header of this event
[in]propertiesthe PropertySet::Ptr to use to populate the event

Definition at line 184 of file Event.cc.

184  {
185  PropertySet p;
186  _constructor(runId, *psp, p);
187 }
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:198
Class for storing generic metadata.
Definition: PropertySet.h:82
lsst::ctrl::events::Event::Event ( std::string const &  runid,
PropertySet const &  properties 
)

Constructor for Event.

Parameters
[in]runidA "run id" to place in the header of this event
[in]propertiesthe PropertySet to use to populate the event

Definition at line 189 of file Event.cc.

189  {
190  PropertySet p;
191  _constructor(runId, ps, p);
192 }
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:198
Class for storing generic metadata.
Definition: PropertySet.h:82
lsst::ctrl::events::Event::Event ( std::string const &  runid,
PropertySet const &  properties,
PropertySet const &  filterable 
)

Constructor for Event.

Parameters
[in]runidA "run id" to place in the header of this event
[in]propertiesthe PropertySet to use to populate the event
[in]filterablePropertySet of types to be added to the header so they can be filtered.

Definition at line 194 of file Event.cc.

194  {
195  _constructor(runId, ps, filterable);
196 }
void _constructor(std::string const &runid, PropertySet const &properties, PropertySet const &filterable)
Definition: Event.cc:198
lsst::ctrl::events::Event::Event ( cms::TextMessage *  msg)

Constructor for Event.

Parameters
[in]msgA cms::TextMessage to convert into an Event object

Definition at line 93 of file Event.cc.

93  {
94 
95  vector<std::string>names = msg->getPropertyNames();
96 
97  _psp = processTextMessage(msg);
98 
99  for (vector<std::string>::iterator name = names.begin(); name != names.end(); ++name) {
100  _keywords.insert(*name);
101  }
102 
103  _psp->set(EVENTTIME, msg->getCMSTimestamp());
104 
105  for (vector<std::string>::iterator n = names.begin(); n != names.end(); ++n) {
106  std::string const& name = *n;
107  cms::Message::ValueType vType = msg->getPropertyValueType(name);
108  switch(vType) {
109  case cms::Message::NULL_TYPE:
110  _psp->set(name, NULL);
111  break;
112  case cms::Message::BOOLEAN_TYPE:
113  _psp->set(name, msg->getBooleanProperty(name));
114  break;
115  case cms::Message::BYTE_TYPE:
116  case cms::Message::CHAR_TYPE:
117  _psp->set(name, msg->getByteProperty(name));
118  break;
119  case cms::Message::SHORT_TYPE:
120  _psp->set(name, msg->getShortProperty(name));
121  break;
122  case cms::Message::INTEGER_TYPE:
123  _psp->set(name, msg->getIntProperty(name));
124  break;
125  case cms::Message::LONG_TYPE:
126  _psp->set(name, msg->getLongProperty(name));
127  break;
128  case cms::Message::DOUBLE_TYPE:
129  _psp->set(name, msg->getDoubleProperty(name));
130  break;
131  case cms::Message::FLOAT_TYPE:
132  _psp->set(name, msg->getFloatProperty(name));
133  break;
134  case cms::Message::STRING_TYPE:
135  _psp->set(name, msg->getStringProperty(name));
136  break;
137  case cms::Message::BYTE_ARRAY_TYPE:
138  case cms::Message::UNKNOWN_TYPE:
139  default:
140  std::string msg("Data type represented by "+name+" is not permitted supported");
141  throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
142  break;
143  }
144  }
145 
146 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENTTIME
Definition: Event.h:67
set< std::string > _keywords
Definition: Event.h:238
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
PropertySet::Ptr processTextMessage(cms::TextMessage *textMessage)
Definition: Event.cc:419
lsst::ctrl::events::Event::~Event ( )
virtual

destructor

Definition at line 520 of file Event.cc.

520  {
521 }

Member Function Documentation

void lsst::ctrl::events::Event::_constructor ( std::string const &  runid,
PropertySet const &  properties,
PropertySet const &  filterable 
)
protected

Definition at line 198 of file Event.cc.

198  {
199  _init();
200 
201  _psp = ps.deepCopy();
202 
203 
204  // do NOT alter the property set we were given. Make a copy of it,
205  // and modify that one.
206 
207  if (!_psp->exists(STATUS)) {
208  _psp->set(STATUS, "unknown");
209  }
210 
211  if (!_psp->exists(EVENTTIME)) {
212  updateEventTime();
213  }
214 
215  // _runId is filled in here and is ignored in the passed PropertySet
216  if (!runId.empty()) {
217  _keywords.insert(RUNID);
218  _psp->set(RUNID, runId);
219  }
220 
221  // _type is filled in here and is ignored in the passed PropertySet
222  _psp->set(TYPE, EventTypes::EVENT);
223 
224  // _topic is filled in on publish and is ignored in the passed PropertySet
226 
227  // _pubTime is filled in on publish and is ignored in the passed PropertySet
228  _psp->set(PUBTIME, (long long)0);
229 
230  if (filterable.nameCount() > 0) {
231  vector<std::string> names = filterable.names();
232 
233  for (vector<std::string>::iterator name = names.begin(); name != names.end(); ++name) {
234  _keywords.insert(*name);
235  }
236 
237  _psp->combine(filterable.PropertySet::deepCopy());
238  }
239 }
static const std::string STATUS
Definition: Event.h:69
static const std::string TOPIC
Definition: Event.h:70
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static const std::string RUNID
Definition: Event.h:68
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENT
Definition: EventTypes.h:46
static const std::string EVENTTIME
Definition: Event.h:67
void updateEventTime()
update the Event time to the current time
Definition: Event.cc:278
static const std::string PUBTIME
Definition: Event.h:71
set< std::string > _keywords
Definition: Event.h:238
static const std::string TYPE
Definition: Event.h:66
static const std::string UNINITIALIZED
Definition: Event.h:72
void lsst::ctrl::events::Event::_init ( )
protected

Definition at line 85 of file Event.cc.

85  {
86  _keywords.insert(TYPE);
87  _keywords.insert(EVENTTIME);
88  _keywords.insert(STATUS);
89  _keywords.insert(TOPIC);
90  _keywords.insert(PUBTIME);
91 }
static const std::string STATUS
Definition: Event.h:69
static const std::string TOPIC
Definition: Event.h:70
static const std::string EVENTTIME
Definition: Event.h:67
static const std::string PUBTIME
Definition: Event.h:71
set< std::string > _keywords
Definition: Event.h:238
static const std::string TYPE
Definition: Event.h:66
template<typename T >
template void lsst::ctrl::events::Event::add< long long > ( std::string const &  name,
std::string const &  tag,
PropertySet const &  properties,
boost::property_tree::ptree &  child 
)
protected

Definition at line 364 of file Event.cc.

364  {
365 
366  std::vector<T> vec = ps.getArray<T>(name);
367 
368  typename std::vector<T>::iterator iter;
369  for (iter = vec.begin(); iter != vec.end(); iter++) {
370  boost::property_tree::ptree pt;
371  pt.put(tag, *iter);
372  child.put_child(name, pt);
373  }
374 }
int iter
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool lsst::ctrl::events::Event::addDataItem ( std::string const &  typeInfo,
boost::property_tree::ptree &  item,
std::string const &  key,
PropertySet ps 
)
private

private method to try to add data to a property set

Parameters
typeInfoa string containing the name of the data type
itema node of a boost::property_tree::ptree containing data
keythe name of the data
psa PropertySet to store the name and data into.
Returns
true if data was added to the PropertySet

Definition at line 435 of file Event.cc.

435  {
436  if (typeInfo == "string") {
437  std::string value = item.get_value<std::string>();
438  ps.add(key, value);
439  } else if (typeInfo == "bool") {
440  bool value = item.get_value<bool>();
441  ps.add(key, value);
442  } else if (typeInfo == "long") {
443  long value = item.get_value<long>();
444  ps.add(key, value);
445  } else if (typeInfo == "long long") {
446  long long value = item.get_value<long long>();
447  ps.add(key, value);
448  } else if (typeInfo == "int") {
449  int value = item.get_value<int>();
450  ps.add(key, value);
451  } else if (typeInfo == "float") {
452  float value = item.get_value<float>();
453  ps.add(key, value);
454  } else if (typeInfo == "double") {
455  double value = item.get_value<double>();
456  ps.add(key, value);
457  } else if (typeInfo == "datetime") {
458  long long value = item.get_value<long long>();
460  } else {
461  return false;
462  }
463  return true;
464 }
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
vector< std::string > lsst::ctrl::events::Event::getCustomPropertyNames ( )

return all custom property names

Returns
a vector of custom property names

Definition at line 157 of file Event.cc.

157  {
158  vector<std::string> names = _psp->names();
159 
160  vector<std::string>::iterator nameIterator;
161  set<std::string>::iterator keyIterator;
162 
163  for (nameIterator = names.begin(); nameIterator != names.end();) {
164  keyIterator = _keywords.find(*nameIterator);
165  if (keyIterator == _keywords.end())
166  nameIterator++;
167  else
168  names.erase(nameIterator);
169  }
170  return names;
171 }
PropertySet::Ptr _psp
Definition: Event.h:236
set< std::string > _keywords
Definition: Event.h:238
PropertySet::Ptr lsst::ctrl::events::Event::getCustomPropertySet ( ) const

return all custom property set

Returns
a PropertySet::Ptr of custom properties

Definition at line 292 of file Event.cc.

292  {
293  PropertySet::Ptr psp = _psp->deepCopy();
294 
295  set<std::string>::iterator keyIterator;
296  for (keyIterator = _keywords.begin(); keyIterator != _keywords.end(); keyIterator++)
297  psp->remove(*keyIterator);
298  return psp;
299 }
PropertySet::Ptr _psp
Definition: Event.h:236
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
set< std::string > _keywords
Definition: Event.h:238
std::string lsst::ctrl::events::Event::getEventDate ( )

get the Event Date

Returns
a formatted date string representing the Event creation time

Definition at line 283 of file Event.cc.

283  {
284  long long eventTime = _psp->get<long long>(EVENTTIME);
285  dafBase::DateTime dateTime(eventTime);
286 
287  struct tm gmTime = dateTime.gmtime();
288  return asctime(&gmTime);
289 }
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENTTIME
Definition: Event.h:67
long long lsst::ctrl::events::Event::getEventTime ( )

get the event creation time

Returns
time in nanoseconds

Definition at line 270 of file Event.cc.

270  {
271  return _psp->get<long long>(EVENTTIME);
272 }
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENTTIME
Definition: Event.h:67
vector< std::string > lsst::ctrl::events::Event::getFilterablePropertyNames ( )

return all filterable property names

Returns
a vector of filterable property names

Definition at line 148 of file Event.cc.

148  {
149  vector<std::string> _names;
150  set<std::string>::iterator keyIterator;
151  for (keyIterator = _keywords.begin(); keyIterator != _keywords.end(); keyIterator++) {
152  _names.push_back(*keyIterator);
153  }
154  return _names;
155 }
set< std::string > _keywords
Definition: Event.h:238
PropertySet::Ptr lsst::ctrl::events::Event::getPropertySet ( ) const

retrieve the PropertySet for this Event

Returns
PropertySet::Ptr to this PropertySet

Definition at line 301 of file Event.cc.

301  {
302  if (_psp != 0) {
303  PropertySet::Ptr psp = _psp->deepCopy();
304  return psp;
305  }
306  PropertySet::Ptr psp(new PropertySet);
307  return psp;
308 }
PropertySet::Ptr _psp
Definition: Event.h:236
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
Class for storing generic metadata.
Definition: PropertySet.h:82
std::string lsst::ctrl::events::Event::getPubDate ( )

get the publication date of this Event, in ASCII

Definition at line 318 of file Event.cc.

318  {
319  long long _pubTime = _psp->get<long long>(PUBTIME);
320  if (_pubTime == 0)
321  return std::string();
322 
323  dafBase::DateTime dateTime(_pubTime);
324 
325  struct tm pubTime = dateTime.gmtime();
326  return asctime(&pubTime);
327 }
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string PUBTIME
Definition: Event.h:71
long long lsst::ctrl::events::Event::getPubTime ( )

get the publication time of this Event

Returns
time in nanoseconds

Definition at line 314 of file Event.cc.

314  {
315  return _psp->get<long long>(PUBTIME);
316 }
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string PUBTIME
Definition: Event.h:71
std::string lsst::ctrl::events::Event::getRunId ( )

get the RunId for this Event

Returns
string representation of the run id

Definition at line 329 of file Event.cc.

329  {
330  if (_psp->exists(RUNID))
331  return _psp->get<std::string>(RUNID);
332  throw LSST_EXCEPT(pexExceptions::RuntimeError, std::string("property RUNID not found"));
333 }
static const std::string RUNID
Definition: Event.h:68
PropertySet::Ptr _psp
Definition: Event.h:236
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::string lsst::ctrl::events::Event::getStatus ( )

get the Event status

Returns
string representation of the Event status

Definition at line 339 of file Event.cc.

339  {
340  return _psp->get<std::string>(STATUS);
341 }
static const std::string STATUS
Definition: Event.h:69
PropertySet::Ptr _psp
Definition: Event.h:236
std::string lsst::ctrl::events::Event::getTopic ( )

get the Event topic

Returns
string representation of the Event topic

Definition at line 351 of file Event.cc.

351  {
352  return _psp->get<std::string>(TOPIC);
353 }
static const std::string TOPIC
Definition: Event.h:70
PropertySet::Ptr _psp
Definition: Event.h:236
std::string lsst::ctrl::events::Event::getType ( void  )

get the Event type

Returns
string representation of the Event type

Definition at line 335 of file Event.cc.

335  {
336  return _psp->get<std::string>(TYPE);
337 }
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string TYPE
Definition: Event.h:66
void lsst::ctrl::events::Event::marshall ( cms::TextMessage *  msg)

marshall values in this event into a cms::TextMessage

Definition at line 355 of file Event.cc.

355  {
356  PropertySet::Ptr psp;
357 
358  populateHeader(msg);
359  psp = getCustomPropertySet();
360  std::string payload = marshall(*psp);
361  msg->setText(payload);
362 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: Event.cc:241
PropertySet::Ptr getCustomPropertySet() const
return all custom property set
Definition: Event.cc:292
void marshall(cms::TextMessage *msg)
marshall values in this event into a cms::TextMessage
Definition: Event.cc:355
std::string lsst::ctrl::events::Event::marshall ( PropertySet const &  properties)
private

Definition at line 376 of file Event.cc.

376  {
377  std::vector<std::string> names = ps.paramNames(false);
378 
379  boost::property_tree::ptree child;
380 
381  for (vector<std::string>::iterator n = names.begin(); n != names.end(); ++n) {
382  std::string name = *n;
383 
384  if (ps.typeOf(name) == typeid(bool)) {
385  add<bool>(name, "bool", ps, child);
386  } else if (ps.typeOf(name) == typeid(long)) {
387  add<long>(name, "long", ps, child);
388  } else if (ps.typeOf(name) == typeid(long long)) {
389  add<long long>(name, "long long", ps, child);
390  } else if (ps.typeOf(name) == typeid(int)) {
391  add<int>(name, "int", ps, child);
392  } else if (ps.typeOf(name) == typeid(float)) {
393  add<float>(name, "float", ps, child);
394  } else if (ps.typeOf(name) == typeid(double)) {
395  add<double>(name, "double", ps, child);
396  } else if (ps.typeOf(name) == typeid(std::string)) {
397  add<std::string>(name, "string", ps, child);
398  } else if (ps.typeOf(name) == typeid(lsst::daf::base::DateTime)) {
399  std::vector<lsst::daf::base::DateTime> vec = ps.getArray<lsst::daf::base::DateTime>(name);
400  std::vector<lsst::daf::base::DateTime>::iterator iter;
401  for (iter = vec.begin(); iter != vec.end(); iter++) {
402  boost::property_tree::ptree pt;
403  pt.put("datetime", (*iter).nsecs());
404  child.put_child(name, pt);
405  }
406  } else {
407  std::string msg("Couldn't marshall "+name);
408  throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
409  }
410  }
411  std::ostringstream payload;
412  write_json(payload, child, false);
413 
414  return payload.str();
415 }
int iter
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
PropertySet::Ptr lsst::ctrl::events::Event::parsePropertySet ( boost::property_tree::ptree  child)
private

private method to iterate through the representation of a propertyset within the boost::property_tree::ptree

Parameters
childa boost::property_tree::ptree to iterate through
Returns
a PropertySet::Ptr containing the data that was stored in child.

Definition at line 471 of file Event.cc.

471  {
472  PropertySet::Ptr psp(new PropertySet);
473 
474  BOOST_FOREACH(boost::property_tree::ptree::value_type const &v, child.get_child("")) {
475  std::string label = v.first;
476  BOOST_FOREACH(boost::property_tree::ptree::value_type &v2, child.get_child(label)) {
477  const bool b = addDataItem(v2.first, v2.second, label, *psp);
478  if (!b) {
479  PropertySet::Ptr p2 = parsePropertySet(child.get_child(label));
480  psp->add(label, p2);
481  break;
482  }
483  }
484  }
485  return psp;
486 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
PropertySet::Ptr parsePropertySet(boost::property_tree::ptree child)
Definition: Event.cc:471
bool addDataItem(std::string const &typeInfo, boost::property_tree::ptree &item, std::string const &key, PropertySet &properties)
Definition: Event.cc:435
Class for storing generic metadata.
Definition: PropertySet.h:82
afw::table::Key< double > b
void lsst::ctrl::events::Event::populateHeader ( cms::TextMessage *  msg) const
virtual

populate a cms::TextMessage header with properties

Parameters
[in]msga cms::TextMessage

Reimplemented in lsst::ctrl::events::CommandEvent, lsst::ctrl::events::StatusEvent, and lsst::ctrl::events::LogEvent.

Definition at line 241 of file Event.cc.

241  {
242  set<std::string>::iterator keyIterator;
243  for (keyIterator = _keywords.begin(); keyIterator != _keywords.end(); keyIterator++) {
244  std::string const& name = *keyIterator;
245  std::type_info const& t = _psp->typeOf(name);
246  if (t == typeid(bool)) {
247  msg->setBooleanProperty(name, _psp->get<bool>(name));
248  } else if (t == typeid(short)) {
249  msg->setShortProperty(name, _psp->get<short>(name));
250  } else if (t == typeid(int)) {
251  msg->setIntProperty(name, _psp->get<int>(name));
252  } else if (t == typeid(long)) {
253  msg->setLongProperty(name, _psp->get<long>(name));
254  } else if (t == typeid(long long)) {
255  msg->setLongProperty(name, _psp->get<long long>(name));
256  } else if (t == typeid(double)) {
257  msg->setDoubleProperty(name, _psp->get<double>(name));
258  } else if (t == typeid(float)) {
259  msg->setFloatProperty(name, _psp->get<float>(name));
260  } else if (t == typeid(std::string)) {
261  msg->setStringProperty(name, _psp->get<std::string>(name));
262  } else {
263  std::string msg("Data type represented in "+ name +" is not permitted in event header");
264  throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
265  }
266  }
267 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
PropertySet::Ptr _psp
Definition: Event.h:236
set< std::string > _keywords
Definition: Event.h:238
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
PropertySet::Ptr lsst::ctrl::events::Event::processTextMessage ( cms::TextMessage *  textMessage)
private

private method unmarshall the DataProperty from the TextMessage

Definition at line 419 of file Event.cc.

419  {
420  if (textMessage == NULL)
421  return PropertySet::Ptr();
422 
423  std::string text = textMessage->getText();
424 
425  return unmarshall(text);
426 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
PropertySet::Ptr unmarshall(std::string const &text)
Definition: Event.cc:492
void lsst::ctrl::events::Event::setEventTime ( long long  nsecs)

set the event creation time

Definition at line 274 of file Event.cc.

274  {
275  _psp->set(EVENTTIME, nsecs);
276 }
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENTTIME
Definition: Event.h:67
void lsst::ctrl::events::Event::setPubTime ( long long  t)

set the publication time of this Event

Definition at line 310 of file Event.cc.

310  {
311  _psp->set(PUBTIME, t);
312 }
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string PUBTIME
Definition: Event.h:71
void lsst::ctrl::events::Event::setStatus ( std::string  status)

set the Event status

Parameters
[in]statusstring representation of the Event status

Definition at line 343 of file Event.cc.

343  {
344  return _psp->set(STATUS, status);
345 }
static const std::string STATUS
Definition: Event.h:69
PropertySet::Ptr _psp
Definition: Event.h:236
int status
void lsst::ctrl::events::Event::setTopic ( std::string  topic)

set the Event topic

Parameters
[in]topicstring representation of the Event topic

Definition at line 347 of file Event.cc.

347  {
348  _psp->set(TOPIC, topic);
349 }
static const std::string TOPIC
Definition: Event.h:70
PropertySet::Ptr _psp
Definition: Event.h:236
PropertySet::Ptr lsst::ctrl::events::Event::unmarshall ( std::string const &  text)
private

private method unmarshall the DataProperty from a text string

Parameters
texta JSON text string
Returns
a PropertySet::Ptr containing the data that was stored in text

Definition at line 492 of file Event.cc.

492  {
493 
494  boost::property_tree::ptree pt;
495  std::istringstream is (text);
496  read_json(is, pt);
497 
498  PropertySet::Ptr psp(new PropertySet);
499 
500  BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt) {
501  std::string key = v.first;
502 
503  boost::property_tree::ptree child = v.second;
504  BOOST_FOREACH(boost::property_tree::ptree::value_type &v2, child) {
505  std::string key2 = v2.first;
506 
507  const bool b = addDataItem(key2, v2.second, key, *psp);
508  if (!b) {
509  std::string value = v2.second.get_value<std::string>();
511  psp->add(key, p);
512  break;
513  }
514  }
515  }
516 
517  return psp;
518 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
PropertySet::Ptr parsePropertySet(boost::property_tree::ptree child)
Definition: Event.cc:471
bool addDataItem(std::string const &typeInfo, boost::property_tree::ptree &item, std::string const &key, PropertySet &properties)
Definition: Event.cc:435
Class for storing generic metadata.
Definition: PropertySet.h:82
afw::table::Key< double > b
void lsst::ctrl::events::Event::updateEventTime ( )

update the Event time to the current time

Definition at line 278 of file Event.cc.

278  {
279  _psp->set(EVENTTIME, (long long)dafBase::DateTime::now().nsecs());
280 }
static DateTime now(void)
Definition: DateTime.cc:554
PropertySet::Ptr _psp
Definition: Event.h:236
static const std::string EVENTTIME
Definition: Event.h:67

Member Data Documentation

PropertySet::Ptr lsst::ctrl::events::Event::_filterable
protected

Definition at line 237 of file Event.h.

set<std::string> lsst::ctrl::events::Event::_keywords
protected

Definition at line 238 of file Event.h.

PropertySet::Ptr lsst::ctrl::events::Event::_psp
protected

Definition at line 236 of file Event.h.

const std::string lsst::ctrl::events::Event::EVENTTIME = "EVENTTIME"
static

Definition at line 67 of file Event.h.

const std::string lsst::ctrl::events::Event::PUBTIME = "PUBTIME"
static

Definition at line 71 of file Event.h.

const std::string lsst::ctrl::events::Event::RUNID = "RUNID"
static

Definition at line 68 of file Event.h.

const std::string lsst::ctrl::events::Event::STATUS = "STATUS"
static

Definition at line 69 of file Event.h.

const std::string lsst::ctrl::events::Event::TOPIC = "TOPIC"
static

Definition at line 70 of file Event.h.

const std::string lsst::ctrl::events::Event::TYPE = "TYPE"
static

Definition at line 66 of file Event.h.

const std::string lsst::ctrl::events::Event::UNINITIALIZED = "uninitialized"
static

Definition at line 72 of file Event.h.


The documentation for this class was generated from the following files: