torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::architecture::Versions Class Reference

Encapsulation of database version information. More...

#include <Versions.hpp>

+ Inheritance diagram for torc::architecture::Versions:
+ Collaboration diagram for torc::architecture::Versions:

Public Member Functions

const DottedVersiongetFormat (void) const
 Returns the database format version. More...
 
uint32_t getBuild (void) const
 Returns the database build number. More...
 
const DottedVersiongetVendor (void) const
 Returns the vendor data version. More...
 
const stringgetVendorString (void) const
 Returns the database format version string. More...
 

Protected Types

typedef std::string string
 Imported type name. More...
 
typedef boost::uint8_t uint8_t
 Imported type name. More...
 
typedef boost::uint16_t uint16_t
 Imported type name. More...
 
typedef boost::uint32_t uint32_t
 Imported type name. More...
 
typedef torc::common::DottedVersion DottedVersion
 Imported type name. More...
 

Protected Member Functions

size_t readVersions (DigestStream &inStream, bool inShowVersion=false)
 Read the version information. More...
 
 Versions (void)
 Protected constructor. More...
 

Protected Attributes

DottedVersion mFormat
 The database format version. More...
 
uint32_t mBuild
 The database build number. More...
 
DottedVersion mVendor
 The vendor data version. More...
 
string mVendorString
 The vendor data version string. More...
 

Private Types

typedef std::basic_istream< char > istream
 Internal typedef of istream;. More...
 
typedef std::basic_ostream< char > ostream
 Internal typedef of ostream;. More...
 

Private Member Functions

istreammIn (void)
 Returns the database console input stream. More...
 
ostreammOut (void)
 Returns the database console output stream. More...
 
ostreammErr (void)
 Returns the database console error stream. More...
 
ostreammLog (void)
 Returns the database console log stream. More...
 
istreamgetConsoleIn (void)
 Returns the database console input stream. More...
 
ostreamgetConsoleOut (void)
 Returns the database console output stream. More...
 
ostreamgetConsoleErr (void)
 Returns the database console error stream. More...
 
ostreamgetConsoleLog (void)
 Returns the database console log stream. More...
 
void setConsoleIn (istream &inStream)
 Sets the database console input stream. More...
 
void setConsoleOut (ostream &inStream)
 Sets the database console output stream. More...
 
void setConsoleErr (ostream &inStream)
 Sets the database console error stream. More...
 
void setConsoleLog (ostream &inStream)
 Sets the database console log stream. More...
 
virtual void setConsoleStreams (istream &inIn, ostream &inOut, ostream &inErr, ostream &inLog)
 Sets all of the database console streams. More...
 

Private Attributes

istreammInPtr
 Pointer to the database console input stream. More...
 
ostreammOutPtr
 
ostreammErrPtr
 
ostreammLogPtr
 

Static Private Attributes

static DDBConsoleStreams sDefaultConsoleStreams
 
static DDBConsoleStreams sNullConsoleStreams
 

Friends

class DDB
 The database has access to our protected functions. More...
 
class torc::architecture::architecture::DigestStreamUnitTest
 The DigestStream unit test has access to our protected functions. More...
 

Detailed Description

Encapsulation of database version information.

The format version information determines if and how DDB should read the database. The vendor vesion information indicates the version of the vendor tools that the database was generated from.

Definition at line 37 of file Versions.hpp.

Member Typedef Documentation

Imported type name.

Definition at line 49 of file Versions.hpp.

Internal typedef of istream;.

Definition at line 41 of file DDBConsoleStreams.hpp.

Internal typedef of ostream;.

Definition at line 43 of file DDBConsoleStreams.hpp.

typedef std::string torc::architecture::Versions::string
protected

Imported type name.

Definition at line 45 of file Versions.hpp.

typedef boost::uint16_t torc::architecture::Versions::uint16_t
protected

Imported type name.

Definition at line 47 of file Versions.hpp.

typedef boost::uint32_t torc::architecture::Versions::uint32_t
protected

Imported type name.

Definition at line 48 of file Versions.hpp.

typedef boost::uint8_t torc::architecture::Versions::uint8_t
protected

Imported type name.

Definition at line 46 of file Versions.hpp.

Constructor & Destructor Documentation

torc::architecture::Versions::Versions ( void  )
inlineprotected

Protected constructor.

Definition at line 66 of file Versions.hpp.

66 : mFormat(), mBuild(0), mVendor(), mVendorString() {}
DottedVersion mFormat
The database format version.
Definition: Versions.hpp:54
DottedVersion mVendor
The vendor data version.
Definition: Versions.hpp:58
string mVendorString
The vendor data version string.
Definition: Versions.hpp:60
uint32_t mBuild
The database build number.
Definition: Versions.hpp:56

Member Function Documentation

uint32_t torc::architecture::Versions::getBuild ( void  ) const
inline

Returns the database build number.

Definition at line 72 of file Versions.hpp.

