VR-Vantage 2.6 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
4.4 - Records

VR-Vantage uses Boost's serialization functionality for reading and writing files.

A class that contains data that is to be read from disk and written to disk is called a record.

Record classes are part of the makArchives library. The guidelines for classes in this library are as follows:

Basic usage of records is as follows:

const std::string filename = "name.ext" SomeDataRecord rec;
//To read a file.
makArchives::DtXmlFileIo::read(filename, rec, "Name");
//To write a file.
makArchives::DtXmlFileIo::read(filename, rec, "Name");

For the most part there is a specific DataRecord type for each file type. However, some records deviate from this standard. All files in ./appData/drivers are DtDriverRecord files, for example, DIS.DtDisDriver stores a DtDriverRecord. The file extension (.DtDisDriver) is the name of the driver class needed to use the file data.

Here is an example record:

class DtTestRecord
{
public:
// All values in a record *MUST* be initialized.
DtTestRecord()
: degrees(0)
, minutes(0)
, seconds(0.0)
{
}
DtTestRecord(int d, int m, float s)
: degrees(d)
, minutes(m)
, seconds(s)
{
}
int degrees;
int minutes;
float seconds;
protected:
friend class boost::serialization::access;
// When the class Archive corresponds to an output archive, the
// & operator is defined similar to <<. Likewise, when the class
// Archive is a type of input archive the & operator is defined
// similar to >>.
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(degrees);
ar & BOOST_SERIALIZATION_NVP(minutes);
ar & BOOST_SERIALIZATION_NVP(seconds);
}
};

To write a test record:

std::string filePath = "testRecord.xml";
DtTestRecord data(35, 59, 24.567f);
makArchives::DtXmlFileIo::write(filePath, data, "DtTestRecord");

To read a test record:

std::string filePath = "testRecord.xml";
DtTestRecord data;
makArchives::DtXmlFileIo::read(filePath, data, "DtTestRecord");

[<< Runtime Settings] [Home] [Top of Page] [Configuration Files >>]



Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)