TINC
Toolkit for Interactive Computation
tinc::DataPoolJson Class Reference

A DataPool class to read Json files. More...

#include <DataPoolJson.hpp>

Inheritance diagram for tinc::DataPoolJson:
tinc::DataPool tinc::IdObject

Public Member Functions

 DataPoolJson (std::string id, ParameterSpace &ps, std::string sliceCacheDir=std::string())
 
 DataPoolJson (ParameterSpace &ps, std::string sliceCacheDir=std::string())
 
void registerDataFile (std::string filename, std::string dimensionInFile)
 registerDataFile More...
 
std::map< std::string, std::string > getRegisteredDataFiles ()
 get registered data files More...
 
void clearRegisteredFiles ()
 Clear list of registered data files. More...
 
ParameterSpacegetParameterSpace ()
 Get parameter space that controls this data pool. More...
 
std::string createDataSlice (std::string field, std::string sliceDimension)
 Extract a slice of data. More...
 
std::string createDataSlice (std::string field, std::vector< std::string > sliceDimensions)
 Extract a slice of data. More...
 
std::vector< std::string > getCurrentFiles ()
 get list of full path to current files in datapool More...
 
size_t readDataSlice (std::string field, std::string sliceDimension, void *data, size_t maxLen)
 readDataSlice More...
 
std::string getCacheDirectory ()
 Get directory for data slices. More...
 
void setCacheDirectory (std::string cacheDirectory, al::Socket *src=nullptr)
 set directory to be used to store slices More...
 
std::vector< std::string > listFields (bool verifyConsistency=false)
 list fields in datapool More...
 
const DataPoolType getType ()
 type of the data pool. Set on constructor, can't change. 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< std::vector< std::string >std::vector< std::string >)> getAllPaths
 
std::function< void(al::Socket *src)> modified = [](al::Socket * ) {}
 

Protected Member Functions

std::vector< std::string > listFieldInFile (std::string file) override
 
bool getFieldFromFile (std::string field, std::string file, size_t dimensionInFileIndex, void *data) override
 
bool getFieldFromFile (std::string field, std::string file, void *data, size_t length) override
 
std::string getFileType (std::string file)
 

Protected Attributes

DataPoolType mType {DataPoolType::DATAPOOL_USER}
 
std::string mId
 
std::string mDocumentation
 

Detailed Description

A DataPool class to read Json files.

Definition at line 43 of file DataPoolJson.hpp.

Constructor & Destructor Documentation

◆ DataPoolJson() [1/2]

tinc::DataPoolJson::DataPoolJson ( std::string  id,
ParameterSpace ps,
std::string  sliceCacheDir = std::string() 
)
inline

Definition at line 45 of file DataPoolJson.hpp.

◆ DataPoolJson() [2/2]

tinc::DataPoolJson::DataPoolJson ( ParameterSpace ps,
std::string  sliceCacheDir = std::string() 
)
inline

Definition at line 51 of file DataPoolJson.hpp.

Member Function Documentation

◆ clearRegisteredFiles()

void tinc::DataPool::clearRegisteredFiles ( )
inherited

Clear list of registered data files.

◆ createDataSlice() [1/2]

std::string tinc::DataPool::createDataSlice ( std::string  field,
std::string  sliceDimension 
)
inherited

Extract a slice of data.

Parameters
fieldname of the field to extract
sliceDimensiondimension that can change across the slice
Returns
filename of the extracted slice

The slice will be created as a NetCDF4 file with a single variable called "data" that spans a dimension "values". The result will be a one dimensional slice containing the values of the "field" across all values for "sliceDimension" that must be registered in the parameter space.

◆ createDataSlice() [2/2]

std::string tinc::DataPool::createDataSlice ( std::string  field,
std::vector< std::string >  sliceDimensions 
)
inherited

Extract a slice of data.

Parameters
fieldname of the field to extract
sliceDimensionsdimensions that can change across the slice
Returns
filename of the extracted slice

The output is a multidimensional slice of the data for the "field" values. The number of dimensions of the result is the size of sliceDimensions

