Bitstream Interpretation Library (BIL)  0.1
Public Types | Public Member Functions | Friends
bil::DeviceRegistry Class Reference

A registry associating device IDs with their names and vice versa. More...

#include <deviceinfo/DeviceRegistry.hpp>

List of all members.

Public Types

typedef std::pair< const
DeviceID::ID_t, std::string > 
pair_t
 type for contained device ID/name pairs

Public Member Functions

 DeviceRegistry ()
 Constructs a new DeviceRegistry instance.
void insert (DeviceID::ID_t deviceID, const std::string &deviceName)
 Copies a ID/name pair into registry.
bool erase (DeviceID::ID_t deviceID)
 Erases a ID/name pair from registry.
bool erase (const std::string &deviceName)
 Erases a ID/name pair from registry.
void clear ()
 Erases all ID/name pairs.
size_t size () const
 Gets the number of contained ID/name pairs.
const pair_tat (size_t index) const
 Gets a device ID/name pair by index read only.
std::string lookup (DeviceID::ID_t deviceID) const
 Looks up a device name by ID.
DeviceID::ID_t lookup (const std::string &deviceName) const
 Looks up a device ID by name.

Friends

void writeBinary (const DeviceRegistry &data, std::ostream &outputStream)
 Writes data from a DeviceRegistry into a binary stream.
void readBinary (DeviceRegistry &data, std::istream &inputStream)
 Reads data into a DeviceRegistry from a binary stream.

Detailed Description

A registry associating device IDs with their names and vice versa.

Every device has got a device ID and a name. This registry holds pairs of them and allows for lookup by ID and by name.

Definition at line 26 of file DeviceRegistry.hpp.


Member Typedef Documentation

typedef std::pair<const DeviceID::ID_t, std::string> bil::DeviceRegistry::pair_t

type for contained device ID/name pairs

Definition at line 82 of file DeviceRegistry.hpp.


Constructor & Destructor Documentation

DeviceRegistry::DeviceRegistry ( )

Constructs a new DeviceRegistry instance.

Definition at line 14 of file DeviceRegistry.cpp.


Member Function Documentation

void DeviceRegistry::insert ( DeviceID::ID_t  deviceID,
const std::string &  deviceName 
)

Copies a ID/name pair into registry.

Parameters:
deviceIDID of the device.
deviceNameName of the device.
Exceptions:
.

Definition at line 20 of file DeviceRegistry.cpp.

bool DeviceRegistry::erase ( DeviceID::ID_t  deviceID)

Erases a ID/name pair from registry.

Parameters:
deviceIDID of the ID/name pair to erase.
Returns:
True, if designated pair was found, false otherwise.

Definition at line 40 of file DeviceRegistry.cpp.

bool DeviceRegistry::erase ( const std::string &  deviceName)

Erases a ID/name pair from registry.

Parameters:
deviceNameName of the ID/name pair to erase.
Returns:
True, if designated pair was found, false otherwise.

Definition at line 56 of file DeviceRegistry.cpp.

void DeviceRegistry::clear ( )

Erases all ID/name pairs.

Definition at line 72 of file DeviceRegistry.cpp.

size_t DeviceRegistry::size ( ) const

Gets the number of contained ID/name pairs.

Returns:
The count.

Definition at line 79 of file DeviceRegistry.cpp.

const DeviceRegistry::pair_t & DeviceRegistry::at ( size_t  index) const

Gets a device ID/name pair by index read only.

Parameters:
indexIndex of the pair to query.
Returns:
Reference to pair at given index. Valid until it is erased.
Exceptions:
.

Definition at line 85 of file DeviceRegistry.cpp.

std::string DeviceRegistry::lookup ( DeviceID::ID_t  deviceID) const

Looks up a device name by ID.

Parameters:
deviceIDID to query.
Returns:
If found, copy of device name associated with given ID; an empty string otherwise.

Definition at line 96 of file DeviceRegistry.cpp.

DeviceID::ID_t DeviceRegistry::lookup ( const std::string &  deviceName) const

Looks up a device ID by name.

Parameters:
deviceNameName to query.
Returns:
If found, copy of device ID associated with given name; 0 otherwise.

Definition at line 106 of file DeviceRegistry.cpp.


Friends And Related Function Documentation

void writeBinary ( const DeviceRegistry data,
std::ostream &  outputStream 
)
friend

Writes data from a DeviceRegistry into a binary stream.

Parameters:
dataThe DeviceRegistry to write.
outputStreamThe stream to write into.
Exceptions:
.
void readBinary ( DeviceRegistry data,
std::istream &  inputStream 
)
friend

Reads data into a DeviceRegistry from a binary stream.

Parameters:
dataThe DeviceRegistry to read into.
inputStreamThe stream to read from.
Exceptions:
.

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