VR-Forces 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:
-
All classes should be Records, and constructed of POD/Value semantics.
-
All classes should be designed for efficient file storage.
-
All files saved by VR-Forces must represent a single Record that can be loaded using a single call.
Basic usage of records is as follows:
const std::string filename = "name.ext" SomeDataRecord rec;
makArchives::DtXmlFileIo::read(filename, rec, "Name");
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:
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;
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 >>]