Psyllid  v1.12.4
Project 8 Data Acquisisition Software
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
monarch_wrapper Class Reference

Wrapper class for a monarch3::M3Monarch object. More...

#include <monarch3_wrap.hh>

Inheritance diagram for monarch_wrapper:
Inheritance graph

Public Member Functions

 monarch_wrapper (const std::string &a_filename)
 
 ~monarch_wrapper ()
 
unsigned get_and_increment_file_count () const
 As it says, return the current value to, and then increment, the file count. More...
 
header_wrap_ptr get_header ()
 Returns the header wrapped in a header_wrap_ptr to be filled at the beginning of file writing. More...
 
const header_wrap_ptr get_header () const
 Returns the header wrapped in a header_wrap_ptr for read-only use anytime. More...
 
stream_wrap_ptr get_stream (unsigned a_stream_no)
 
void start_using ()
 Make the wrapper available for use; starts parallel on-deck thread. More...
 
void execute_switch_loop ()
 
void trigger_switch ()
 
bool okay_to_write ()
 Ensure that the file is available to write to (via a stream) More...
 
void switch_to_new_file ()
 
void stop_using ()
 Make the wrapper unavailable for use; stops the parallel on-deck thread. More...
 
void finish_stream (unsigned a_stream_no)
 Finish the given stream. The stream object will be deleted. More...
 
void finish_file ()
 Finish the file. More...
 
monarch_time_point_t get_run_start_time () const
 
void set_stage (monarch_stage a_stage)
 Override the stage value. More...
 
void set_max_file_size (double a_size)
 Set the maximum file size used to determine when a new file is automatically started. More...
 
void record_file_contribution (double a_size)
 

Private Member Functions

void do_cancellation (int a_code)
 
 monarch_wrapper (const monarch_wrapper &)=delete
 
monarch_wrapperoperator= (const monarch_wrapper &)=delete
 

Private Attributes

std::string f_orig_filename
 
std::string f_filename_base
 
std::string f_filename_ext
 
unsigned f_file_count
 
double f_max_file_size_mb
 
std::atomic< double > f_file_size_est_mb
 
std::condition_variable f_wait_to_write
 
std::thread * f_switch_thread
 
std::atomic< bool > f_ok_to_write
 
std::atomic< bool > f_do_switch_flag
 
std::condition_variable f_do_switch_trig
 
std::shared_ptr< monarch3::Monarch3 > f_monarch
 
std::mutex f_monarch_mutex
 
header_wrap_ptr f_header_wrap
 
std::map< unsigned, stream_wrap_ptrf_stream_wraps
 
monarch_time_point_t f_run_start_time
 
monarch_stage f_stage
 
std::thread * f_od_thread
 
monarch_on_deck_manager f_monarch_od_manager
 

Friends

class monarch_on_deck_manager
 

Detailed Description

Wrapper class for a monarch3::M3Monarch object.

Author
N. S. Oblath

Provides the thread-safe, synchronized access to the Monarch object. All thread safety is handled by the interface functions.

Also owns a monarch_on_deck_manager object to handle asynchronous creation of on-deck files and finishing of completed files.

Definition at line 152 of file monarch3_wrap.hh.

Constructor & Destructor Documentation

◆ monarch_wrapper() [1/2]

monarch_wrapper ( const std::string &  a_filename)

Definition at line 239 of file monarch3_wrap.cc.

◆ ~monarch_wrapper()

Definition at line 284 of file monarch3_wrap.cc.

◆ monarch_wrapper() [2/2]

monarch_wrapper ( const monarch_wrapper )
privatedelete

Member Function Documentation

◆ do_cancellation()

void do_cancellation ( int  a_code)
inlineprivate

Definition at line 428 of file monarch3_wrap.hh.

◆ execute_switch_loop()

void execute_switch_loop ( )

Definition at line 427 of file monarch3_wrap.cc.

◆ finish_file()

void finish_file ( )

Finish the file.

Definition at line 519 of file monarch3_wrap.cc.

◆ finish_stream()

void finish_stream ( unsigned  a_stream_no)

Finish the given stream. The stream object will be deleted.

Definition at line 500 of file monarch3_wrap.cc.

◆ get_and_increment_file_count()

unsigned get_and_increment_file_count ( ) const
inline

As it says, return the current value to, and then increment, the file count.

Definition at line 417 of file monarch3_wrap.hh.

◆ get_header() [1/2]

header_wrap_ptr get_header ( )

Returns the header wrapped in a header_wrap_ptr to be filled at the beginning of file writing.

Definition at line 330 of file monarch3_wrap.cc.

◆ get_header() [2/2]

const header_wrap_ptr get_header ( ) const
inline

Returns the header wrapped in a header_wrap_ptr for read-only use anytime.

Definition at line 407 of file monarch3_wrap.hh.