72 { return mBuild; }
uint32_t mBuild
The database build number.
Definition: Versions.hpp:56
ostream& torc::architecture::DDBConsoleStreams::getConsoleErr ( void  )
inlineinherited

Returns the database console error stream.

Definition at line 69 of file DDBConsoleStreams.hpp.

69 { return mErr(); }
ostream & mErr(void)
Returns the database console error stream.

+ Here is the call graph for this function:

istream& torc::architecture::DDBConsoleStreams::getConsoleIn ( void  )
inlineinherited

Returns the database console input stream.

Definition at line 65 of file DDBConsoleStreams.hpp.

65 { return mIn(); }
istream & mIn(void)
Returns the database console input stream.

+ Here is the call graph for this function:

ostream& torc::architecture::DDBConsoleStreams::getConsoleLog ( void  )
inlineinherited

Returns the database console log stream.

Definition at line 71 of file DDBConsoleStreams.hpp.

71 { return mLog(); }
ostream & mLog(void)
Returns the database console log stream.

+ Here is the call graph for this function:

ostream& torc::architecture::DDBConsoleStreams::getConsoleOut ( void  )
inlineinherited

Returns the database console output stream.

Definition at line 67 of file DDBConsoleStreams.hpp.

67 { return mOut(); }
ostream & mOut(void)
Returns the database console output stream.

+ Here is the call graph for this function:

const DottedVersion& torc::architecture::Versions::getFormat ( void  ) const
inline

Returns the database format version.

Definition at line 70 of file Versions.hpp.

70 { return mFormat; }
DottedVersion mFormat
The database format version.
Definition: Versions.hpp:54

+ Here is the caller graph for this function:

const DottedVersion& torc::architecture::Versions::getVendor ( void  ) const
inline

Returns the vendor data version.

Definition at line 74 of file Versions.hpp.

74 { return mVendor; }
DottedVersion mVendor
The vendor data version.
Definition: Versions.hpp:58
const string& torc::architecture::Versions::getVendorString ( void  ) const
inline

Returns the database format version string.

Definition at line 76 of file Versions.hpp.

76 { return mVendorString; }
string mVendorString
The vendor data version string.
Definition: Versions.hpp:60
ostream& torc::architecture::DDBConsoleStreams::mErr ( void  )
inlineinherited

Returns the database console error stream.

Definition at line 61 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

istream& torc::architecture::DDBConsoleStreams::mIn ( void  )
inlineinherited

Returns the database console input stream.

Definition at line 57 of file DDBConsoleStreams.hpp.

57 { return *mInPtr; }
istream * mInPtr
Pointer to the database console input stream.

+ Here is the caller graph for this function:

ostream& torc::architecture::DDBConsoleStreams::mLog ( void  )
inlineinherited

Returns the database console log stream.

Definition at line 63 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

ostream& torc::architecture::DDBConsoleStreams::mOut ( void  )
inlineinherited

Returns the database console output stream.

Definition at line 59 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

size_t torc::architecture::Versions::readVersions ( DigestStream inStream,
bool  inShowVersion = false 
)
protected

Read the version information.

Todo:
Throw a proper exception.
Todo:
Throw a proper exception.

Definition at line 25 of file Versions.cpp.

25  {
26  // prepare to read from the stream
27  size_t bytesReadOffset = inStream.getBytesRead();
28  char scratch[1 << 10]; // scratch read buffer
29  uint16_t nameLength = 0; // length of tile type name
30 
31  // read the "TORC" magic
32  std::string torc("TORC");
33  inStream.read(scratch, 4);
34  scratch[4] = 0;
35  if(!(torc == scratch)) {
36  mErr() << "This is not a valid Torc database. Magic \"" << scratch
37  << "\" does not match expected \"" << torc << "\"." << std::endl;
38  return 0;
39  }
40 
41  // read the database Versions information
42  inStream.read(mFormat.mMajor);
43  inStream.read(mFormat.mMinor);
44  inStream.read(mFormat.mRevision);
45  inStream.read(mFormat.mReserved);
46  // read the database build number
47  inStream.read(mBuild);
48 
49  // if the database version we just read isn't one that we support, we should throw an
50  // exception and/or return now
51 
52  // read the section header
53  std::string versionHeader;
54  inStream.readSectionHeader(versionHeader);
55  /// \todo Throw a proper exception.
56  if(versionHeader != ">>>>Version >>>>") throw -1;
57 
58  // read the vendor Versions information
59  inStream.read(mVendor.mMajor);
60  inStream.read(mVendor.mMinor);
61  inStream.read(mVendor.mRevision);
62  inStream.read(mVendor.mReserved);
63  // read the vendor Versions string
64  inStream.read(nameLength);
65  /// \todo Throw a proper exception.
66  if(nameLength > sizeof(scratch)) throw -1;
67  inStream.read(scratch, nameLength);
68  scratch[nameLength] = 0;
69  mVendorString = scratch;
70 
71  if(inShowVersion) mOut() << "\tDatabase " << static_cast<uint32_t>(mFormat.mMajor)
72  << "." << static_cast<uint32_t>(mFormat.mMinor) << "."
73  << static_cast<uint32_t>(mFormat.mRevision) << " build " << mBuild << ", Vendor "
74  //<< static_cast<uint32_t>(mVendor.mMajor) << "."
75  //<< static_cast<uint32_t>(mVendor.mMinor) << "."
76  //<< static_cast<uint32_t>(mVendor.mRevision)
77  << '"' << mVendorString << '"' << std::endl;
78 
79  // return the number of bytes read
80  return inStream.getBytesRead() - bytesReadOffset;
81  }
ostream & mErr(void)
Returns the database console error stream.
std::string string
DottedVersion mFormat
The database format version.
Definition: Versions.hpp:54
boost::uint16_t uint16_t
Imported type name.
Definition: Versions.hpp:47
ostream & mOut(void)
Returns the database console output stream.
DottedVersion mVendor
The vendor data version.
Definition: Versions.hpp:58
string mVendorString
The vendor data version string.
Definition: Versions.hpp:60
boost::uint32_t uint32_t
Imported type name.
Definition: Versions.hpp:48
uint32_t mBuild
The database build number.
Definition: Versions.hpp:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleErr ( ostream inStream)
inlineinherited

