[asterisk-scf-commits] asterisk-scf/integration/statereplicator.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Sep 22 10:05:55 CDT 2010


branch "master" has been updated
       via  54f4e7b9eb37e50a17ebddc5ca472bde582e3e4d (commit)
      from  747d9ed0aa4f01ed06ee4b2d17d8a1311ac25cf9 (commit)

Summary of changes:
 src/StateReplicator.h               |   59 ++++++++++++++++++++++++++++++++--
 test/MockStateReplicatorListener.h  |    4 +-
 testslice/StateReplicatorTestIf.ice |   12 +++---
 3 files changed, 63 insertions(+), 12 deletions(-)


- Log -----------------------------------------------------------------
commit 54f4e7b9eb37e50a17ebddc5ca472bde582e3e4d
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed Sep 22 10:03:37 2010 -0500

    Minor cleanup of test slices, and added comments to template
    operations.

diff --git a/src/StateReplicator.h b/src/StateReplicator.h
index d0a2464..5f4b4c0 100644
--- a/src/StateReplicator.h
+++ b/src/StateReplicator.h
@@ -16,9 +16,27 @@ namespace StateReplication
 
 /**
  * Templatization of a state replicator.  
- * NOTE: 
  *  - The state item type is assumed to have a public field named "key" which is of type "k". 
- *  - The listeners should be notified on a worker thread. 
+
+ The Replicator should implement (at a minimum) these operations:
+   interface FooStateReplicator
+   {
+     void addListener(TestStateReplicatorListener *listener);
+	  void removeListener(TestStateReplicatorListener *listener);
+	  void setState (FooStateItemSeq items);
+	  void removeState(FooKeySeq items);
+	  idempotent TestStateItemSeq getState(FooSeq itemKeys);
+	  idempotent TestStateItemSeq getAllState();
+   };
+
+ The Listener should implement (at a minimum) these operations:
+   interface FooStateReplicatorListener
+   {
+     void stateRemove(FooSeq itemKeys);
+	  void stateSet(FooStateItemSeq items);
+   };
+
+ * NOTE: - The process should be made asynchronous.  
  */
 template<typename R, typename S, typename s, typename K, typename k, typename L>  
 class StateReplicator : public R
@@ -34,7 +52,7 @@ public:
    public:
       SetStateNotice(const U& stateSeq) : mStateSeq(stateSeq) {}
       ~SetStateNotice() {}
-      void operator() (T x) {x->setStateNotice(mStateSeq);}
+      void operator() (T x) {x->stateSet(mStateSeq);}
       U mStateSeq;
    };
 
@@ -47,7 +65,7 @@ public:
    public:
       RemoveStateNotice(const V& keys) : mKeys(keys) {}
       ~RemoveStateNotice() {}
-      void operator() (T x) {x->removeStateNotice(mKeys);}
+      void operator() (T x) {x->stateRemoved(mKeys);}
       V mKeys;
    };
 
@@ -67,11 +85,19 @@ public:
    StateReplicator() {};
    virtual ~StateReplicator() {};
 
+   /**
+    * Adds a listener of state update notices. 
+    * @Override 
+    */
    void addListener(const L& listener, const Ice::Current& = ::Ice::Current())
    {
       mListeners.push_back(listener);
    }
 
+   /**
+    * Removes a listener of state update notices. 
+    * @Override 
+    */
    void removeListener(const L& listener, const Ice::Current& = ::Ice::Current())
    {
       std::vector<L>::iterator it = std::find_if(mListeners.begin(), mListeners.end(), IdentifyListener<L>(listener));
@@ -82,11 +108,17 @@ public:
       }
    }
 
+   /**
+    * Drops all listeners of state update notices.
+    */
    void clearListeners()
    {
       mListeners.clear();
    }
 
+   /**
+    * Drops all state that has previously been set. Notifies listeners. 
+    */
    void clearState()
    {
       K allIds;
@@ -101,6 +133,10 @@ public:
       mStateItemMap.clear();
    }
 
