xo-alloc/xo-process/include/xo/process/UpxEvent.hpp
Roland Conybeare 2450ab4ed9 Add 'xo-process/' from commit '7cfc560f02'
git-subtree-dir: xo-process
git-subtree-mainline: abd08e3491
git-subtree-split: 7cfc560f02
2025-05-11 16:10:34 -05:00

54 lines
1.8 KiB
C++

/* @file UpxEvent.hpp */
#pragma once
#include "xo/indentlog/timeutil/timeutil.hpp"
namespace xo {
namespace process {
/* typical representation for events emitted by a stochastic process
* writing this as a non-template class (instead of just template alias)
* because we want typeinfo to be generated
*/
class UpxEvent {
public:
using utc_nanos = xo::time::utc_nanos;
public:
UpxEvent();
//UpxEvent(std::pair<utc_nanos, double> const & x) : contents_{x} {}
UpxEvent(std::pair<utc_nanos, double> const & x) : tm_{x.first}, upx_{x.second} {}
//UpxEvent(utc_nanos tm, double x) : contents_{tm, x} {}
UpxEvent(utc_nanos tm, double x) : tm_{tm}, upx_{x} {}
/* reflect UpxEvent object representation */
static void reflect_self();
/* convenience -- e.g. so we can use with EventTimeFn */
//utc_nanos tm() const { return contents_.first; }
utc_nanos tm() const { return tm_; }
//double upx() const { return contents_.second; }
double upx() const { return upx_; }
void display(std::ostream & os) const;
std::string display_string() const;
private:
/* note: earlier version inherited std::pair<>, but this exposed
* pybind11 problem when we tried to control printing
*/
utc_nanos tm_;
double upx_;
//std::pair<utc_nanos, double> contents_;
}; /*UpxEvent*/
inline std::ostream &
operator<<(std::ostream & os, UpxEvent const & x) {
x.display(os);
return os;
} /*operator<<*/
} /*namespace process*/
} /*namespace xo*/
/* end UpxEvent.hpp */