1#ifndef _MSPASS_ENSEMBLE_H_
2#define _MSPASS_ENSEMBLE_H_
3#include "mspass/seismic/Seismogram.h"
4#include "mspass/seismic/TimeSeries.h"
5#include "mspass/utility/memory_constants.h"
40 dynamic_cast<const mspass::utility::
Metadata &>(parent)),
44 if (
this != (&parent)) {
61 Tdata &operator[](
const size_t n)
const try {
62 return (this->member[n]);
94 for (i = 0; i < this->member.size(); ++i) {
103 for (
size_t i = 0; i < exclude.size(); i++) {
105 sync_md.
erase(exclude[i]);
108 for (
size_t i = 0; i < this->member.size(); ++i) {
110 (*mdmember) += sync_md;
155 ensemble_is_live =
false;
167 ensemble_is_live =
false;
182 ensemble_is_live = parent.ensemble_is_live;
187 ensemble_is_live =
true;
190 void kill() { ensemble_is_live =
false; };
192 bool live()
const {
return ensemble_is_live; };
195 bool dead()
const {
return !ensemble_is_live; };
213 ensemble_is_live =
true;
221 if (&parent !=
this) {
223 this->member.reserve(parent.
member.size());
224 this->member = parent.
member;
226 ensemble_is_live = parent.ensemble_is_live;
230 size_t memory_use()
const {
232 memuse =
sizeof(*this);
233 for (
auto p = this->member.begin(); p != this->member.end(); ++p) {
234 memuse += p->memory_use();
240 mspass::utility::memory_constants::MD_AVERAGE_SIZE * this->md.size();
241 memuse += mspass::utility::memory_constants::KEY_AVERAGE_SIZE *
242 this->changed_or_set.size();
244 memuse += mspass::utility::memory_constants::ELOG_AVERAGE_SIZE *
250 bool ensemble_is_live;
254 for (
auto dptr = this->member.begin(); dptr != this->member.end(); ++dptr) {
Ensemble()
Definition Ensemble.h:22
void sync_metadata(std::vector< std::string > exclude)
copy ensemble metadata to all members except for the ones excluded.
Definition Ensemble.h:101
std::vector< Tdata > member
Container holding data objects.
Definition Ensemble.h:20
void sync_metadata()
copy ensemble metadata to all members.
Definition Ensemble.h:92
Ensemble(const size_t n)
Reserve space but build empty ensemble.
Definition Ensemble.h:31
void update_metadata(const mspass::utility::Metadata &newmd)
updates ensemble header (Metadata).
Definition Ensemble.h:77
Ensemble(const mspass::utility::Metadata &md, const size_t n)
Definition Ensemble.h:33
Ensemble(const Ensemble &parent)
Definition Ensemble.h:38
Ensemble & operator=(const Ensemble &parent)
Definition Ensemble.h:43
Template class that extends Ensemble to include an error log and live tests.
Definition Ensemble.h:135
LoggingEnsemble(const Ensemble< T > &parent)
Definition Ensemble.h:186
LoggingEnsemble(const mspass::utility::Metadata &md, const mspass::utility::ErrorLogger &elogin, const size_t ndata)
Definition Ensemble.h:175
LoggingEnsemble< T > & operator=(const LoggingEnsemble< T > &parent)
Definition Ensemble.h:220
LoggingEnsemble(const mspass::utility::Metadata &md, const size_t n)
Definition Ensemble.h:163
LoggingEnsemble()
Definition Ensemble.h:141
void kill()
Definition Ensemble.h:190
bool set_live()
Definition Ensemble.h:211
bool validate()
Definition Ensemble.h:253
mspass::utility::ErrorLogger elog
Definition Ensemble.h:138
LoggingEnsemble(const size_t n)
Definition Ensemble.h:154
bool live() const
Definition Ensemble.h:192
LoggingEnsemble(const LoggingEnsemble< T > &parent)
Definition Ensemble.h:180
bool dead() const
Definition Ensemble.h:195
Container to hold error logs for a data object.
Definition ErrorLogger.h:60
Define metadata keys.
Definition BasicSpectrum.h:6
Ensemble< TimeSeries > TimeSeriesEnsemble
Definition Ensemble.h:262
Ensemble< Seismogram > ThreeComponentEnsemble
Definition Ensemble.h:264