BTK  0.3dev.0
Open-source library to visualize/process biomechanical data
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
btk::AcquisitionFileIO Class Referenceabstract

Interface to read/write acquisition's files. More...

#include <btkAcquisitionFileIO.h>

Inheritance diagram for btk::AcquisitionFileIO:
Inheritance graph
[legend]

Classes

class  Extension
 Native extension used with an acquisition file IO. More...
 
class  Extensions
 List of AcquisitionFileIO::Extension object. More...
 

Public Types

enum  ByteOrder { OrderNotApplicable = 0, IEEE_LittleEndian, VAX_LittleEndian, IEEE_BigEndian }
 
typedef btkSharedPtr< const
AcquisitionFileIO
ConstPointer
 
enum  FileType { TypeNotApplicable, ASCII, Binary }
 
enum  InternalsUpdateOption {
  UpdateNotApplicable = 0, NoUpdate = UpdateNotApplicable, DataBasedUpdate = 1, MetaDataBasedUpdate = 2,
  FileFormatOption = 512
}
 
typedef btkSharedPtr
< AcquisitionFileIO
Pointer
 
enum  StorageFormat { StorageNotApplicable = 0, Float = -1, Integer = 1 }
 

Public Member Functions

virtual bool CanReadFile (const std::string &filename)=0
 
virtual bool CanWriteFile (const std::string &filename)=0
 
ByteOrder GetByteOrder () const
 
std::string GetByteOrderAsString () const
 
FileType GetFileType () const
 
int GetInternalsUpdateOptions () const
 
StorageFormat GetStorageFormat () const
 
std::string GetStorageFormatAsString () const
 
virtual const ExtensionsGetSupportedExtensions () const =0
 
bool HasInternalsUpdateOption (int option) const
 
virtual void Read (const std::string &filename, Acquisition::Pointer output)=0
 
void SetByteOrder (ByteOrder b)
 
void SetInternalsUpdateOptions (int options)
 
void SetStorageFormat (StorageFormat s)
 
virtual void Write (const std::string &filename, Acquisition::Pointer input)=0
 

Static Public Member Functions

static bool HasReadOperation ()
 
static bool HasWriteOperation ()
 

Protected Member Functions

 AcquisitionFileIO (FileType f=TypeNotApplicable, ByteOrder b=OrderNotApplicable, StorageFormat s=StorageNotApplicable, int internalsUpdate=UpdateNotApplicable)
 
void SetFileType (FileType f)
 
virtual ~AcquisitionFileIO ()
 

Protected Attributes

ByteOrder m_ByteOrder
 
FileType m_FileType
 
int m_InternalsUpdate
 
StorageFormat m_StorageFormat
 

Detailed Description

Interface to read/write acquisition's files.

A class inheriting from AcquisitionFileIO has to implement 4 methods:

To help developers, some macros were defined in case:

These macros should be used at the top of the declaration of the new class. For example:

* class FooFileIO : public AcquisitionFileIO
* {
* BTK_FILE_IO_ONLY_READ_OPERATION;
* BTK_FILE_IO_SUPPORTED_EXTENSIONS("FOO");
* public:
* // ...
* virtual bool CanReadFile(const std::string& filename);
* virtual void Read(const std::string& filename, Acquisition::Pointer output);
* // ...
* };
*

In this example, the FooFileIO class can only read files, and the default file extension known is "FOO".

Note
Check the class AcquisitionFileIO::Extension to add more than one default extension.

After the implementation of the new IO, you can decide to add it to the factory (using the method AcquisitionFileIOFactory::AddFileIO). This will give the possibility to select the new IO automatically based on the return value of the method CanReadFile() or CanWriteFile().

For inheriting classes which implement the Write() method, it is possible to select the way the internal configuration (if any) is updated based on the acquisiton input. By default, the internal member m_InternalsUpdate is set to AcquisitionFileIO::UpdateNotApplicable. Two other choices are proposed to update the internal: based on data (points, analog channels, events) (AcquisitionFileIO::DataBasedUpdate) or based on metadata (AcquisitionFileIO::MetaDataBasedUpdate). These options are only informative and it is up to each file format to use this information of not. It is also possible to extend the options used to update each file format internals by using the enum value AcquisitionFileIO::FileFormatOption. For example, the C3D file format has an option (C3DFileIO::CompatibleVicon = AcquisitionFileIO::FileFormatOption) to keep generated file compatible with the software Polygon (Vicon, version 3.5) which crash if some parameters' description is empty.

Note
The methods to set the file type, the byte order or the storage format are in general not used as lots of file format doesn't have options for these properties. Only the C3D file format is known to have some options each time.

Member Typedef Documentation

Smart pointer associated with a const AcquisitionFileIO object.

Smart pointer associated with an AcquisitionFileIO object.

Member Enumeration Documentation

Enums used to specify the byte order of the file (integer and float).

Enumerator
OrderNotApplicable 

Enum value used to indicate the byte order is not yet known.

IEEE_LittleEndian 

Enum value for a byte order in little endian with a IEEE float representation.

VAX_LittleEndian 

Enum value for a byte order in little endian with a VAX float representation.

IEEE_BigEndian 

Enum value for a byte order in big endian with a IEEE float representation.

Enums used to specify the type of the file.

