API 4.4.1-2022-10-19-2c4045e59
For MATLAB, Python, Java, and C++ users
OpenSim::FileAdapter Class Reference

FileAdapter is a DataAdapter that reads and writes files with methods read and writeFile respectively. More...

+ Inheritance diagram for OpenSim::FileAdapter:

Public Member Functions

 FileAdapter ()=default
 
 FileAdapter (const FileAdapter &)=default
 
 FileAdapter (FileAdapter &&)=default
 
FileAdapteroperator= (const FileAdapter &)=default
 
FileAdapteroperator= (FileAdapter &&)=default
 
virtual ~FileAdapter ()=default
 
- Public Member Functions inherited from OpenSim::DataAdapter
virtual DataAdapterclone () const =0
 
 DataAdapter ()=default
 
 DataAdapter (const DataAdapter &)=default
 
 DataAdapter (DataAdapter &&)=default
 
DataAdapteroperator= (const DataAdapter &)=default
 
DataAdapteroperator= (DataAdapter &&)=default
 
virtual ~DataAdapter ()=default
 
DataAdapter::OutputTables read (const std::string &dataSourceSpecification) const
 Public interface to read data from a dataSourceSpecification, typically a file or folder. More...
 
const std::shared_ptr< AbstractDataTablegetDataTable (const OutputTables &tables, const std::string tableName)
 Generic interface to retrieve a specific table by name from read result. More...
 

Static Public Member Functions

static void writeFile (const InputTables &tables, const std::string &fileName)
 Write a collection of tables to the given file. More...
 
static std::string findExtension (const std::string &filename)
 Find the extension from a filename. More...
 
static std::vector< std::string > getNextLine (std::istream &stream, const std::string &delims)
 Get the next line from the stream and tokenize/split the line using the given delimiters. More...
 
static std::vector< std::string > tokenize (const std::string &str, const std::string &delims)
 Tokenize/split a given string using the given delimiters. More...
 
static std::shared_ptr< DataAdaptercreateAdapterFromExtension (const std::string &fileName)
 Create a concerte FileAdapter based on the extension of the passed in file and return it. More...
 
- Static Public Member Functions inherited from OpenSim::DataAdapter
static bool registerDataAdapter (const std::string &identifier, const DataAdapter &adapter)
 Register a concrete DataAdapter by its unique string identifier. More...
 

Detailed Description

FileAdapter is a DataAdapter that reads and writes files with methods read and writeFile respectively.

The read method is implemented in the base class and it calls the virtual extendRead method implemented by format specific subclasses. Typically you don't need to call read explicitly if reading one DataTable from file, instead use a constructor of the table from the specific file. e.g.

TimeSeriesTableVec3 table(filename);
TimeSeriesTable_< SimTK::Vec3 > TimeSeriesTableVec3
See TimeSeriesTable_ for details on the interface.
Definition: TimeSeriesTable.h:522

Constructor & Destructor Documentation

◆ FileAdapter() [1/3]

OpenSim::FileAdapter::FileAdapter ( )
default

◆ FileAdapter() [2/3]

OpenSim::FileAdapter::FileAdapter ( const FileAdapter )
default

◆ FileAdapter() [3/3]

OpenSim::FileAdapter::FileAdapter ( FileAdapter &&  )
default

◆ ~FileAdapter()

virtual OpenSim::FileAdapter::~FileAdapter ( )
virtualdefault

Member Function Documentation

◆ createAdapterFromExtension()

static std::shared_ptr< DataAdapter > OpenSim::FileAdapter::createAdapterFromExtension ( const std::string &  fileName)
static

Create a concerte FileAdapter based on the extension of the passed in file and return it.

This serves as a Factory of FileAdapters so clients don't need to know specific concrete subclasses, as long as the generic base class read interface is used

Referenced by OpenSim::DataTable_< ETX, ETY >::DataTable_(), and OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_().

◆ findExtension()

static std::string OpenSim::FileAdapter::findExtension ( const std::string &  filename)
static

Find the extension from a filename.


◆ getNextLine()

static std::vector< std::string > OpenSim::FileAdapter::getNextLine ( std::istream &  stream,
const std::string &  delims 
)
static

Get the next line from the stream and tokenize/split the line using the given delimiters.


◆ operator=() [1/2]

FileAdapter & OpenSim::FileAdapter::operator= ( const FileAdapter )
default

◆ operator=() [2/2]

FileAdapter & OpenSim::FileAdapter::operator= ( FileAdapter &&  )
default

◆ tokenize()

static std::vector< std::string > OpenSim::FileAdapter::tokenize ( const std::string &  str,
const std::string &  delims 
)
static

Tokenize/split a given string using the given delimiters.

The delimiters are each required to be one character and the string is split if/when any of those characters are found. For example, a delimiter string " \t" specifies that either a space or a tab can act as the delimiter.

◆ writeFile()

static void OpenSim::FileAdapter::writeFile ( const InputTables tables,
const std::string &  fileName 
)
static

Write a collection of tables to the given file.

Different file formats require different number/type of tables. See specific adapter's documentation to see what is required.


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