Libgetar C++ API

GTAR

class GTAR

Accessor interface for a trajectory archive.

Public Functions

GTAR(const std::string &filename, const OpenMode mode)

Constructor. Opens the file at filename in the given mode. The format of the file depends on the extension of filename.

void close()

Manually close the opened archive (it automatically closes itself upon destruction)

void writeString(const std::string &path, const std::string &contents, CompressMode mode)

Write a string to the given location.

void writeBytes(const std::string &path, const std::vector<char> &contents, CompressMode mode)

Write a bytestring to the given location.

void writePtr(const std::string &path, const void *contents, const size_t byteLength, CompressMode mode)

Write the contents of a pointer to the given location.

template<typename iter, typename T>
void writeIndividual(const std::string &path, const iter &start, const iter &end, CompressMode mode)

Write an individual binary property to the specified location, converting to little endian if necessary.

template<typename T>
void writeUniform(const std::string &path, const T &val)

Write a uniform binary property to the specified location, converting to little endian if necessary.

template<typename T>
SharedArray<T> readIndividual(const std::string &path)

Read an individual binary property to the specified location, converting from little endian if necessary.

template<typename T>
SharedPtr<T> readUniform(const std::string &path)

Read a uniform binary property to the specified location, converting from little endian if necessary.

SharedArray<char> readBytes(const std::string &path)

Read a bytestring from the specified location.

std::vector<Record> getRecordTypes() const

Query all of the records in the archive. These will all have empty indices.

std::vector<std::string> queryFrames(const Record &target) const

Query the indices associated with a given record. The record is not required to have a null index.

class BulkWriter

Public Functions

BulkWriter(GTAR &archive)

Create a new BulkWriter on an archive. Only one should exist for any archive at a time.

~BulkWriter()

Clean up the BulkWriter data. Causes all writes to be performed.

void writeString(const std::string &path, const std::string &contents, CompressMode mode)

Write a string to the given location.

void writeBytes(const std::string &path, const std::vector<char> &contents, CompressMode mode)

Write a bytestring to the given location.

void writePtr(const std::string &path, const void *contents, const size_t byteLength, CompressMode mode)

Write the contents of a pointer to the given location.

template<typename iter, typename T>
void writeIndividual(const std::string &path, const iter &start, const iter &end, CompressMode mode)

Write an individual binary property to the specified location, converting to little endian if necessary.

template<typename T>
void writeUniform(const std::string &path, const T &val)

Write a uniform binary property to the specified location, converting to little endian if necessary.

Record

class Record

Simple class for a record which can be stored in an archive.

Public Functions

Record()

Default constructor: initialize all strings to empty, behavior to Constant, format to UInt8, and resolution to Text

Record(const std::string &path)

Create a record from a path (inside the archive), parsing the path into the various fields

Record(const std::string &group, const std::string &name, const std::string &index, Behavior behavior, Format format, Resolution resolution)

Create a record directly from the full set of elements.

Record(const Record &rhs)

Copy constructor.

void operator=(const Record &rhs)

Assignment operator.

bool operator==(const Record &rhs) const

Equality.

bool operator!=(const Record &rhs) const

Inequality.

bool operator<(const Record &rhs) const

Comparison.

void copy(const Record &rhs)

Copy all fields from rhs into this object.

std::string nullifyIndex()

Set our index to the empty string.

Record withNullifiedIndex() const

Return a copy of this object, but with an empty string for its index

std::string getPath() const

Construct a path (for inside an archive) from this object’s various fields

std::string getGroup() const

Get the stored group field.

std::string getName() const

Get the stored name field.

std::string getIndex() const

Get the stored index field.

Behavior getBehavior() const

Get the stored behavior field.

Format getFormat() const

Get the stored format field.

Resolution getResolution() const

Get the stored resolution field.

void setIndex(const std::string &index)

Set the index field for this Record object.

Enums: Behavior, Format, Resolution

enum gtar::Behavior

Time behavior of properties.

Values:

enumerator Constant
enumerator Discrete
enumerator Continuous
enum gtar::Format

Binary formats in which properties can be stored.

Values:

enumerator Float32
enumerator Float64
enumerator Int32
enumerator Int64
enumerator UInt8
enumerator UInt32
enumerator UInt64
enum gtar::Resolution

Level of detail of property storage.

Values:

enumerator Text
enumerator Uniform
enumerator Individual

SharedArray

template<typename T>
class SharedArray

Generic reference-counting shared array implementation for arbitrary datatypes.

Subclassed by gtar::SharedPtr< T >

Public Functions

inline SharedArray()

Default constructor. Allocates nothing.

inline SharedArray(T *target, size_t length)

Target constructor: allocates a new SharedArrayShim for the given pointer and takes ownership of it.

inline SharedArray(const SharedArray<T> &rhs)

Copy constructor: make this object point to the same array as rhs, increasing the reference count if necessary

inline SharedArray(const SharedPtr<T> &rhs)

Initialize from SharedPtr: make this object point to the same shim as rhs, increasing the reference count if necessary

inline ~SharedArray()

Destructor: decrement the reference count and deallocate if we are the last owner of the pointer

inline void copy(const SharedArray<T> &rhs)

Non-operator form of assignment.

inline bool isNull()

Returns true if m_shim is null or m_shim’s target is null.

inline void operator=(const SharedArray<T> &rhs)

Assignment operator: make this object point to the same thing as rhs (and deallocate our old memory if necessary)

inline iterator begin()

Returns a standard style iterator to the start of the array.

inline iterator end()

Returns a standard style iterator to just past the end of the array.

inline T *get()

Returns the raw pointer held (NULL otherwise)

inline size_t size() const

Returns the size, in number of objects, of this array.

inline void release()

Release our claim on the pointer, including decrementing the reference count

inline T *disown()

Stop managing this array and give it to C.

inline void swap(SharedArray<T> &target)

Swap the contents of this array with another.

inline T &operator[](size_t idx)

Access elements by index.

inline const T &operator[](size_t idx) const

Const access to elements by index.