#include <DBManager.hh>
Inherits DBBase.
List of all members.
Detailed Description
Manager for a database (blackboard) operations.
This class implements a database manager, DBManager. This subclass of DBBase also launches a protocol thread, which sits on a stream sink waiting for protocol messages. These messages are queries for access to the database. Remote clients can sign up to get changes in database entries or to make changes in database entries.
One piece of bookkeeping (and example of the awkwardness of implementing a client/server relationship with RHexCom) is that the manager caches a list of the response sources to use in responding to messages on the protocol sink. Each remote client that sends a protocol message has exactly one response source created and cached in the response source list. If a remote client sends a message, and we see in the appropriate response source (source host/port matches) that it was created for a client with a different ID (i.e., the old client died, and this is a new client with the same host/port), then the manager must find and invalidate all of the queries the dead client sent in order to keep the books properly.
The protocol thread does not get kicked off until the user calls the "enable" method. This allows the user of the database manager to create the manager, add a bunch of entries, and then enable the manager. Thus the application does not have to worry if remote clients will sign up for entries in between the time the manager is created and the time the user adds the appropriate entries.
|
Public Member Functions |
| DBManager (CommManager *mgr, com_id_t id, int fundamental_rate, int priority=-1) |
| ~DBManager () |
DBEntry * | enter (const char *name, int max_size, const char *description, bool local_write_only=false) |
DBEntry * | lookup (const char *name, int max_size, const char *description) const |
DBEntry * | enterInt (const char *name, bool local_write_only=false) |
DBEntry * | enterDouble (const char *name, bool local_write_only=false) |
DBEntry * | lookupInt (const char *name) |
DBEntry * | lookupDouble (const char *name) |
void | enable () |
void | disable () |
Related Functions |
(Note that these are not member functions.)
|
| ENTER(name, type) |
| LOOKUP(name, type) |
Constructor & Destructor Documentation
DBManager::DBManager |
( |
CommManager * |
mgr, |
|
|
com_id_t |
id, |
|
|
int |
fundamental_rate, |
|
|
int |
priority = -1 |
|
) |
|
|
|
The constructor creates a database manager. "mgr", "fundamental_rate", and "priority" are passed to the superclass. When the protocol thread is kicked off by the enable method, it will use the same priority as the monitor thread and will create a stream sink with the ID id. |
|
The destructor shuts down the threads properly and clear out all database memory. |
Member Function Documentation
void DBManager::disable |
( |
|
) |
|
|
|
This method shuts down the protocol thread. |
void DBManager::enable |
( |
|
) |
|
|
|
This method launches the protocol thread. Before this method is invoked, all incoming messages from remote clients will be ignored. |
DBEntry* DBManager::enter |
( |
const char * |
name, |
|
|
int |
max_size, |
|
|
const char * |
description, |
|
|
bool |
local_write_only = false |
|
) |
|
|
|
This method creates an entry. If an entry by that name already exists and is compatible with the maximum size and description entered here, it just returns that pre-existing entry. If the existing entry is incompatible with "max_size" and "description", it returns NULL. If no entry exists by that name, it creates the appropriate entry and returns it. If "local_write_only" is true, only local writing to the entry is allowed, i.e., remote clients will not be allowed to write to this entry. |
DBEntry* DBManager::lookup |
( |
const char * |
name, |
|
|
int |
max_size, |
|
|
const char * |
description |
|
) |
const |
|
|
This method looks up an entry. If the entry already exists and is compatible with max_size and description, it just returns it. If the entry is incompatible it returns NULL. |
Friends And Related Function Documentation
ENTER |
( |
name, |
|
|
type |
|
) |
[related]
|
|
|
This is a convenience macro for creating an entry named "name" which will contain data of type "type". The size and description of the entry will be extracted using macro magic from the type name type. |
LOOKUP |
( |
name, |
|
|
type |
|
) |
[related]
|
|
|
This is a convenience macro for looking up an entry named "name" which contains data of type "type". The size and description of the entry will be extracted using macro magic from the type name type. |
RHexLib Reference Documentation