TINC
Toolkit for Interactive Computation
tinc::DiskBufferAbstract Class Referenceabstract

Base pure virtual class that defines the DiskBuffer interface. More...

#include <DiskBufferAbstract.hpp>

Inheritance diagram for tinc::DiskBufferAbstract:
tinc::IdObject tinc::DiskBuffer< NetCDFData > tinc::DiskBuffer< std::string > tinc::DiskBuffer< al::Image > tinc::DiskBuffer< nlohmann::json > tinc::DiskBuffer< DataType > tinc::DiskBufferNetCDFData tinc::DiskBufferText tinc::DiskBufferImage tinc::DiskBufferJson

Public Member Functions

std::string getCurrentFileName ()
 getCurrentFileName More...
 
virtual bool loadData (std::string filename, bool notify=true)=0
 Update buffer from file. More...
 
std::string getBaseFileName ()
 
void setBaseFileName (std::string name)
 
void setRelativePath (std::string path)
 
std::string getRelativePath ()
 
void setRootPath (std::string path)
 
std::string getRootPath ()
 
std::string getFullPath ()
 
void cleanupRoundRobinFiles ()
 
void enableRoundRobin (int cacheSize=0, bool clearLocks=true)
 
void useFileLock (bool use=true, bool clearLocks=true)
 
std::string getFilenameForWriting ()
 
void registerUpdateCallback (std::function< void(bool)> cb)
 register a function to be called when this object generates new buffer data More...
 
void registerNotifyCallback (std::function< void(bool)> cb)
 register a function to be called when this object generates new buffer data More...
 
std::string getId ()
 get this object's id More...
 
void setId (std::string id)
 set this object's id More...
 
std::string getDocumentation () const
 
void setDocumentation (const std::string &documentation)
 

Public Attributes

std::function< void(al::Socket *src)> modified = [](al::Socket * ) {}
 

Protected Member Functions

std::string makeNextFileName ()
 
std::string makeFileName (uint64_t index)
 

Protected Attributes

std::string m_fileName
 
DistributedPath m_distPath
 
std::shared_ptr< al::ParameterString > m_trigger
 
std::mutex m_writeLock
 
uint64_t m_roundRobinCounter {0}
 
uint64_t m_roundRobinSize {0}
 
std::vector< std::function< void(bool)> > mUpdateCallbacks
 
std::vector< std::function< void(bool)> > mNotifyCallbacks
 
std::string mId
 
std::string mDocumentation
 

Detailed Description

Base pure virtual class that defines the DiskBuffer interface.

This class defines the interface to the filesystem for disk buffers

Definition at line 51 of file DiskBufferAbstract.hpp.

Member Function Documentation

◆ cleanupRoundRobinFiles()

void tinc::DiskBufferAbstract::cleanupRoundRobinFiles ( )
inline

Definition at line 87 of file DiskBufferAbstract.hpp.

◆ enableRoundRobin()

void tinc::DiskBufferAbstract::enableRoundRobin ( int  cacheSize = 0,
bool  clearLocks = true 
)
inline

Definition at line 88 of file DiskBufferAbstract.hpp.

◆ getBaseFileName()

std::string tinc::DiskBufferAbstract::getBaseFileName ( )
inline

Definition at line 75 of file DiskBufferAbstract.hpp.

◆ getCurrentFileName()

std::string tinc::DiskBufferAbstract::getCurrentFileName ( )
inline

getCurrentFileName

Returns

This function is not thread safe. Needs to be called synchronously to any process functions

Definition at line 60 of file DiskBufferAbstract.hpp.

◆ getDocumentation()

std::string tinc::IdObject::getDocumentation ( ) const
inherited

◆ getFilenameForWriting()

std::string tinc::DiskBufferAbstract::getFilenameForWriting ( )
inline

Definition at line 96 of file DiskBufferAbstract.hpp.

◆ getFullPath()

std::string tinc::DiskBufferAbstract::getFullPath ( )
inline

Definition at line 84 of file DiskBufferAbstract.hpp.

◆ getId()

std::string tinc::IdObject::getId ( )
inherited

get this object's id

◆ getRelativePath()

std::string tinc::DiskBufferAbstract::getRelativePath ( )
inline

Definition at line 79 of file DiskBufferAbstract.hpp.

◆ getRootPath()

std::string tinc::DiskBufferAbstract::getRootPath ( )
inline

Definition at line 82 of file DiskBufferAbstract.hpp.

◆ loadData()

virtual bool tinc::DiskBufferAbstract::loadData ( std::string  filename,
bool  notify = true 
)
pure virtual

