Developer documentation
Version 3.0.3-105-gd3941f44
MR::DWI::Tractography::ScalarWriter< T > Class Template Reference

class to handle writing track scalars to file More...

#include "dwi/tractography/scalar_file.h"

Inheritance diagram for MR::DWI::Tractography::ScalarWriter< T >:

Public Types

using value_type = T
 

Public Member Functions

 ScalarWriter (const std::string &file, const Properties &properties)
 
 ~ScalarWriter ()
 
bool operator() (const TrackScalar< T > &tck_scalar)
 

Protected Member Functions

void add_scalar (const value_type &s)
 
value_type delimiter () const
 
void format_scalar (const value_type &s, value_type &destination)
 
void commit ()
 
 ScalarWriter (const ScalarWriter &)=delete
 

Protected Attributes

const size_t buffer_capacity
 
std::unique_ptr< value_type[]> buffer
 
size_t buffer_size
 
int64_t current_offset
 

Detailed Description

template<typename T = float>
class MR::DWI::Tractography::ScalarWriter< T >

class to handle writing track scalars to file

writes track scalar file header as specified in properties and individual track scalars to the file specified in file. Writing individual scalars is done using the append() method.

This class implements a large write-back RAM buffer to hold the track scalar data in RAM, and only commits to file when the buffer capacity is reached. This minimises the number of write() calls, which can otherwise become a bottleneck on distributed or network filesystems. It also helps reduce file fragmentation when multiple processes write to file concurrently. The size of the write-back buffer defaults to 16MB, and can be set in the config file using the TrackWriterBufferSize field (in bytes).

Definition at line 167 of file scalar_file.h.

Member Typedef Documentation

◆ value_type

template<typename T = float>
using MR::DWI::Tractography::ScalarWriter< T >::value_type = T

Definition at line 170 of file scalar_file.h.

Constructor & Destructor Documentation

◆ ScalarWriter() [1/2]

template<typename T = float>
MR::DWI::Tractography::ScalarWriter< T >::ScalarWriter ( const std::string &  file,
const Properties properties 
)
inline

Definition at line 181 of file scalar_file.h.

◆ ~ScalarWriter()

template<typename T = float>
MR::DWI::Tractography::ScalarWriter< T >::~ScalarWriter ( )
inline

Definition at line 202 of file scalar_file.h.

◆ ScalarWriter() [2/2]

template<typename T = float>
MR::DWI::Tractography::ScalarWriter< T >::ScalarWriter ( const ScalarWriter< T > &  )
protecteddelete

Member Function Documentation

◆ add_scalar()

template<typename T = float>
void MR::DWI::Tractography::ScalarWriter< T >::add_scalar ( const value_type s)
inlineprotected

Definition at line 230 of file scalar_file.h.

◆ commit()

template<typename T = float>
void MR::DWI::Tractography::ScalarWriter< T >::commit ( )
inlineprotected

Definition at line 245 of file scalar_file.h.

◆ delimiter()

template<typename T = float>
value_type MR::DWI::Tractography::ScalarWriter< T >::delimiter ( ) const
inlineprotected

Definition at line 234 of file scalar_file.h.

◆ format_scalar()

template<typename T = float>
void MR::DWI::Tractography::ScalarWriter< T >::format_scalar ( const value_type s,
value_type destination 
)
inlineprotected

Definition at line 236 of file scalar_file.h.

◆ operator()()

template<typename T = float>
bool MR::DWI::Tractography::ScalarWriter< T >::operator() ( const TrackScalar< T > &  tck_scalar)
inline

Definition at line 207 of file scalar_file.h.

Member Data Documentation

◆ buffer

template<typename T = float>
std::unique_ptr<value_type[]> MR::DWI::Tractography::ScalarWriter< T >::buffer
protected

Definition at line 226 of file scalar_file.h.

◆ buffer_capacity

template<typename T = float>
const size_t MR::DWI::Tractography::ScalarWriter< T >::buffer_capacity
protected

Definition at line 225 of file scalar_file.h.

◆ buffer_size

template<typename T = float>
size_t MR::DWI::Tractography::ScalarWriter< T >::buffer_size
protected

Definition at line 227 of file scalar_file.h.

◆ current_offset

template<typename T = float>
int64_t MR::DWI::Tractography::ScalarWriter< T >::current_offset
protected

Definition at line 228 of file scalar_file.h.


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