MADARA  3.4.1
madara::knowledge::FileStreamer Class Reference

Splits files into fragments that can be saved to and loaded from a knowledge base. More...

#include <FileStreamer.h>

Public Member Functions

 FileStreamer ()
 Constructor. More...
 
 FileStreamer (const std::string &key, const std::string &filename, KnowledgeBase kb)
 Constructor. More...
 
void clear_fragments (void)
 Clears the fragment list. More...
 
uint32_t get_crc (void)
 Returns the crc of the file. More...
 
std::string get_filename (void)
 Returns the name of the file. More...
 
size_t get_size (void)
 Returns the size of the file. More...
 
void init (const std::string &key, const std::string &filename, KnowledgeBase kb)
 Initializes the file stream and all containers. More...
 
size_t load (size_t index, size_t frag_size=60000)
 Loads a fragment into the knowledge base. More...
 
void modify (void)
 Remodifies the file size and crc. More...
 

Public Attributes

containers::Integer file_crc
 the crc of the file More...
 
containers::Map file_fragments
 the crc of the file More...
 
containers::Integer file_size
 the size of the file contents More...
 
containers::FlexMap file_space
 records that contain the file fragments More...
 

Private Attributes

std::string filename_
 the name of the file More...
 
std::ifstream stream_
 the stream to read from More...
 

Detailed Description

Splits files into fragments that can be saved to and loaded from a knowledge base.

Definition at line 23 of file FileStreamer.h.

Constructor & Destructor Documentation

◆ FileStreamer() [1/2]

madara::knowledge::FileStreamer::FileStreamer ( )
inline

Constructor.

Definition at line 29 of file FileStreamer.h.

◆ FileStreamer() [2/2]

madara::knowledge::FileStreamer::FileStreamer ( const std::string &  key,
const std::string &  filename,
KnowledgeBase  kb 
)
inline

Constructor.

Parameters
keythe location in the knowledge base to save to
filenamethe file to open and read from
kbthe knowledge base to stream to

Definition at line 37 of file FileStreamer.h.

Member Function Documentation

◆ clear_fragments()

void madara::knowledge::FileStreamer::clear_fragments ( void  )
inline

Clears the fragment list.

Definition at line 130 of file FileStreamer.h.

◆ get_crc()

uint32_t madara::knowledge::FileStreamer::get_crc ( void  )
inline

Returns the crc of the file.

Returns
the crc of the file

Definition at line 104 of file FileStreamer.h.

◆ get_filename()

std::string madara::knowledge::FileStreamer::get_filename ( void  )
inline

Returns the name of the file.

Returns
the name of the file being streamed

Definition at line 122 of file FileStreamer.h.

◆ get_size()

size_t madara::knowledge::FileStreamer::get_size ( void  )
inline

Returns the size of the file.

Returns
the size of the file

Definition at line 113 of file FileStreamer.h.

◆ init()

void madara::knowledge::FileStreamer::init ( const std::string &  key,
const std::string &  filename,
KnowledgeBase  kb 
)
inline

Initializes the file stream and all containers.

Parameters
keythe location in the knowledge base to save to
filenamethe file to open and read from
kbthe knowledge base to stream to

Definition at line 49 of file FileStreamer.h.

◆ load()

size_t madara::knowledge::FileStreamer::load ( size_t  index,
size_t  frag_size = 60000 
)
inline

Loads a fragment into the knowledge base.

Definition at line 73 of file FileStreamer.h.

◆ modify()

void madara::knowledge::FileStreamer::modify ( void  )
inline

Remodifies the file size and crc.

Definition at line 138 of file FileStreamer.h.

Member Data Documentation

◆ file_crc

containers::Integer madara::knowledge::FileStreamer::file_crc

the crc of the file

Definition at line 151 of file FileStreamer.h.

◆ file_fragments

containers::Map madara::knowledge::FileStreamer::file_fragments

the crc of the file

Definition at line 154 of file FileStreamer.h.

◆ file_size

containers::Integer madara::knowledge::FileStreamer::file_size

the size of the file contents

Definition at line 148 of file FileStreamer.h.

◆ file_space

containers::FlexMap madara::knowledge::FileStreamer::file_space

records that contain the file fragments

Definition at line 145 of file FileStreamer.h.

◆ filename_

std::string madara::knowledge::FileStreamer::filename_
private

the name of the file

Definition at line 158 of file FileStreamer.h.

◆ stream_

std::ifstream madara::knowledge::FileStreamer::stream_
private

the stream to read from

Definition at line 161 of file FileStreamer.h.


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