Sets the database console error stream.

Definition at line 77 of file DDBConsoleStreams.hpp.

77 { mErrPtr = &inStream; }

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleIn ( istream inStream)
inlineinherited

Sets the database console input stream.

Definition at line 73 of file DDBConsoleStreams.hpp.

73 { mInPtr = &inStream; }
istream * mInPtr
Pointer to the database console input stream.

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleLog ( ostream inStream)
inlineinherited

Sets the database console log stream.

Definition at line 79 of file DDBConsoleStreams.hpp.

79 { mLogPtr = &inStream; }

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleOut ( ostream inStream)
inlineinherited

Sets the database console output stream.

Definition at line 75 of file DDBConsoleStreams.hpp.

75 { mOutPtr = &inStream; }

+ Here is the caller graph for this function:

virtual void torc::architecture::DDBConsoleStreams::setConsoleStreams ( istream inIn,
ostream inOut,
ostream inErr,
ostream inLog 
)
inlinevirtualinherited

Sets all of the database console streams.

Parameters
inInThe console input stream.
inOutThe console output stream.
inErrThe console error stream.
inLogThe console log stream.

Reimplemented in torc::architecture::DDB.

Definition at line 85 of file DDBConsoleStreams.hpp.

86  {
87  setConsoleIn(inIn);
88  setConsoleOut(inOut);
89  setConsoleErr(inErr);
90  setConsoleLog(inLog);
91  }
void setConsoleOut(ostream &inStream)
Sets the database console output stream.
void setConsoleIn(istream &inStream)
Sets the database console input stream.
void setConsoleLog(ostream &inStream)
Sets the database console log stream.
void setConsoleErr(ostream &inStream)
Sets the database console error stream.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class DDB
friend

The database has access to our protected functions.

Definition at line 40 of file Versions.hpp.

friend class torc::architecture::architecture::DigestStreamUnitTest
friend

The DigestStream unit test has access to our protected functions.

Definition at line 42 of file Versions.hpp.

Field Documentation

uint32_t torc::architecture::Versions::mBuild
protected

The database build number.

Definition at line 56 of file Versions.hpp.

ostream* torc::architecture::DDBConsoleStreams::mErrPtr
protectedinherited

Definition at line 96 of file DDBConsoleStreams.hpp.

DottedVersion torc::architecture::Versions::mFormat
protected

The database format version.

Definition at line 54 of file Versions.hpp.

istream* torc::architecture::DDBConsoleStreams::mInPtr
protectedinherited

Pointer to the database console input stream.

Definition at line 94 of file DDBConsoleStreams.hpp.

ostream* torc::architecture::DDBConsoleStreams::mLogPtr
protectedinherited

Definition at line 97 of file DDBConsoleStreams.hpp.

ostream* torc::architecture::DDBConsoleStreams::mOutPtr
protectedinherited

Definition at line 95 of file DDBConsoleStreams.hpp.

DottedVersion torc::architecture::Versions::mVendor
protected

The vendor data version.

Definition at line 58 of file Versions.hpp.

string torc::architecture::Versions::mVendorString
protected

The vendor data version string.

Definition at line 60 of file Versions.hpp.

DDBConsoleStreams torc::architecture::DDBConsoleStreams::sDefaultConsoleStreams
staticinherited

Definition at line 45 of file DDBConsoleStreams.hpp.

DDBConsoleStreams torc::architecture::DDBConsoleStreams::sNullConsoleStreams
staticinherited

Definition at line 46 of file DDBConsoleStreams.hpp.


The documentation for this class was generated from the following files: