Update of /cvsroot/playerstage/code/player/server/drivers/blackboard/localbb
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28583/server/drivers/blackboard/localbb

Modified Files:
        localbb.cpp 
Log Message:
changed blackboard interface to use a string group id instead of an integer


Index: localbb.cpp
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/blackboard/localbb/localbb.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** localbb.cpp 30 Jan 2008 02:06:46 -0000      1.6
--- localbb.cpp 6 Feb 2008 19:38:36 -0000       1.7
***************
*** 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;
--- 103,113 ----
  typedef struct BlackBoardEntry
  {
!       /** Constructor. Sets key and group to empty strings. Data should be 
automatically set to empty values. */
!   BlackBoardEntry() { key = ""; group = ""; }
  
    /** Entry label */
    string key;
    /** Secondary identifier. */
!   string group;
    /** Entry data */
    EntryData data;
***************
*** 126,136 ****
    player_blackboard_entry_t result;
    memset(&result, 0, sizeof(player_blackboard_entry_t));
    result.type = entry.data.type;
    result.subtype = entry.data.subtype;
    result.key_count = strlen(entry.key.c_str()) + 1;
    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];
--- 126,143 ----
    player_blackboard_entry_t result;
    memset(&result, 0, sizeof(player_blackboard_entry_t));
+   
    result.type = entry.data.type;
    result.subtype = entry.data.subtype;
+ 
    result.key_count = strlen(entry.key.c_str()) + 1;
    result.key = new char[result.key_count]; //strdup(entry.key.c_str());
    memcpy(result.key, entry.key.c_str(), result.key_count);
!   assert(result.key_count > 0);
! 
!   result.group_count = strlen(entry.group.c_str()) + 1;
!   result.group = new char[result.group_count];
!   memcpy(result.group, entry.group.c_str(), result.group_count);
!   assert(result.group_count > 0);
!   
    result.data_count = entry.data.data_count;
    result.data = new uint8_t[result.data_count];
***************
*** 146,152 ****
    result.data.type = entry.type;
    result.data.subtype = entry.subtype;
-   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];
--- 153,158 ----
    result.data.type = entry.type;
    result.data.subtype = entry.subtype;
    result.key = string(entry.key);
!   result.group = string(entry.group);
    result.data.data_count = entry.data_count;
    result.data.data = new uint8_t[result.data.data_count];
***************
*** 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.
--- 225,238 ----
                /** @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 Second identifier.
                 * @param resp_queue Player response queue of the subscriber. 
                 */
!               BlackBoardEntry SubscribeKey(const string &key, const string 
&group, const QueuePointer &resp_queue);
                /** @brief Remove the key and queue combination from the 
listeners hash-map.
                 * @param key Entry key.
!                * @param group Second identifier.
                 * @param qp Player response queue of the subscriber. 
                 */
!               void UnsubscribeKey(const string &key, const string &group, 
const QueuePointer &qp);
                /** @brief Set the entry in the entries hashmap. *
                 * @param entry BlackBoardEntry that must be put in the hashmap.
***************
*** 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;
  };
  
--- 248,256 ----
                // Internal blackboard data
                /** Map of labels to entry data. */
!               //map<group, map<key, entry> >
!               map<string, map<string, BlackBoardEntry> > entries;
                /** Map of labels to listening queues. */
!               //map<group, map<key, vector<device queue> > >
!               map<string, map<string, vector<QueuePointer> > > listeners;
  };
  
***************
*** 324,332 ****
        // 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
        player_blackboard_entry_t response = 
ToPlayerBlackBoardEntry(current_value);
!       size_t response_size = sizeof(player_blackboard_entry_t) + 
response.key_count + response.data_count;
  
        // Publish the blackboard entry
--- 332,340 ----
        // 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, resp_queue);
  
        // Get the entry for the given key
        player_blackboard_entry_t response = 
ToPlayerBlackBoardEntry(current_value);
!       size_t response_size = sizeof(player_blackboard_entry_t) + 
response.key_count + response.group_count + response.data_count;
  
        // Publish the blackboard entry
***************
*** 344,347 ****
--- 352,359 ----
                delete [] response.key;
        }
+       if (response.group)
+       {
+               delete [] response.group;
+       }
        if (response.data)
        {
***************
*** 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
--- 373,377 ----
        // Remove the device from the listeners map
        player_blackboard_entry_t *request = 
reinterpret_cast<player_blackboard_entry_t*>(data);
!       UnsubscribeKey(request->key, request->group, resp_queue);
  
        // Send back an empty ack
***************
*** 389,393 ****
        
        // 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++)
--- 401,405 ----
        
        // Send out update events to other listening devices
!       vector<QueuePointer> &devices = listeners[entry.group][entry.key];
  
        for (vector<QueuePointer>::iterator itr=devices.begin(); itr != 
devices.end(); itr++)
***************
*** 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;
  }
--- 429,441 ----
  
////////////////////////////////////////////////////////////////////////////////
  // Add a device to the listener list for a key. Return the current value of 
the entry.
! BlackBoardEntry LocalBB::SubscribeKey(const string &key, const string &group, 
const QueuePointer &resp_queue)
  {
!       listeners[group][key].push_back(resp_queue);
!       BlackBoardEntry entry = entries[group][key];
        if (entry.key == "")
        {
                entry.key = key;
        }
!       entry.group = group;
        return entry;
  }
***************
*** 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++)
--- 443,449 ----
  
////////////////////////////////////////////////////////////////////////////////
  // Remove a device from the listener list for a key.
! void LocalBB::UnsubscribeKey(const string &key, const string &group, const 
QueuePointer &qp)
  {
!       vector<QueuePointer> &devices = listeners[group][key];
  
        for (vector<QueuePointer>::iterator itr = devices.begin(); itr != 
devices.end(); itr++)
***************
*** 449,453 ****
  void LocalBB::SetEntry(const BlackBoardEntry &entry)
  {
!       entries[entry.group_id][entry.key] = entry;
  }
  
--- 461,465 ----
  void LocalBB::SetEntry(const BlackBoardEntry &entry)
  {
!       entries[entry.group][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

Reply via email to