# Barry::Mode::Desktop Class Reference

`#include <m_desktop.h>`

Inheritance diagram for Barry::Mode::Desktop:

[legend]
Collaboration diagram for Barry::Mode::Desktop:

[legend]

List of all members.

## Detailed Description

The main interface class to the device databases.

To use this class, use the following steps:

- Create a Controller object (see Controller class for more details)
- Create this Mode::Desktop object, passing in the Controller object during construction
- Call Open() to open database socket and finish constructing.
- Call GetDBDB() to get the device's database database
- Call GetDBID() to get a database ID by name
- Call LoadDatabase() to retrieve and store a database

Definition at line 58 of file m_desktop.h.

## Public Member Functions

const DatabaseDatabase & | GetDBDB () const
| Returns DatabaseDatabase object for this connection.
unsigned int | GetDBID (const std::string &name) const
| Get numeric database ID by name.
unsigned int | GetDBCommand (CommandType ct)
| Get database command from command table.
void | GetRecordStateTable (unsigned int dbId, RecordStateTable &result)
| Retrieve the record state table from the handheld device, using the given database ID.
void | AddRecord (unsigned int dbId, Builder &build)
| Adds a record to the specified database.
void | GetRecord (unsigned int dbId, unsigned int stateTableIndex, Parser &parser)
| Retrieves a specific record from the specified database.
void | SetRecord (unsigned int dbId, unsigned int stateTableIndex, Builder &build)
| Overwrites a specific record in the device as identified by the stateTableIndex.
void | ClearDirty (unsigned int dbId, unsigned int stateTableIndex)
| Clears the dirty flag on the specified record in the specified database.
void | DeleteRecord (unsigned int dbId, unsigned int stateTableIndex)
| Deletes the specified record in the specified database.
void | LoadDatabase (unsigned int dbId, Parser &parser)
| Retrieve a database from the handheld device, using the given parser to parse the resulting data, and optionally store it.

## Member Function Documentation

const DatabaseDatabase& Barry::Mode::Desktop::GetDBDB | ( |  | ) | const`[inline]`

Returns DatabaseDatabase object for this connection.

Must call Open() first, which loads the DBDB.

Definition at line 94 of file m_desktop.h.

unsigned int Barry::Mode::Desktop::GetDBID | ( | const std::string & | name | ) | const

Get numeric database ID by name.

Parameters:

  `[in]` | name | Name of database, which matches one of the names listed in GetDBDB()

Exceptions:

  | Barry::Error | Thrown if name not found.

Definition at line 134 of file m_desktop.cc.

unsigned int Barry::Mode::Desktop::GetDBCommand | ( | CommandType | ct | ) |

Get database command from command table.

Must call Open() before this.

Definition at line 150 of file m_desktop.cc.

Referenced by Barry::DBPacket::ClearDatabase(), Barry::DBPacket::DeleteRecordByIndex(), Barry::DBPacket::GetDBDB(), Barry::DBPacket::GetRecordByIndex(), Barry::DBPacket::GetRecords(), Barry::DBPacket::GetRecordStateTable(), Barry::DBPacket::SetRecord(), Barry::DBPacket::SetRecordByIndex(), and Barry::DBPacket::SetRecordFlags().

Here is the caller graph for this function:

void Barry::Mode::Desktop::GetRecordStateTable | ( | unsigned int | dbId,
|  | RecordStateTable & | result |
| ) |  |  |

Retrieve the record state table from the handheld device, using the given database ID.

Results will be stored in result, which will be cleared before adding.

Definition at line 186 of file m_desktop.cc.

References Barry::DBPacket::GetRecordStateTable().

Here is the call graph for this function:

void Barry::Mode::Desktop::AddRecord | ( | unsigned int | dbId,
|  | Builder & | build |
| ) |  |  |

Adds a record to the specified database.

RecordId is retrieved from build, and duplicate IDs are allowed by the device (i.e. you can have two records with the same ID) but *not* recommended!

Definition at line 212 of file m_desktop.cc.

References Barry::DBPacket::ReturnCode(), and Barry::DBPacket::SetRecord().

Here is the call graph for this function:

void Barry::Mode::Desktop::GetRecord | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex,
|  | Parser & | parser |
| ) |  |  |

Retrieves a specific record from the specified database.

The stateTableIndex comes from the GetRecordStateTable() function. GetRecord() does not clear the dirty flag.

Definition at line 247 of file m_desktop.cc.

References Barry::DBPacket::GetRecordByIndex(), and Barry::DBPacket::Parse().

Here is the call graph for this function:

void Barry::Mode::Desktop::SetRecord | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex,
|  | Builder & | build |
| ) |  |  |

Overwrites a specific record in the device as identified by the stateTableIndex.

Definition at line 297 of file m_desktop.cc.

References Barry::DBPacket::ReturnCode(), and Barry::DBPacket::SetRecordByIndex().

Here is the call graph for this function:

void Barry::Mode::Desktop::ClearDirty | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex |
| ) |  |  |

Clears the dirty flag on the specified record in the specified database.

Definition at line 333 of file m_desktop.cc.

References Barry::DBPacket::SetRecordFlags().

Here is the call graph for this function:

void Barry::Mode::Desktop::DeleteRecord | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex |
| ) |  |  |

Deletes the specified record in the specified database.

Definition at line 352 of file m_desktop.cc.

References Barry::DBPacket::DeleteRecordByIndex().

Here is the call graph for this function:

void Barry::Mode::Desktop::LoadDatabase | ( | unsigned int | dbId,
|  | Parser & | parser |
| ) |  |  |

Retrieve a database from the handheld device, using the given parser to parse the resulting data, and optionally store it.

See the RecordParser<> template to create a parser object. The RecordParser<> template allows custom storage based on the type of database record retrieved. The database ID and the parser Record type must match.

Parameters:

  `[in]` | dbId | Database Database ID - use GetDBID()
  `[out]` | parser | Parser object which parses the resulting protocol data, and optionally stores it in a custom fashion. See the RecordParser<> template.

Exceptions:

  | Barry::Error | Thrown on protocol error.
  | std::logic_error | Thrown if not in Desktop mode.

Definition at line 389 of file m_desktop.cc.

References Barry::Mode::DBLoader::GetNextRecord(), Barry::Parser::ParseRecord(), and Barry::Mode::DBLoader::StartDBLoad().

Here is the call graph for this function:

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

- m_desktop.h
- m_desktop.cc
- m_desktoptmpl.h