Skip to content

Commit

Permalink
Refactored the name of Iterator class to CommonIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Nov 11, 2022
1 parent 7f2e12a commit 38014a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
40 changes: 6 additions & 34 deletions src/credentials/GroupDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CHIPMemString.h>
#include <lib/support/Iterator.h>
#include <lib/support/CommonIterator.h>

namespace chip {
namespace Credentials {
Expand Down Expand Up @@ -187,39 +187,11 @@ class GroupDataProvider
virtual void OnGroupRemoved(FabricIndex fabric_index, const GroupInfo & old_group) = 0;
};

/**
* Template used to iterate the stored group data
*/
template <typename T>
class Iterator
{
public:
virtual ~Iterator() = default;
/**
* @retval The number of entries in total that will be iterated.
*/
virtual size_t Count() = 0;
/**
* @param[out] item Value associated with the next element in the iteration.
* @retval true if the next entry is successfully retrieved.
* @retval false if no more entries can be found.
*/
virtual bool Next(T & item) = 0;
/**
* Release the memory allocated by this iterator.
* Must be called before the pointer goes out of scope.
*/
virtual void Release() = 0;

protected:
Iterator() = default;
};

using GroupInfoIterator = Iterator<GroupInfo>;
using GroupKeyIterator = Iterator<GroupKey>;
using EndpointIterator = Iterator<GroupEndpoint>;
using KeySetIterator = Iterator<KeySet>;
using GroupSessionIterator = Iterator<GroupSession>;
using GroupInfoIterator = CommonIterator<GroupInfo>;
using GroupKeyIterator = CommonIterator<GroupKey>;
using EndpointIterator = CommonIterator<GroupEndpoint>;
using KeySetIterator = CommonIterator<KeySet>;
using GroupSessionIterator = CommonIterator<GroupSession>;

GroupDataProvider(uint16_t maxGroupsPerFabric = CHIP_CONFIG_MAX_GROUPS_PER_FABRIC,
uint16_t maxGroupKeysPerFabric = CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace chip {
* Template used to generate a custom iterator
*/
template <typename T>
class Iterator
class CommonIterator
{
public:
virtual ~Iterator() = default;
virtual ~CommonIterator() = default;
/**
* @retval The number of entries in total that will be iterated.
*/
Expand All @@ -49,7 +49,7 @@ class Iterator
virtual void Release() = 0;

protected:
Iterator() = default;
CommonIterator() = default;
};

} // namespace chip

0 comments on commit 38014a8

Please sign in to comment.