riCOM_cpp
This repository contains the C++ implementation of the riCOM (Real Time Centre Of Mass) algorithm for 4D Scanning electron microscopy.
Public Member Functions | Public Attributes | List of all members
FileConnector Class Reference

#include <FileConnector.h>

Public Member Functions

void open_file ()
 
void close_file ()
 
void read_data (char *buffer, size_t data_size)
 
 FileConnector ()
 

Public Attributes

std::filesystem::path path
 

Detailed Description

Definition at line 23 of file FileConnector.h.

Constructor & Destructor Documentation

◆ FileConnector()

FileConnector::FileConnector ( )

Definition at line 65 of file FileConnector.cpp.

65 : path(), stream(), file_size(0), pos(0) {}
std::filesystem::path path
Definition: FileConnector.h:26

Member Function Documentation

◆ close_file()

void FileConnector::close_file ( )

Definition at line 37 of file FileConnector.cpp.

38 {
39  if (stream.is_open())
40  {
41  stream.close();
42  }
43 }

◆ open_file()

void FileConnector::open_file ( )

Definition at line 16 of file FileConnector.cpp.

17 {
18  if (!path.empty())
19  {
20  file_size = std::filesystem::file_size(path);
21  stream.open(path, std::ios::in | std::ios::binary);
22  if (stream.is_open())
23  {
24  reset_file();
25  }
26  else
27  {
28  std::cout << "FileConnector::open_file(): Error opening file!" << std::endl;
29  }
30  }
31  else
32  {
33  std::cout << "FileConnector::open_file(): Path argument is empty!" << std::endl;
34  }
35 }

◆ read_data()

void FileConnector::read_data ( char *  buffer,
size_t  data_size 
)

Definition at line 46 of file FileConnector.cpp.

47 {
48  stream.read(buffer, data_size);
49 
50  pos += data_size;
51  // Reset file to the beginning for repeat reading
52  if (file_size - pos < data_size)
53  {
54  reset_file();
55  }
56 };

Member Data Documentation

◆ path

std::filesystem::path FileConnector::path

Definition at line 26 of file FileConnector.h.


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