Update of /cvsroot/playerstage/code/player/server/drivers/blackboard/localbb
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv869/server/drivers/blackboard/localbb
Modified Files:
localbb.cpp
Log Message:
changed blackboard structure to have a group
Index: localbb.cpp
===================================================================
RCS file:
/cvsroot/playerstage/code/player/server/drivers/blackboard/localbb/localbb.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** localbb.cpp 21 Jan 2008 02:58:45 -0000 1.5
--- localbb.cpp 30 Jan 2008 02:06:46 -0000 1.6
***************
*** 103,111 ****
typedef struct BlackBoardEntry
{
! /** Constructor. Sets key to an empty string. Data should be
automatically set to empty values. */
! BlackBoardEntry() { key = ""; }
/** Entry label */
string key;
/** Entry data */
EntryData data;
--- 103,113 ----
typedef struct BlackBoardEntry
{
! /** Constructor. Sets key to an empty string and group_id to 0. Data
should be automatically set to empty values. */
! BlackBoardEntry() { key = ""; group_id = 0; }
/** Entry label */
string key;
+ /** Secondary identifier. */
+ uint32_t group_id;
/** Entry data */
EntryData data;
***************
*** 129,132 ****
--- 131,136 ----
result.key = new char[result.key_count]; //strdup(entry.key.c_str());
memcpy(result.key, entry.key.c_str(), result.key_count);
+ assert(strlen(result.key) > 0);
+ result.group_id = entry.group_id;
result.data_count = entry.data.data_count;
result.data = new uint8_t[result.data_count];
***************
*** 144,147 ****
--- 148,152 ----
assert(entry.key != NULL);
result.key = string(entry.key);
+ result.group_id = entry.group_id;
result.data.data_count = entry.data_count;
result.data.data = new uint8_t[result.data.data_count];
***************
*** 214,225 ****
/** @brief Add the key and queue combination to the listeners
hash-map and return the entry for the key.
* @param key Entry key.
* @param resp_queue Player response queue of the subscriber.
*/
! BlackBoardEntry SubscribeKey(const string &key, const
QueuePointer &resp_queue);
/** @brief Remove the key and queue combination from the
listeners hash-map.
* @param key Entry key.
* @param qp Player response queue of the subscriber.
*/
! void UnsubscribeKey(const string &key, const QueuePointer &qp);
/** @brief Set the entry in the entries hashmap. *
* @param entry BlackBoardEntry that must be put in the hashmap.
--- 219,232 ----
/** @brief Add the key and queue combination to the listeners
hash-map and return the entry for the key.
* @param key Entry key.
+ * @param group_id Second identifier.
* @param resp_queue Player response queue of the subscriber.
*/
! BlackBoardEntry SubscribeKey(const string &key, uint32_t
group_id, const QueuePointer &resp_queue);
/** @brief Remove the key and queue combination from the
listeners hash-map.
* @param key Entry key.
+ * @param group_id Second identifier.
* @param qp Player response queue of the subscriber.
*/
! void UnsubscribeKey(const string &key, uint32_t group_id, const
QueuePointer &qp);
/** @brief Set the entry in the entries hashmap. *
* @param entry BlackBoardEntry that must be put in the hashmap.
***************
*** 235,241 ****
// Internal blackboard data
/** Map of labels to entry data. */
! map<string, BlackBoardEntry> entries;
/** Map of labels to listening queues. */
! map<string, vector<QueuePointer> > listeners;
};
--- 242,248 ----
// Internal blackboard data
/** Map of labels to entry data. */
! map<uint32_t, map<string, BlackBoardEntry> > entries;
/** Map of labels to listening queues. */
! map<uint32_t, map<string, vector<QueuePointer> > > listeners;
};
***************
*** 317,321 ****
// Add the device to the listeners map
player_blackboard_entry_t *request =
reinterpret_cast<player_blackboard_entry_t*>(data);
! BlackBoardEntry current_value = SubscribeKey(request->key , resp_queue);
// Get the entry for the given key
--- 324,328 ----
// Add the device to the listeners map
player_blackboard_entry_t *request =
reinterpret_cast<player_blackboard_entry_t*>(data);
! BlackBoardEntry current_value = SubscribeKey(request->key,
request->group_id, resp_queue);
// Get the entry for the given key
***************
*** 354,358 ****
// Remove the device from the listeners map
player_blackboard_entry_t *request =
reinterpret_cast<player_blackboard_entry_t*>(data);
! UnsubscribeKey(request->key, resp_queue);
// Send back an empty ack
--- 361,365 ----
// Remove the device from the listeners map
player_blackboard_entry_t *request =
reinterpret_cast<player_blackboard_entry_t*>(data);
! UnsubscribeKey(request->key, request->group_id, resp_queue);
// Send back an empty ack
***************
*** 382,386 ****
// Send out update events to other listening devices
! vector<QueuePointer> &devices = listeners[entry.key];
for (vector<QueuePointer>::iterator itr=devices.begin(); itr !=
devices.end(); itr++)
{
--- 389,394 ----
// Send out update events to other listening devices
! vector<QueuePointer> &devices = listeners[entry.group_id][entry.key];
!
for (vector<QueuePointer>::iterator itr=devices.begin(); itr !=
devices.end(); itr++)
{
***************
*** 409,420 ****
////////////////////////////////////////////////////////////////////////////////
// Add a device to the listener list for a key. Return the current value of
the entry.
! BlackBoardEntry LocalBB::SubscribeKey(const string &key, const QueuePointer
&resp_queue)
{
! listeners[key].push_back(resp_queue);
! BlackBoardEntry entry = entries[key];
if (entry.key == "")
{
entry.key = key;
}
return entry;
}
--- 417,429 ----
////////////////////////////////////////////////////////////////////////////////
// Add a device to the listener list for a key. Return the current value of
the entry.
! BlackBoardEntry LocalBB::SubscribeKey(const string &key, uint32_t group_id,
const QueuePointer &resp_queue)
{
! listeners[group_id][key].push_back(resp_queue);
! BlackBoardEntry entry = entries[group_id][key];
if (entry.key == "")
{
entry.key = key;
}
+ entry.group_id = group_id;
return entry;
}
***************
*** 422,428 ****
////////////////////////////////////////////////////////////////////////////////
// Remove a device from the listener list for a key.
! void LocalBB::UnsubscribeKey(const string &key, const QueuePointer &qp)
{
! vector<QueuePointer> &devices = listeners[key];
for (vector<QueuePointer>::iterator itr = devices.begin(); itr !=
devices.end(); itr++)
--- 431,437 ----
////////////////////////////////////////////////////////////////////////////////
// Remove a device from the listener list for a key.
! void LocalBB::UnsubscribeKey(const string &key, uint32_t group_id, const
QueuePointer &qp)
{
! vector<QueuePointer> &devices = listeners[group_id][key];
for (vector<QueuePointer>::iterator itr = devices.begin(); itr !=
devices.end(); itr++)
***************
*** 440,444 ****
void LocalBB::SetEntry(const BlackBoardEntry &entry)
{
! entries[entry.key] = entry;
}
--- 449,453 ----
void LocalBB::SetEntry(const BlackBoardEntry &entry)
{
! entries[entry.group_id][entry.key] = entry;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit