9 #ifndef ED247_CLIENT_ITERATOR 10 #define ED247_CLIENT_ITERATOR 22 template <
typename T,
typename U>
23 struct is_pair<std::pair<T, U>> : std::true_type { };
25 template<class Return, class Iterator, typename std::enable_if<!is_pair<typename Iterator::value_type>::value,
bool>::type =
true>
26 Return iterator_shared_get(Iterator& itr) {
29 template<class Return, class Iterator, typename std::enable_if<is_pair<typename Iterator::value_type>::value,
bool>::type =
true>
30 Return iterator_shared_get(Iterator& itr) {
31 return itr->second.get();
34 enum class ContextOwned { True, False };
36 template <
class CBaseList,
typename T>
39 typedef std::shared_ptr<T> container_value_t;
44 virtual bool is_context_owned() = 0;
46 virtual uint32_t size()
const = 0;
48 virtual T* get_current() = 0;
49 virtual T* get_next() = 0;
50 virtual void reset_iterator() = 0;
52 virtual void free() = 0;
55 template <
class CBaseList,
typename T,
class Container, ContextOwned context_owned = ContextOwned::False>
57 typedef typename Container::iterator iterator_t;
69 virtual bool is_context_owned() {
70 return context_owned == ContextOwned::True;
73 uint32_t size()
const override {
74 return _container->size();
78 virtual void free()
override {
79 if (_container && _container_owner)
delete _container;
87 void reset_iterator()
override {
88 _iterator = _container->end();
91 T* get_current()
override {
92 if (!_container)
return nullptr;
93 if (_iterator == _container->end())
return nullptr;
94 return iterator_shared_get<T*>(_iterator);
97 T* get_next()
override {
98 if (!_container)
return nullptr;
99 if (_iterator == _container->end()) {
100 _iterator = _container->begin();
104 return get_current();
109 _container(container), _container_owner(container_owner) {
110 _iterator = _container->end();
113 Container* _container;
114 iterator_t _iterator;
115 bool _container_owner;
Definition: ed247_client_list.h:56
Definition: ed247_client_list.h:37
Definition: ed247_channel.cpp:37
Definition: ed247_client_list.h:20