Garmin Fleet Management Controller
2.19.0
|
Map whose contents are also saved to a file. More...
#include <FileBackedMap.h>
Public Types | |
typedef std::map< key_type, T >::const_iterator | const_iterator |
Iterator for read-only traversal through the map. More... | |
typedef T::key_type | key_type |
key type More... | |
Public Member Functions | |
FileBackedMap (const char *aFileName) | |
Create a new FileBackedMap. More... | |
const_iterator | begin () |
Iterator positioned at the first element in the map. More... | |
void | clear () |
Remove all elements from the map. More... | |
bool | contains (const key_type &aKey) |
Check whether the specified key is in the map. More... | |
uint32 | count () const |
The number of items in the map. More... | |
bool | empty () |
Check whether the map is empty. More... | |
const_iterator | end () |
Iterator positioned after the last element in the map. More... | |
T & | get (const key_type &aKey) |
Get the item by key. More... | |
const key_type & | getKeyAt (uint32 aIndex) const |
Get the key for the item at a given list index. More... | |
void | put (T &aValue) |
Add (or replace) an item in the map. More... | |
void | remove (const key_type &aKey) |
Remove an item from the map. More... | |
void | save () |
Save the map to disk. More... | |
uint32 | validCount () const |
The number of valid items in the map. More... | |
Private Member Functions | |
void | load () |
Read the contents of the backing file into the map. More... | |
Private Attributes | |
const char * | mFileName |
The name of the file that this map is saved to. More... | |
std::vector< key_type > | mKeyList |
Map of indexes to keys. More... | |
std::map< key_type, T > | mMap |
The underlying map in memory. More... | |
Map whose contents are also saved to a file.
A FileBackedMap is a map of uint32 to a value type. Each value in the map for which isValid() returns TRUE is saved to a text file, with one line per item.
Methods are provided to add/replace, remove, check for, and get items from the underlying map, iterate through the items in the map, and clear the map's contents. All keep the underlying file in sync.
T | The value type for items in the map. |
Definition at line 32 of file FileBackedMap.h.
typedef std::map<key_type, T>::const_iterator FileBackedMap< T >::const_iterator |
Iterator for read-only traversal through the map.
Definition at line 54 of file FileBackedMap.h.
typedef T::key_type FileBackedMap< T >::key_type |
key type
Definition at line 36 of file FileBackedMap.h.
|
inline |
Create a new FileBackedMap.
Construct a FileBackedMap and load all items from file
aFileName | The file associated with this map. |
Definition at line 46 of file FileBackedMap.h.
|
inline |
Iterator positioned at the first element in the map.
Definition at line 59 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::getNextStopId(), CFmiPcAppDlg::initStopList(), CFmiPcAppDlg::OnBnClickedEnable(), CSelectCannedResponseDlg::OnInitDialog(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendDeleteWaypointCat(), CWaypointDlg::updateCatBox(), CCannedTxtMsgDlg::updateListBox(), CDriverLoginDlg::updateListBox(), CDriverIdAndStatusDlg::updateListBox(), CAobrdDriversDlg::updateListBox(), CManageCannedResponseDlg::updateListBox(), and CWaypointDlg::updateListBox().
|
inline |
Remove all elements from the map.
Definition at line 88 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::resetCannedMessages(), FmiApplicationLayer::resetCannedResponseMessages(), FmiApplicationLayer::resetCannedResponses(), FmiApplicationLayer::resetDriverStatusList(), FmiApplicationLayer::resetSavedStops(), and FmiApplicationLayer::resetWaypoints().
|
inline |
Check whether the specified key is in the map.
aKey | The key to look for |
Definition at line 78 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::end(), FmiApplicationLayer::getNextStopId(), FmiApplicationLayer::procDriverStatusUpdate(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendAOBRDDriverDownloadResponseV2(), and FmiApplicationLayer::sendDeleteWaypoint().
|
inline |
The number of items in the map.
Definition at line 197 of file FileBackedMap.h.
|
inline |
Check whether the map is empty.
Definition at line 163 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::getNextStopId(), and FmiApplicationLayer::removeStopByIndex().
|
inline |
Iterator positioned after the last element in the map.
Definition at line 67 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::getNextStopId(), CFmiPcAppDlg::initStopList(), CFmiPcAppDlg::OnBnClickedEnable(), CSelectCannedResponseDlg::OnInitDialog(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendDeleteWaypointCat(), CWaypointDlg::updateCatBox(), CCannedTxtMsgDlg::updateListBox(), CDriverLoginDlg::updateListBox(), CDriverIdAndStatusDlg::updateListBox(), CAobrdDriversDlg::updateListBox(), CManageCannedResponseDlg::updateListBox(), and CWaypointDlg::updateListBox().
|
inline |
Get the item by key.
Get the item with the specified key, creating it if it is not already in the map.
aKey | The key of the item to retrieve |
Definition at line 102 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::procDriverStatusUpdate(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendA603Stop(), FmiApplicationLayer::sendAOBRDDriverDownloadResponseV2(), FmiApplicationLayer::sendCannedMessage(), FmiApplicationLayer::sendCannedResponse(), FmiApplicationLayer::sendCreateWaypointCat(), FmiApplicationLayer::sendDeleteWaypointCat(), FmiApplicationLayer::sendDriverStatusListItem(), FmiApplicationLayer::sendNextAOBRDShipment(), and FmiApplicationLayer::sendWaypoint().
|
inline |
Get the key for the item at a given list index.
aIndex | The key of the item to retrieve. Must be less than validCount(). |
Definition at line 119 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::get(), CWaypointDlg::getCatIds(), and CWaypointDlg::OnBnClickedWptBtnDelete().
|
inlineprivate |
Read the contents of the backing file into the map.
Load all items from mFileName into mMap.
Definition at line 216 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::FileBackedMap().
|
inline |
Add (or replace) an item in the map.
aValue | The item to add |
Definition at line 133 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::getKeyAt(), CStopNewDlg::OnBnClickedOk(), FmiApplicationLayer::rx(), FmiApplicationLayer::sendA603Stop(), FmiApplicationLayer::sendCannedMessage(), FmiApplicationLayer::sendCannedResponse(), FmiApplicationLayer::sendCreateWaypointCat(), FmiApplicationLayer::sendDriverStatusListItem(), and FmiApplicationLayer::sendWaypoint().
|
inline |
Remove an item from the map.
aKey | The key of the item to remove |
Definition at line 147 of file FileBackedMap.h.
Referenced by FmiApplicationLayer::removeStopByIndex(), FmiApplicationLayer::rx(), and FmiApplicationLayer::sendDeleteWaypoint().
|
inline |
Save the map to disk.
Definition at line 171 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::clear(), FileBackedMap< StopListItem >::put(), FileBackedMap< StopListItem >::remove(), DriverLoginItem::save(), WaypointListItem::save(), AobrdDriverItem::save(), and ClientListItem::save().
|
inline |
The number of valid items in the map.
Definition at line 206 of file FileBackedMap.h.
|
private |
The name of the file that this map is saved to.
Definition at line 240 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::load(), and FileBackedMap< StopListItem >::save().
|
private |
Map of indexes to keys.
Definition at line 246 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::getKeyAt(), FileBackedMap< StopListItem >::load(), FileBackedMap< StopListItem >::save(), and FileBackedMap< StopListItem >::validCount().
|
private |
The underlying map in memory.
Definition at line 243 of file FileBackedMap.h.
Referenced by FileBackedMap< StopListItem >::begin(), FileBackedMap< StopListItem >::clear(), FileBackedMap< StopListItem >::contains(), FileBackedMap< StopListItem >::count(), FileBackedMap< StopListItem >::empty(), FileBackedMap< StopListItem >::end(), FileBackedMap< StopListItem >::get(), FileBackedMap< StopListItem >::load(), FileBackedMap< StopListItem >::put(), FileBackedMap< StopListItem >::remove(), and FileBackedMap< StopListItem >::save().