McStas Readout Master 0.8.0
Loading...
Searching...
No Matches
CollectorSink Class Reference

Public Member Functions

 CollectorSink (CollectorSink &other)=delete
 
void operator= (const CollectorSink &)=delete
 
bool is_setup () const
 
std::string current_filename () const
 
size_t user_count () const
 
void setup (const std::string &filename)
 Open (or create) the one file this process collects into.
 
size_t count_points () const
 How many scan points the file already holds, read from any collector group.
 
void teardown ()
 
std::optional< HighFive::Group > getCollector (const std::string &name, const DetectorType &detector, const ReadoutType &readout)
 
std::optional< HighFive::Group > getCollector (const std::string &name, const HighFive::DataType &datatype, const std::optional< DetectorType > &detector=std::nullopt, const std::optional< std::string > &description=std::nullopt)
 Get (or create) a collector group for records of an arbitrary compound datatype.
 
auto removeCollector (const std::string &name)
 
template<class T >
void addParameter (const std::string &name, T value, const std::optional< std::string > &unit=std::nullopt, const std::optional< std::string > &description=std::nullopt)
 

Static Public Member Functions

static const std::string & type_attribute ()
 
static const std::string & collector_group_type ()
 
static const std::string & readout_dataset_name ()
 
static const std::string & cue_dataset_name ()
 
static const std::string & weight_dataset_name ()
 
static const std::string & normalization_dataset_name ()
 
static const std::string & detector_attribute_name ()
 The detector identity is a GROUP attribute, alongside the EFU routing attributes: together they say where — and as what — a group replays. The record layout needs no attribute at all: it is the dataset's own compound datatype, compared against the registry for sendability.
 
static const std::string & efu_address_attribute_name ()
 
static const std::string & efu_port_attribute_name ()
 
static const std::string & parameter_group_type ()
 
static const std::string & parameter_group_name ()
 
static const std::string & parameter_unit_attribute_name ()
 
static const std::string & parameter_description_attribute_name ()
 
static const std::string & program_attribute_name ()
 
static const std::string & version_attribute_name ()
 
static const std::string & revision_attribute_name ()
 
static const std::string & program_attribute_value ()
 
static const std::string & version_attribute_value ()
 
static const std::string & revision_attribute_value ()
 
static RL_API CollectorSink * instance ()
 
static void destroy ()
 
static bool allow_existing_file ()
 Whether a run may add to a collector file that already existed.
 
template<class T >
static void extend_points (HighFive::DataSet ds, const size_t length, const T value)
 Grow a per-point dataset to length, filling any new elements with value.
 

Protected Attributes

std::set< std::string > users_
 
bool appending_ {false}
 Whether this run is adding a scan point to a file that already held some.
 
size_t points_before_ {0}
 How many points the file held when this run opened it.
 
std::optional< std::string > filename_ {std::nullopt}
 
std::optional< HighFive::File > file_ {std::nullopt}
 
std::optional< HighFive::Group > collector_
 
std::optional< HighFive::Group > parameters_ {std::nullopt}
 

Detailed Description

Definition at line 129 of file CollectorClass.h.

Member Function Documentation

◆ addParameter()

template<class T >
void CollectorSink::addParameter ( const std::string &  name,
T  value,
const std::optional< std::string > &  unit = std::nullopt,
const std::optional< std::string > &  description = std::nullopt 
)
inline

Definition at line 422 of file CollectorClass.h.

◆ allow_existing_file()

static bool CollectorSink::allow_existing_file ( )
inlinestatic

Whether a run may add to a collector file that already existed.

False unless READOUT_ALLOW_EXISTING_FILE is set in the environment. See setup().

Definition at line 244 of file CollectorClass.h.

Referenced by setup().

◆ collector_group_type()

static const std::string & CollectorSink::collector_group_type ( )
inlinestatic

Definition at line 147 of file CollectorClass.h.

◆ count_points()

size_t CollectorSink::count_points ( ) const
inline

How many scan points the file already holds, read from any collector group.

The collector groups are the authority – every one of them carries one cue per point – and a file with no collector groups yet holds no points.

Definition at line 291 of file CollectorClass.h.

Referenced by setup().

◆ cue_dataset_name()

static const std::string & CollectorSink::cue_dataset_name ( )
inlinestatic

Definition at line 155 of file CollectorClass.h.

◆ current_filename()

std::string CollectorSink::current_filename ( ) const
inline

Definition at line 238 of file CollectorClass.h.

◆ destroy()

static void CollectorSink::destroy ( )
inlinestatic

Definition at line 233 of file CollectorClass.h.

◆ detector_attribute_name()

static const std::string & CollectorSink::detector_attribute_name ( )
inlinestatic

The detector identity is a GROUP attribute, alongside the EFU routing attributes: together they say where — and as what — a group replays. The record layout needs no attribute at all: it is the dataset's own compound datatype, compared against the registry for sendability.

Definition at line 172 of file CollectorClass.h.

Referenced by getCollector().

◆ efu_address_attribute_name()

static const std::string & CollectorSink::efu_address_attribute_name ( )
inlinestatic

Definition at line 176 of file CollectorClass.h.

◆ efu_port_attribute_name()

static const std::string & CollectorSink::efu_port_attribute_name ( )
inlinestatic

Definition at line 180 of file CollectorClass.h.

◆ extend_points()

template<class T >
static void CollectorSink::extend_points ( HighFive::DataSet  ds,
const size_t  length,
const T  value 
)
inlinestatic

Grow a per-point dataset to length, filling any new elements with value.

Definition at line 311 of file CollectorClass.h.

◆ getCollector() [1/2]

std::optional< HighFive::Group > CollectorSink::getCollector ( const std::string &  name,
const DetectorType &  detector,
const ReadoutType &  readout 
)
inline

Definition at line 337 of file CollectorClass.h.

◆ getCollector() [2/2]

std::optional< HighFive::Group > CollectorSink::getCollector ( const std::string &  name,
const HighFive::DataType &  datatype,
const std::optional< DetectorType > &  detector = std::nullopt,
const std::optional< std::string > &  description = std::nullopt 
)
inline

Get (or create) a collector group for records of an arbitrary compound datatype.

The typed overload above resolves the registry datatype for its ReadoutType; this overload accepts any compound type so user-described records get the same cue-based layout. The detector identity — the ESS packet-type byte, unrecoverable from the record layout — is written as a group attribute when known; the original type description string (when given) is stored as a dataset attribute.

Definition at line 352 of file CollectorClass.h.

References detector_attribute_name(), and points_before_.

◆ is_setup()

bool CollectorSink::is_setup ( ) const
inline

Definition at line 237 of file CollectorClass.h.

◆ normalization_dataset_name()

static const std::string & CollectorSink::normalization_dataset_name ( )
inlinestatic

Definition at line 163 of file CollectorClass.h.

◆ parameter_description_attribute_name()

static const std::string & CollectorSink::parameter_description_attribute_name ( )
inlinestatic

Definition at line 197 of file CollectorClass.h.

◆ parameter_group_name()

static const std::string & CollectorSink::parameter_group_name ( )
inlinestatic

Definition at line 189 of file CollectorClass.h.

◆ parameter_group_type()

static const std::string & CollectorSink::parameter_group_type ( )
inlinestatic

Definition at line 185 of file CollectorClass.h.

◆ parameter_unit_attribute_name()

static const std::string & CollectorSink::parameter_unit_attribute_name ( )
inlinestatic

Definition at line 193 of file CollectorClass.h.

◆ program_attribute_name()

static const std::string & CollectorSink::program_attribute_name ( )
inlinestatic

Definition at line 201 of file CollectorClass.h.

◆ program_attribute_value()

static const std::string & CollectorSink::program_attribute_value ( )
inlinestatic

Definition at line 213 of file CollectorClass.h.

◆ readout_dataset_name()

static const std::string & CollectorSink::readout_dataset_name ( )
inlinestatic

Definition at line 151 of file CollectorClass.h.

◆ removeCollector()

auto CollectorSink::removeCollector ( const std::string &  name)
inline

Definition at line 417 of file CollectorClass.h.

◆ revision_attribute_name()

static const std::string & CollectorSink::revision_attribute_name ( )
inlinestatic

Definition at line 209 of file CollectorClass.h.

◆ revision_attribute_value()

static const std::string & CollectorSink::revision_attribute_value ( )
inlinestatic

Definition at line 221 of file CollectorClass.h.

◆ setup()

void CollectorSink::setup ( const std::string &  filename)
inline

Open (or create) the one file this process collects into.

Called once per file per process, from the Collector constructors and guarded by is_setup() – which is what makes it the right place to refuse a file that was already on disk. Several collectors sharing one file are expected and fine; what is not fine is a second run writing into the file a previous one left behind, which folds its rays into the earlier run's scan point and leaves one set of parameter values standing for all of them. Nothing errors when that happens, which is why it is refused here rather than detected later.

Definition at line 258 of file CollectorClass.h.

References allow_existing_file(), appending_, count_points(), and points_before_.

◆ teardown()

void CollectorSink::teardown ( )
inline

Definition at line 322 of file CollectorClass.h.

◆ type_attribute()

static const std::string & CollectorSink::type_attribute ( )
inlinestatic

Definition at line 143 of file CollectorClass.h.

◆ user_count()

size_t CollectorSink::user_count ( ) const
inline

Definition at line 239 of file CollectorClass.h.

◆ version_attribute_name()

static const std::string & CollectorSink::version_attribute_name ( )
inlinestatic

Definition at line 205 of file CollectorClass.h.

◆ version_attribute_value()

static const std::string & CollectorSink::version_attribute_value ( )
inlinestatic

Definition at line 217 of file CollectorClass.h.

◆ weight_dataset_name()

static const std::string & CollectorSink::weight_dataset_name ( )
inlinestatic

Definition at line 159 of file CollectorClass.h.

Member Data Documentation

◆ appending_

bool CollectorSink::appending_ {false}
protected

Whether this run is adding a scan point to a file that already held some.

Definition at line 135 of file CollectorClass.h.

Referenced by setup().

◆ collector_

std::optional<HighFive::Group> CollectorSink::collector_
protected

Definition at line 140 of file CollectorClass.h.

◆ file_

std::optional<HighFive::File> CollectorSink::file_ {std::nullopt}
protected

Definition at line 139 of file CollectorClass.h.

◆ filename_

std::optional<std::string> CollectorSink::filename_ {std::nullopt}
protected

Definition at line 138 of file CollectorClass.h.

◆ parameters_

std::optional<HighFive::Group> CollectorSink::parameters_ {std::nullopt}
protected

Definition at line 140 of file CollectorClass.h.

◆ points_before_

size_t CollectorSink::points_before_ {0}
protected

How many points the file held when this run opened it.

Definition at line 137 of file CollectorClass.h.

Referenced by getCollector(), and setup().

◆ users_

std::set<std::string> CollectorSink::users_
protected

Definition at line 133 of file CollectorClass.h.


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