◆ getCacheDirectory()

std::string tinc::DataPool::getCacheDirectory ( )
inlineinherited

Get directory for data slices.

Returns
cache directory

Definition at line 142 of file DataPool.hpp.

◆ getCurrentFiles()

std::vector<std::string> tinc::DataPool::getCurrentFiles ( )
inherited

get list of full path to current files in datapool

Returns
list of files

Both root path and current run path are prepended to the file names.

◆ getDocumentation()

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

◆ getFieldFromFile() [1/2]

bool tinc::DataPoolJson::getFieldFromFile ( std::string  field,
std::string  file,
size_t  dimensionInFileIndex,
void *  data 
)
overrideprotectedvirtual

Implements tinc::DataPool.

◆ getFieldFromFile() [2/2]

bool tinc::DataPoolJson::getFieldFromFile ( std::string  field,
std::string  file,
void *  data,
size_t  length 
)
overrideprotectedvirtual

Implements tinc::DataPool.

◆ getFileType()

std::string tinc::DataPool::getFileType ( std::string  file)
protectedinherited

◆ getId()

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

get this object's id

◆ getParameterSpace()

ParameterSpace& tinc::DataPool::getParameterSpace ( )
inlineinherited

Get parameter space that controls this data pool.

Returns
the parameter space

Definition at line 91 of file DataPool.hpp.

◆ getRegisteredDataFiles()

std::map<std::string, std::string> tinc::DataPool::getRegisteredDataFiles ( )
inherited

get registered data files

Returns
key is the filename and vlaue is the name of the dimension that file contains

The dimension name in the output names the dimension whose changes have produced the values in the fields in the file

◆ getType()

const DataPoolType tinc::DataPool::getType ( )
inlineinherited

type of the data pool. Set on constructor, can't change.

Definition at line 171 of file DataPool.hpp.

◆ listFieldInFile()

std::vector<std::string> tinc::DataPoolJson::listFieldInFile ( std::string  file)
overrideprotectedvirtual

Implements tinc::DataPool.

◆ listFields()

std::vector<std::string> tinc::DataPool::listFields ( bool  verifyConsistency = false)
inherited

list fields in datapool

Parameters
verifyConsistencyverify that all files in datapool are consistent
Returns
lis of field names

◆ readDataSlice()

size_t tinc::DataPool::readDataSlice ( std::string  field,
std::string  sliceDimension,
void *  data,
size_t  maxLen 
)
inherited

readDataSlice

Parameters
field
sliceDimensiondimension that can vary in the slice
data
maxLen
Returns
number of elements written to data pointer

◆ registerDataFile()

void tinc::DataPool::registerDataFile ( std::string  filename,
std::string  dimensionInFile 
)
inherited

registerDataFile

Parameters
filename
dimensionInFileThis filename must be relative to mParameterSpace->generateRelativeRunPath. It should be present in all data paths for the parameter space.

◆ setCacheDirectory()

void tinc::DataPool::setCacheDirectory ( std::string  cacheDirectory,
al::Socket *  src = nullptr 
)
inherited

set directory to be used to store slices

Parameters
cacheDirectory
srcsocket that originated this request (nullptr if local)

◆ setDocumentation()

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

◆ setId()

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

set this object's id

Member Data Documentation

◆ getAllPaths

std::function<std::vector<std::string>std::vector<std::string>)> tinc::DataPool::getAllPaths
inherited
Initial value:
= [&](std::vector<std::string> fixedDimensions =
std::vector<std::string>()) {
return mParameterSpace->runningPaths(fixedDimensions);
}
std::vector< std::string > runningPaths(std::vector< std::string > fixedDimensions=std::vector< std::string >())
Returns all the paths that are used by the whole parameter space.

Replace this function when the parameter space runningPaths() function is not adequate.

Definition at line 163 of file DataPool.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.

◆ modified

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

Definition at line 65 of file IdObject.hpp.

◆ mType

DataPoolType tinc::DataPool::mType {DataPoolType::DATAPOOL_USER}
protectedinherited

Definition at line 181 of file DataPool.hpp.


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