+   /**
+    * Add or update the specified state variables, and notify listeners. 
+    * @Override
+    */
    void setState(const S& items, const Ice::Current& = ::Ice::Current())
    {
       for (S::const_iterator iter = items.begin();
@@ -121,6 +157,10 @@ public:
       for_each( mListeners.begin(), mListeners.end(), SetStateNotice<L,S>(items) );
    }
 
+   /**
+    * Remove the specified state variables, and notify listeners. 
+    * @Override
+    */
    void removeState(const K& ids, const Ice::Current& = ::Ice::Current())
    {
       for (K::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
@@ -131,6 +171,10 @@ public:
       for_each(mListeners.begin(), mListeners.end(), RemoveStateNotice<L,K>(ids));
    }
 
+   /**
+    * Retrieve the state variables identifed by the key collection.  
+    * @Override
+    */
    S getState(const K& itemKeys, const Ice::Current& = ::Ice::Current())
    { 
       S results;
@@ -142,6 +186,10 @@ public:
       return results;
    }
 
+   /**
+    * Retrieve all the state variables currently known to this replicator. 
+    * @Override
+    */
    S getAllState(const Ice::Current& = ::Ice::Current())
    {
       S results;
@@ -153,6 +201,9 @@ public:
       return results;
    }
 
+   /**
+    * Returns the number of listeners currently registered with this replicator. 
+    */
    int getListenerCount()
    {
       return mListeners.size();
diff --git a/test/MockStateReplicatorListener.h b/test/MockStateReplicatorListener.h
index abaaeb6..581d066 100644
--- a/test/MockStateReplicatorListener.h
+++ b/test/MockStateReplicatorListener.h
@@ -22,13 +22,13 @@ public:
    {
    }
 
-    void removeStateNotice(const ::Ice::StringSeq& itemKeys, const ::Ice::Current& )
+    void stateRemoved(const ::Ice::StringSeq& itemKeys, const ::Ice::Current& )
     {
        mItemKeys = itemKeys;
        mRemoveStateCalled = true;
     }
 
-    void setStateNotice(const ::AsteriskSCF::StateReplicatorTest::V1::TestStateItemSeq& items, const ::Ice::Current& )
+    void stateSet(const ::AsteriskSCF::StateReplicatorTest::V1::TestStateItemSeq& items, const ::Ice::Current& )
     {
        mStateItems = items;
        mSetStateCalled = true;
diff --git a/testslice/StateReplicatorTestIf.ice b/testslice/StateReplicatorTestIf.ice
index 8b2a758..f70a92c 100644
--- a/testslice/StateReplicatorTestIf.ice
+++ b/testslice/StateReplicatorTestIf.ice
@@ -17,18 +17,18 @@ module V1
 
    interface TestStateReplicatorListener
    {
-      void removeStateNotice(Ice::StringSeq itemKeys);
-	  void setStateNotice(TestStateItemSeq items);
+      void stateRemoved(Ice::StringSeq itemKeys);
+	  void stateSet(TestStateItemSeq items);
    };
 
    interface TestStateReplicator
    {
       void addListener(TestStateReplicatorListener *listener);
-	  idempotent void removeListener(TestStateReplicatorListener *listener);
+	  void removeListener(TestStateReplicatorListener *listener);
 	  void setState (TestStateItemSeq items);
-	  idempotent void removeState(Ice::StringSeq items);
-	  TestStateItemSeq getState(Ice::StringSeq itemKeys);
-	  TestStateItemSeq getAllState();
+	  void removeState(Ice::StringSeq items);
+	  idempotent TestStateItemSeq getState(Ice::StringSeq itemKeys);
+	  idempotent TestStateItemSeq getAllState();
    };
    
    class TestStateItemFoo extends TestStateItem

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/statereplicator.git



More information about the asterisk-scf-commits mailing list