API  4.5.1
For C++ developers
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...
 

Additional Inherited Members

- Public Types inherited from OpenSim::DataAdapter
typedef std::map< std::string, std::shared_ptr< DataAdapter > > RegisteredDataAdapters
 Type of the registry containing registered adapters. More...
 
typedef std::map< std::string, std::shared_ptr< AbstractDataTable > > OutputTables
 Collection of tables returned by reading methods implemented in derived classes. More...
 
typedef std::map< std::string, const AbstractDataTable * > InputTables
 Collection of tables accepted by writing methods implemented in derived classes. More...
 
- Protected Member Functions inherited from OpenSim::DataAdapter
virtual OutputTables extendRead (const std::string &sourceName) const =0
 Implements reading functionality. More...
 
virtual void extendWrite (const InputTables &tables, const std::string &sinkName) const =0
 Implements writing functionality. More...
 
- Static Protected Member Functions inherited from OpenSim::DataAdapter
static std::shared_ptr< DataAdaptercreateAdapter (const std::string &identifier)
 Creator of concrete DataAdapter(s) for the specified source type by its unique identifier (string). 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);

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_< double, SimTK::Real >::DataTable_(), and OpenSim::TimeSeriesTable_< SimTK::Vec3 >::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: