[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:18:34 CDT 2010
branch "master" has been updated
via 3f9ec8408a5fbff32828a61a96b0a72f0d586815 (commit)
from 54f4e7b9eb37e50a17ebddc5ca472bde582e3e4d (commit)
Summary of changes:
src/StateReplicator.h | 40 ++++++++++++++++++++--------------------
test/SharedTestData.h | 3 ++-
2 files changed, 22 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit 3f9ec8408a5fbff32828a61a96b0a72f0d586815
Author: Ken Hunt <ken.hunt at digium.com>
Date: Wed Sep 22 10:16:13 2010 -0500
Reduced number of template arguments required.
diff --git a/src/StateReplicator.h b/src/StateReplicator.h
index 5f4b4c0..5a4fb81 100644
--- a/src/StateReplicator.h
+++ b/src/StateReplicator.h
@@ -16,7 +16,7 @@ namespace StateReplication
/**
* Templatization of a state replicator.
- * - The state item type is assumed to have a public field named "key" which is of type "k".
+ * - The state item type is assumed to have a public field named "key" which is of type "K".
The Replicator should implement (at a minimum) these operations:
interface FooStateReplicator
@@ -38,10 +38,10 @@ namespace StateReplication
* NOTE: - The process should be made asynchronous.
*/
-template<typename R, typename S, typename s, typename K, typename k, typename L>
+template<typename R, typename S, typename K, typename L>
class StateReplicator : public R
{
-// Types: R - Replicator, S - State Item Seq, s - state item, K - Key sequence, k - Key element type, L - Listener
+// Template Types: R - Replicator, S - State item, K - Key element, L - Listener
public:
/**
* Functor for forwarding setState() notices.
@@ -121,14 +121,14 @@ public:
*/
void clearState()
{
- K allIds;
+ std::vector<K> allIds;
- for(std::map<k, s>::const_iterator it = mStateItemMap.begin(); it != mStateItemMap.end(); ++it)
+ for(std::map<K, S>::const_iterator it = mStateItemMap.begin(); it != mStateItemMap.end(); ++it)
{
allIds.push_back(it->first);
}
- for_each(mListeners.begin(), mListeners.end(), RemoveStateNotice<L,K>(allIds));
+ for_each(mListeners.begin(), mListeners.end(), RemoveStateNotice<L,std::vector<K>>(allIds));
mStateItemMap.clear();
}
@@ -137,12 +137,12 @@ public:
* Add or update the specified state variables, and notify listeners.
* @Override
*/
- void setState(const S& items, const Ice::Current& = ::Ice::Current())
+ void setState(const std::vector<S>& items, const Ice::Current& = ::Ice::Current())
{
- for (S::const_iterator iter = items.begin();
+ for (std::vector<S>::const_iterator iter = items.begin();
iter != items.end(); ++iter)
{
- std::map<k, s>::iterator mapItem = mStateItemMap.find((*iter)->key);
+ std::map<K, S>::iterator mapItem = mStateItemMap.find((*iter)->key);
if (mapItem != mStateItemMap.end())
{
@@ -154,32 +154,32 @@ public:
}
}
- for_each( mListeners.begin(), mListeners.end(), SetStateNotice<L,S>(items) );
+ for_each( mListeners.begin(), mListeners.end(), SetStateNotice<L,std::vector<S>>(items) );
}
/**
* Remove the specified state variables, and notify listeners.
* @Override
*/
- void removeState(const K& ids, const Ice::Current& = ::Ice::Current())
+ void removeState(const std::vector<K>& ids, const Ice::Current& = ::Ice::Current())
{
- for (K::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
+ for (std::vector<K>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
{
mStateItemMap.erase(*iter);
}
- for_each(mListeners.begin(), mListeners.end(), RemoveStateNotice<L,K>(ids));
+ for_each(mListeners.begin(), mListeners.end(), RemoveStateNotice<L,std::vector<K>>(ids));
}
/**
* Retrieve the state variables identifed by the key collection.
* @Override
*/
- S getState(const K& itemKeys, const Ice::Current& = ::Ice::Current())
+ std::vector<S> getState(const std::vector<K>& itemKeys, const Ice::Current& = ::Ice::Current())
{
- S results;
+ std::vector<S> results;
- for(K::const_iterator it = itemKeys.begin(); it != itemKeys.end(); ++it)
+ for(std::vector<K>::const_iterator it = itemKeys.begin(); it != itemKeys.end(); ++it)
{
results.push_back(mStateItemMap[(*it)]);
}
@@ -190,11 +190,11 @@ public:
* Retrieve all the state variables currently known to this replicator.
* @Override
*/
- S getAllState(const Ice::Current& = ::Ice::Current())
+ std::vector<S> getAllState(const Ice::Current& = ::Ice::Current())
{
- S results;
+ std::vector<S> results;
- for(std::map<k, s>::const_iterator it = mStateItemMap.begin(); it != mStateItemMap.end(); ++it)
+ for(std::map<K, S>::const_iterator it = mStateItemMap.begin(); it != mStateItemMap.end(); ++it)
{
results.push_back(it->second);
}
@@ -211,7 +211,7 @@ public:
private:
std::vector<L> mListeners;
- std::map<k, s > mStateItemMap;
+ std::map<K, S > mStateItemMap;
};
diff --git a/test/SharedTestData.h b/test/SharedTestData.h
index 4c7bf48..5a89e94 100644
--- a/test/SharedTestData.h
+++ b/test/SharedTestData.h
@@ -15,7 +15,8 @@ namespace AsteriskSCF
{
namespace StateReplicatorTest
{
- typedef AsteriskSCF::StateReplication::StateReplicator<AsteriskSCF::StateReplicatorTest::V1::TestStateReplicator, AsteriskSCF::StateReplicatorTest::V1::TestStateItemSeq, AsteriskSCF::StateReplicatorTest::V1::TestStateItemPtr, Ice::StringSeq, std::string, AsteriskSCF::StateReplicatorTest::V1::TestStateReplicatorListenerPrx> TestReplicatorImpl;
+ // typedef AsteriskSCF::StateReplication::StateReplicator<AsteriskSCF::StateReplicatorTest::V1::TestStateReplicator, AsteriskSCF::StateReplicatorTest::V1::TestStateItemSeq, AsteriskSCF::StateReplicatorTest::V1::TestStateItemPtr, Ice::StringSeq, std::string, AsteriskSCF::StateReplicatorTest::V1::TestStateReplicatorListenerPrx> TestReplicatorImpl;
+ typedef AsteriskSCF::StateReplication::StateReplicator<AsteriskSCF::StateReplicatorTest::V1::TestStateReplicator, AsteriskSCF::StateReplicatorTest::V1::TestStateItemPtr, std::string, AsteriskSCF::StateReplicatorTest::V1::TestStateReplicatorListenerPrx> TestReplicatorImpl;
typedef IceUtil::Handle<TestReplicatorImpl> TestReplicatorImplPtr;
/**
-----------------------------------------------------------------------
--
asterisk-scf/integration/statereplicator.git
More information about the asterisk-scf-commits
mailing list