◆ get_run_start_time()

monarch_time_point_t get_run_start_time ( ) const
inline

Definition at line 412 of file monarch3_wrap.hh.

◆ get_stream()

stream_wrap_ptr get_stream ( unsigned  a_stream_no)

Returns the requested stream wrapped in a stream_wrap_ptr to be used to write records to the file. If the header had not been written, this writes the header to the file.

Definition at line 351 of file monarch3_wrap.cc.

◆ okay_to_write()

bool okay_to_write ( )
inline

Ensure that the file is available to write to (via a stream)

Definition at line 660 of file monarch3_wrap.cc.

◆ operator=()

monarch_wrapper& operator= ( const monarch_wrapper )
privatedelete

◆ record_file_contribution()

void record_file_contribution ( double  a_size)

If keeping track of file sizes for automatically creating new files, use this to inform the monarch_wrapper that a given number of bytes was written to the file. This should be called every time a record is written to the file.

Definition at line 647 of file monarch3_wrap.cc.

◆ set_max_file_size()

void set_max_file_size ( double  a_size)
inline

Set the maximum file size used to determine when a new file is automatically started.

Definition at line 422 of file monarch3_wrap.hh.

◆ set_stage()

void set_stage ( monarch_stage  a_stage)

Override the stage value.

Definition at line 640 of file monarch3_wrap.cc.

◆ start_using()

void start_using ( )

Make the wrapper available for use; starts parallel on-deck thread.

Definition at line 374 of file monarch3_wrap.cc.

◆ stop_using()

void stop_using ( )

Make the wrapper unavailable for use; stops the parallel on-deck thread.

Definition at line 477 of file monarch3_wrap.cc.

◆ switch_to_new_file()

void switch_to_new_file ( )

Switch to a new file that continues the first file. The filename is automatically determine from the original filename by appending an integer count of the number of continuation files. If file contributions are being recorded, this is done automatically when the maximum file size is exceeded.

Definition at line 579 of file monarch3_wrap.cc.

◆ trigger_switch()

void trigger_switch ( )

Definition at line 468 of file monarch3_wrap.cc.

Friends And Related Function Documentation

◆ monarch_on_deck_manager

friend class monarch_on_deck_manager
friend

Definition at line 207 of file monarch3_wrap.hh.

Member Data Documentation

◆ f_do_switch_flag

std::atomic< bool > f_do_switch_flag
private

Definition at line 224 of file monarch3_wrap.hh.

◆ f_do_switch_trig

std::condition_variable f_do_switch_trig
private

Definition at line 225 of file monarch3_wrap.hh.

◆ f_file_count

unsigned f_file_count
mutableprivate

Definition at line 217 of file monarch3_wrap.hh.

◆ f_file_size_est_mb

std::atomic< double > f_file_size_est_mb
private

Definition at line 220 of file monarch3_wrap.hh.

◆ f_filename_base

std::string f_filename_base
private

Definition at line 215 of file monarch3_wrap.hh.

◆ f_filename_ext

std::string f_filename_ext
private

Definition at line 216 of file monarch3_wrap.hh.

◆ f_header_wrap

header_wrap_ptr f_header_wrap
private

Definition at line 230 of file monarch3_wrap.hh.

◆ f_max_file_size_mb

double f_max_file_size_mb
private

Definition at line 219 of file monarch3_wrap.hh.

◆ f_monarch

std::shared_ptr< monarch3::Monarch3 > f_monarch
private

Definition at line 227 of file monarch3_wrap.hh.

◆ f_monarch_mutex

std::mutex f_monarch_mutex
mutableprivate

Definition at line 228 of file monarch3_wrap.hh.

◆ f_monarch_od_manager

monarch_on_deck_manager f_monarch_od_manager
private

Definition at line 239 of file monarch3_wrap.hh.

◆ f_od_thread

std::thread* f_od_thread
private

Definition at line 238 of file monarch3_wrap.hh.

◆ f_ok_to_write

std::atomic< bool > f_ok_to_write
private

Definition at line 223 of file monarch3_wrap.hh.

◆ f_orig_filename

std::string f_orig_filename
private

Definition at line 214 of file monarch3_wrap.hh.

◆ f_run_start_time

monarch_time_point_t f_run_start_time
private

Definition at line 234 of file monarch3_wrap.hh.

◆ f_stage

monarch_stage f_stage
private

Definition at line 236 of file monarch3_wrap.hh.

◆ f_stream_wraps

std::map< unsigned, stream_wrap_ptr > f_stream_wraps
private

Definition at line 232 of file monarch3_wrap.hh.

◆ f_switch_thread

std::thread* f_switch_thread
private

Definition at line 222 of file monarch3_wrap.hh.

◆ f_wait_to_write

std::condition_variable f_wait_to_write
private

Definition at line 221 of file monarch3_wrap.hh.


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