Update buffer from file.

Parameters
filename
notifyif true, the notification callbacks are called
Returns
true if succesfully loaded file

You should normally call this function without setting the notify argument.

Implemented in tinc::DiskBuffer< DataType >, tinc::DiskBuffer< NetCDFData >, tinc::DiskBuffer< std::string >, tinc::DiskBuffer< al::Image >, and tinc::DiskBuffer< nlohmann::json >.

◆ makeFileName()

std::string tinc::DiskBufferAbstract::makeFileName ( uint64_t  index)
inlineprotected

Definition at line 156 of file DiskBufferAbstract.hpp.

◆ makeNextFileName()

std::string tinc::DiskBufferAbstract::makeNextFileName ( )
inlineprotected

Definition at line 144 of file DiskBufferAbstract.hpp.

◆ registerNotifyCallback()

void tinc::DiskBufferAbstract::registerNotifyCallback ( std::function< void(bool)>  cb)
inline

register a function to be called when this object generates new buffer data

Parameters
cbIf this object is registered with a TINC server or client, this function will only be called if the data creation is local to the node.

When defining loadData(), these callbacks should only be called accodring to the notify argument.

Definition at line 125 of file DiskBufferAbstract.hpp.

◆ registerUpdateCallback()

void tinc::DiskBufferAbstract::registerUpdateCallback ( std::function< void(bool)>  cb)
inline

register a function to be called when this object generates new buffer data

Parameters
cbIf this object is registered with a TINC server or client, this function will only be called if the data creation is local to the node.

Definition at line 110 of file DiskBufferAbstract.hpp.

◆ setBaseFileName()

void tinc::DiskBufferAbstract::setBaseFileName ( std::string  name)
inline

Definition at line 76 of file DiskBufferAbstract.hpp.

◆ setDocumentation()

void tinc::IdObject::setDocumentation ( const std::string &  documentation)
inherited

◆ setId()

void tinc::IdObject::setId ( std::string  id)
inherited

set this object's id

◆ setRelativePath()

void tinc::DiskBufferAbstract::setRelativePath ( std::string  path)
inline

Definition at line 78 of file DiskBufferAbstract.hpp.

◆ setRootPath()

void tinc::DiskBufferAbstract::setRootPath ( std::string  path)
inline

Definition at line 81 of file DiskBufferAbstract.hpp.

◆ useFileLock()

void tinc::DiskBufferAbstract::useFileLock ( bool  use = true,
bool  clearLocks = true 
)
inline

Definition at line 92 of file DiskBufferAbstract.hpp.

Member Data Documentation

◆ m_distPath

DistributedPath tinc::DiskBufferAbstract::m_distPath
protected

Definition at line 132 of file DiskBufferAbstract.hpp.

◆ m_fileName

std::string tinc::DiskBufferAbstract::m_fileName
protected

Definition at line 130 of file DiskBufferAbstract.hpp.

◆ m_roundRobinCounter

uint64_t tinc::DiskBufferAbstract::m_roundRobinCounter {0}
protected

Definition at line 138 of file DiskBufferAbstract.hpp.

◆ m_roundRobinSize

uint64_t tinc::DiskBufferAbstract::m_roundRobinSize {0}
protected

Definition at line 139 of file DiskBufferAbstract.hpp.

◆ m_trigger

std::shared_ptr<al::ParameterString> tinc::DiskBufferAbstract::m_trigger
protected

Definition at line 134 of file DiskBufferAbstract.hpp.

◆ m_writeLock

std::mutex tinc::DiskBufferAbstract::m_writeLock
protected

Definition at line 136 of file DiskBufferAbstract.hpp.

◆ mDocumentation

std::string tinc::IdObject::mDocumentation
protectedinherited

Definition at line 69 of file IdObject.hpp.

◆ mId

std::string tinc::IdObject::mId
protectedinherited

Definition at line 68 of file IdObject.hpp.

◆ mNotifyCallbacks

std::vector<std::function<void(bool)> > tinc::DiskBufferAbstract::mNotifyCallbacks
protected

Definition at line 142 of file DiskBufferAbstract.hpp.

◆ modified

std::function<void(al::Socket *src)> tinc::IdObject::modified = [](al::Socket * ) {}
inherited

Definition at line 65 of file IdObject.hpp.

◆ mUpdateCallbacks

std::vector<std::function<void(bool)> > tinc::DiskBufferAbstract::mUpdateCallbacks
protected

Definition at line 141 of file DiskBufferAbstract.hpp.


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