1#ifndef NE_STL_INCLUDENE_STL_DELEGATOR_STORAGE_H
2#define NE_STL_INCLUDENE_STL_DELEGATOR_STORAGE_H
23 for (
auto& iter : _temp_callback_list) {
24 if (iter !=
nullptr) {
40template <
typename t_delegator>
50 auto _new_delegate = nstd::make_shared<t_delegator>(_delegate);
51 size_t _new_delegate_id = (size_t)(_new_delegate.get());
59 if (!_weak_flag.expired()) {
60 nstd::lock_guard auto_lock(lock_);
61 auto it = std::find_if(element_list_.begin(), element_list_.end(), [&](const pair<size_t, nstd::shared_ptr<t_delegator>>& item) {
62 return item.first == _new_delegate_id;
64 if (it != element_list_.end())
65 element_list_.erase(it);
69 inline operator bool()
const {
71 return !element_list_.empty();
75 template <
typename... t_params>
80 _element_list = element_list_;
82 for (
auto& it : _element_list) {
83 if (it.second !=
nullptr) {
84 (*it.second)(params...);
94template <
typename t_delegator>
Definition: ne_stl_continuous_container.h:15
Definition: ne_stl_delegator_storage.h:41
void operator()(t_params... params)
Definition: ne_stl_delegator_storage.h:76
bool operator==(std::nullptr_t) const
Definition: ne_stl_delegator_storage.h:73
void clear()
Definition: ne_stl_delegator_storage.h:45
nstd::spinlock lock_
Definition: ne_stl_delegator_storage.h:90
bool operator!=(std::nullptr_t) const
Definition: ne_stl_delegator_storage.h:74
_delegator_storage()
Definition: ne_stl_delegator_storage.h:43
~_delegator_storage()
Definition: ne_stl_delegator_storage.h:44
unregister_delegate_t add_delegate(const t_delegator &_delegate, bool exclusive=false)
Definition: ne_stl_delegator_storage.h:49
nstd::vector< pair< size_t, nstd::shared_ptr< t_delegator > > > element_list_
Definition: ne_stl_delegator_storage.h:91
nstd::weak_semantics_supporter weak_flag_
Definition: ne_stl_delegator_storage.h:92
Definition: ne_stl_spinlock.h:61
Definition: ne_stl_spinlock.h:44
Definition: ne_stl_delegator_storage.h:12
nstd::vector< unregister_delegate_t > callback_list_
Definition: ne_stl_delegator_storage.h:36
_unregister_delegator()=default
void add_delegate(const unregister_delegate_t &_delegate)
Definition: ne_stl_delegator_storage.h:29
~_unregister_delegator()
Definition: ne_stl_delegator_storage.h:15
void clear()
Definition: ne_stl_delegator_storage.h:16
nstd::spinlock callback_list_lock_
Definition: ne_stl_delegator_storage.h:35
Definition: ne_stl_any.h:7
pair< first_type, second_type > make_pair(const first_type &_first, const second_type &_second)
Definition: ne_stl_value_def.h:65
unsigned char bool
Definition: stdbool.h:25
Definition: ne_stl_bind.h:11
Definition: ne_stl_bind.h:13
nstd::weak_ptr< nstd::weak_flag > get_weak_flag()
Definition: ne_stl_bind.h:15
Definition: ne_stl_bind.h:132