HOPS
HOPS class reference
Public Member Functions | List of all members
hops::MHO_BinaryFileInterface Class Reference

Class MHO_BinaryFileInterface. More...

#include <MHO_BinaryFileInterface.hh>

Public Member Functions

 MHO_BinaryFileInterface ()
 
virtual ~MHO_BinaryFileInterface ()
 
void Close ()
 Closes file and key/index streamers if open. More...
 
bool ExtractFileObjectKeys (const std::string &filename, std::vector< MHO_FileKey > &keys)
 reads an object file and extracts the object file keys while skipping over the object data (cannot be actively streaming to another open file when called) More...
 
bool ExtractFileObjectKeysAndOffsets (const std::string &filename, std::vector< MHO_FileKey > &keys, std::vector< std::size_t > &byte_offsets)
 pulls out the object keys and the bytes offsets to the key entry of each object from the start of the file (skipping over object data) More...
 
bool ExtractIndexFileObjectKeys (const std::string &index_filename, std::vector< MHO_FileKey > &keys)
 reads an index file and extracts the object file keys (cannot be actively streaming to another open file when called) More...
 
bool IsOpenForRead ()
 Checks if the object streamer is open for reading. More...
 
bool IsOpenForWrite ()
 Checks if both object and key streamers are open for writing when fCollectKeys is true, otherwise checks only the object streamer. More...
 
bool OpenToAppend (const std::string &obj_filename, const std::string &index_filename="")
 Opens a file for appending objects and optionally streams keys to an index file. More...
 
bool OpenToRead (const std::string &filename)
 Opens a file for reading and checks if it's open. More...
 
bool OpenToReadAtOffset (const std::string &filename, uint64_t offset_bytes)
 Opens a file for reading at a specified byte offset. More...
 
bool OpenToWrite (const std::string &obj_filename, const std::string &index_filename="")
 Opens a file for writing and optionally opens an index file if provided. More...
 
template<class XReadType >
bool Read (XReadType &obj, MHO_FileKey &obj_key)
 Reads the object (XReadType) specified by the object file key from the file. More...
 
template<class XWriteType >
bool Write (const XWriteType &obj, const char *shortname)
 Writes an object (must inherit from MHO_Serializable) to a file (with optional shortname string - overloaded for char array name). Checks if both object and key streamers are open for write if fCollectKeys is true, otherwise checks only object streamer. More...
 
template<class XWriteType >
bool Write (const XWriteType &obj, const std::string &shortname="")
 Writes an object (must inherit from MHO_Serializable) to a file (with optional shortname string). Checks if both object and key streamers are open for write if fCollectKeys is true, otherwise checks only object streamer. More...
 

Detailed Description

Class MHO_BinaryFileInterface.

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Wed Apr 21 13:40:18 2021 -0400

Constructor & Destructor Documentation

◆ MHO_BinaryFileInterface()

hops::MHO_BinaryFileInterface::MHO_BinaryFileInterface ( )
inline

◆ ~MHO_BinaryFileInterface()

virtual hops::MHO_BinaryFileInterface::~MHO_BinaryFileInterface ( )
inlinevirtual

Member Function Documentation

◆ Close()

void hops::MHO_BinaryFileInterface::Close ( )
inline

Closes file and key/index streamers if open.

◆ ExtractFileObjectKeys()

bool hops::MHO_BinaryFileInterface::ExtractFileObjectKeys ( const std::string &  filename,
std::vector< MHO_FileKey > &  keys 
)
inline

reads an object file and extracts the object file keys while skipping over the object data (cannot be actively streaming to another open file when called)

Parameters
filename(const std::string&)
keys(std::vector< MHO_FileKey >&)
Returns
Return value (bool)

◆ ExtractFileObjectKeysAndOffsets()

bool hops::MHO_BinaryFileInterface::ExtractFileObjectKeysAndOffsets ( const std::string &  filename,
std::vector< MHO_FileKey > &  keys,
std::vector< std::size_t > &  byte_offsets 
)
inline

pulls out the object keys and the bytes offsets to the key entry of each object from the start of the file (skipping over object data)

Parameters
filename(const std::string&)
keys(std::vector< MHO_FileKey >&)
byte_offsets(std::vector< std::size_t >&)
Returns
Return value (bool)

◆ ExtractIndexFileObjectKeys()

bool hops::MHO_BinaryFileInterface::ExtractIndexFileObjectKeys ( const std::string &  index_filename,
std::vector< MHO_FileKey > &  keys 
)
inline

reads an index file and extracts the object file keys (cannot be actively streaming to another open file when called)

Parameters
index_filename(const std::string&)
keys(std::vector< MHO_FileKey >&)
Returns
Return value (bool)

◆ IsOpenForRead()

bool hops::MHO_BinaryFileInterface::IsOpenForRead ( )
inline

Checks if the object streamer is open for reading.

Returns
True if open for read, false otherwise.

◆ IsOpenForWrite()

bool hops::MHO_BinaryFileInterface::IsOpenForWrite ( )
inline

Checks if both object and key streamers are open for writing when fCollectKeys is true, otherwise checks only the object streamer.

Returns
True if both streamers are open (when fCollectKeys is true), or if the object streamer is open; false otherwise.

◆ OpenToAppend()

bool hops::MHO_BinaryFileInterface::OpenToAppend ( const std::string &  obj_filename,
const std::string &  index_filename = "" 
)
inline

Opens a file for appending objects and optionally streams keys to an index file.

Parameters
obj_filenameFilename of the object file to open for appending
index_filenameOptional filename of the index file for streaming keys
Returns
True if both object and key files are opened successfully, false otherwise

◆ OpenToRead()

bool hops::MHO_BinaryFileInterface::OpenToRead ( const std::string &  filename)
inline

Opens a file for reading and checks if it's open.

Parameters
filenameThe name of the file to be opened for reading.
Returns
True if the file is successfully opened for reading, false otherwise.

◆ OpenToReadAtOffset()

bool hops::MHO_BinaryFileInterface::OpenToReadAtOffset ( const std::string &  filename,
uint64_t  offset_bytes 
)
inline

Opens a file for reading at a specified byte offset.

Parameters
filenameThe name of the file to open and read from.
offset_bytes(uint64_t)
Returns
True if the file was successfully opened for reading at the specified offset, false otherwise.

◆ OpenToWrite()

bool hops::MHO_BinaryFileInterface::OpenToWrite ( const std::string &  obj_filename,
const std::string &  index_filename = "" 
)
inline

Opens a file for writing and optionally opens an index file if provided.

Parameters
obj_filenameThe filename to write object data to.
index_filenameOptional filename to write key/index data to.
Returns
True if both files are opened successfully, false otherwise.

◆ Read()

template<class XReadType >
bool hops::MHO_BinaryFileInterface::Read ( XReadType &  obj,
MHO_FileKey obj_key 
)
inline

Reads the object (XReadType) specified by the object file key from the file.

Parameters
objreference to the object to be filled with data (XReadType&)
theFile key which points to the object to be read
Returns
True if file is open for read, false otherwise

◆ Write() [1/2]

template<class XWriteType >
bool hops::MHO_BinaryFileInterface::Write ( const XWriteType &  obj,
const char *  shortname 
)
inline

Writes an object (must inherit from MHO_Serializable) to a file (with optional shortname string - overloaded for char array name). Checks if both object and key streamers are open for write if fCollectKeys is true, otherwise checks only object streamer.

Parameters
theobject to be written of type (const XWriteType &)
shortname- optional discriptive char array (C-string)
Returns
Boolean indicating whether writing was successful or not

◆ Write() [2/2]

template<class XWriteType >
bool hops::MHO_BinaryFileInterface::Write ( const XWriteType &  obj,
const std::string &  shortname = "" 
)
inline

Writes an object (must inherit from MHO_Serializable) to a file (with optional shortname string). Checks if both object and key streamers are open for write if fCollectKeys is true, otherwise checks only object streamer.

Parameters
theobject to be written of type (const XWriteType &)
shortname- optional discriptive string
Returns
Boolean indicating whether writing was successful or not

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