Enumerator
TypeNotApplicable 

Enum value used to indicate the type of the file is not yet known.

ASCII 

Enum value for ASCII file.

Binary 

Enum value for binary file.

Enums used to specify the update of the internal configuration of a file format (if any)

Enumerator
UpdateNotApplicable 

No update is done and existing internals are used.

NoUpdate 

Same as AcquisitionFileIO::UpdateNotApplicable.

DataBasedUpdate 

Internals are updated using acquisition data (points, analog channels, events).

MetaDataBasedUpdate 

Internals are updated using acquisition metadata.

FileFormatOption 

Extension for specific file format extension. It is important to distinguish each new option by multiplying by 2-based integer (i.e. 2, 4, 8, 16, etc.).

* enum {MyFirstOption = AcquisitionFileIO::FileFormatOption, MySecondOption = 2*AcquisitionFileIO::FileFormatOption};
*

Enums used to specify the format of the stored data.

Enumerator
StorageNotApplicable 

Acquisition's data have no storage format.

Float 

Acquisition's data are stored as float values.

Integer 

Acquisition's data are stored as integer values.

Constructor & Destructor Documentation

btk::AcquisitionFileIO::AcquisitionFileIO ( FileType  f = TypeNotApplicable,
ByteOrder  b = OrderNotApplicable,
StorageFormat  s = StorageNotApplicable,
int  internalsUpdate = UpdateNotApplicable 
)
protected

Constructor.

btk::AcquisitionFileIO::~AcquisitionFileIO ( )
inlineprotectedvirtual

Empty destructor.

Member Function Documentation

bool btk::AcquisitionFileIO::CanReadFile ( const std::string &  filename)
pure virtual
bool btk::AcquisitionFileIO::CanWriteFile ( const std::string &  filename)
pure virtual

Checks if filename can be write by this AcquisitionFileIO. This method should try to determine if the file's suffix corresponds to one of the supported file's suffixes by this AcquisitionFileIO.

Implemented in btk::C3DFileIO, btk::CALForcePlateFileIO, btk::ANBFileIO, btk::ANCFileIO, and btk::TRCFileIO.

ByteOrder btk::AcquisitionFileIO::GetByteOrder ( ) const
inline

Gets the byte order of the file (only for binary file).

std::string btk::AcquisitionFileIO::GetByteOrderAsString ( ) const

Gets the byte order as a string.

FileType btk::AcquisitionFileIO::GetFileType ( ) const
inline

Gets the type of the file.

int btk::AcquisitionFileIO::GetInternalsUpdateOptions ( ) const
inline

Returns the option(s) used to update internals.

StorageFormat btk::AcquisitionFileIO::GetStorageFormat ( ) const
inline

Returns the format used to store points and analog channels.

std::string btk::AcquisitionFileIO::GetStorageFormatAsString ( ) const

Gets the storage format as a string.

const Extensions & btk::AcquisitionFileIO::GetSupportedExtensions ( ) const
pure virtual

Return the suppored extensions by this file IO.

bool btk::AcquisitionFileIO::HasInternalsUpdateOption ( int  option) const
inline

Returns true if the given option is used or false if not.

static bool btk::AcquisitionFileIO::HasReadOperation ( )
inlinestatic

Returns the property of this acquisition file IO to read data from a file and extract data.

Note
This method is set to true by default and is automatically adapted in inherited class when the macro BTK_FILE_IO_ONLY_WRITE_OPERATION is used.
static bool btk::AcquisitionFileIO::HasWriteOperation ( )
inlinestatic

Returns the property of this acquisition file IO to read data from a file and extract data.

Note
This method is set to true by default and is automatically adapted in inherited class when the macro BTK_FILE_IO_ONLY_READ_OPERATION is used.
void btk::AcquisitionFileIO::Read ( const std::string &  filename,
Acquisition::Pointer  output 
)
pure virtual
void btk::AcquisitionFileIO::SetByteOrder ( ByteOrder  o)
inline

Sets the byte order of the file (only for binary file).

void btk::AcquisitionFileIO::SetFileType ( FileType  f)
inlineprotected

Sets the type of the file. This method is protected because some file can be only ASCII file or binary file. An inherited class can use this method as public with using AcquisitionFileIO::SetFileType; in its public part.

void btk::AcquisitionFileIO::SetInternalsUpdateOptions ( int  options)
inline

Sets the option(s) used to update internals.

void btk::AcquisitionFileIO::SetStorageFormat ( StorageFormat  s)
inline

Sets the format used to store points and analog channels.

void btk::AcquisitionFileIO::Write ( const std::string &  filename,
Acquisition::Pointer  input 
)
pure virtual

Write the file designated by filename with the content of input.

Implemented in btk::C3DFileIO, btk::CALForcePlateFileIO, btk::ANBFileIO, btk::ANCFileIO, and btk::TRCFileIO.

Member Data Documentation

btk::AcquisitionFileIO::m_ByteOrder
protected

Byte order.

btk::AcquisitionFileIO::m_FileType
protected

File type.

btk::AcquisitionFileIO::m_InternalsUpdate
protected

Configuration used to update file format internals when an acquisition is writed.

btk::AcquisitionFileIO::m_StorageFormat
protected

Storage format.