handle(0),
searchDescriptors(),
onAddNotifiers(),
- onDelNotifiers()
+ onDelNotifiers(),
+ onAddNotifiersImpl(),
+ onDelNotifiersImpl()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
AddUserIntoIndexes(users.begin());
SetUserNotifiers(users.begin());
-// õ×ÅÄÏÍÌÑÅÍ ×ÓÅÈ ÖÅÌÁÀÝÉÈ, ÞÔÏ ÄÏÂÁ×ÌÅÎ ÎÏ×ÙÊ ÐÏÌØÚÏ×ÁÔÅÌØ
-set<NOTIFIER_BASE<USER_PTR> *>::iterator ni = onAddNotifiers.begin();
-while (ni != onAddNotifiers.end())
{
- (*ni)->Notify(&users.front());
- ++ni;
+ // Fire all "on add" notifiers
+ set<NOTIFIER_BASE<USER_PTR> *>::iterator ni = onAddNotifiers.begin();
+ while (ni != onAddNotifiers.end())
+ {
+ (*ni)->Notify(&users.front());
+ ++ni;
+ }
+ }
+
+ {
+ // Fire all "on add" implementation notifiers
+ set<NOTIFIER_BASE<USER_IMPL_PTR> *>::iterator ni = onAddNotifiersImpl.begin();
+ while (ni != onAddNotifiersImpl.end())
+ {
+ (*ni)->Notify(&users.front());
+ ++ni;
+ }
}
return 0;
}
}
-set<NOTIFIER_BASE<USER_PTR> *>::iterator ni = onDelNotifiers.begin();
-while (ni != onDelNotifiers.end())
{
- (*ni)->Notify(&(*u));
- ++ni;
+ set<NOTIFIER_BASE<USER_PTR> *>::iterator ni = onDelNotifiers.begin();
+ while (ni != onDelNotifiers.end())
+ {
+ (*ni)->Notify(&(*u));
+ ++ni;
+ }
+ }
+
+ {
+ set<NOTIFIER_BASE<USER_IMPL_PTR> *>::iterator ni = onDelNotifiersImpl.begin();
+ while (ni != onDelNotifiersImpl.end())
+ {
+ (*ni)->Notify(&(*u));
+ ++ni;
+ }
}
{
}
//-----------------------------------------------------------------------------
int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_PTR * usr) const
+{
+ USER_IMPL * ptr = NULL;
+ if (FindByIPIdx(ip, &ptr))
+ return -1;
+ *usr = ptr;
+ return 0;
+}
+//-----------------------------------------------------------------------------
+int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_IMPL ** usr) const
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE<USER_PTR> * n)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-//printfd(__FILE__, "DelNotifierUserAdd\n");
onAddNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
onDelNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
+void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+onAddNotifiersImpl.insert(n);
+}
+//-----------------------------------------------------------------------------
+void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+onAddNotifiersImpl.erase(n);
+}
+//-----------------------------------------------------------------------------
+void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+onDelNotifiersImpl.insert(n);
+}
+//-----------------------------------------------------------------------------
+void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+onDelNotifiersImpl.erase(n);
+}
+//-----------------------------------------------------------------------------
int USERS_IMPL::OpenSearch()
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
}
//-----------------------------------------------------------------------------
int USERS_IMPL::SearchNext(int h, USER_PTR * user)
+{
+ USER_IMPL * ptr = NULL;
+ if (SearchNext(h, &ptr))
+ return -1;
+ *user = ptr;
+ return 0;
+}
+//-----------------------------------------------------------------------------
+int USERS_IMPL::SearchNext(int h, USER_IMPL ** user)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
void AddNotifierUserDel(NOTIFIER_BASE<USER_PTR> *);
void DelNotifierUserDel(NOTIFIER_BASE<USER_PTR> *);
+ void AddNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> *);
+ void DelNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> *);
+
+ void AddNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> *);
+ void DelNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> *);
+
int Add(const std::string & login, const ADMIN * admin);
void Del(const std::string & login, const ADMIN * admin);
int GetUserNum() const;
int FindByIPIdx(uint32_t ip, USER_PTR * user) const;
+ int FindByIPIdx(uint32_t ip, USER_IMPL ** user) const;
bool IsIPInIndex(uint32_t ip) const;
int OpenSearch();
int SearchNext(int handler, USER_PTR * user);
+ int SearchNext(int handler, USER_IMPL ** user);
int CloseSearch(int handler);
int Start();
std::set<NOTIFIER_BASE<USER_PTR>*> onAddNotifiers;
std::set<NOTIFIER_BASE<USER_PTR>*> onDelNotifiers;
+ std::set<NOTIFIER_BASE<USER_IMPL_PTR>*> onAddNotifiersImpl;
+ std::set<NOTIFIER_BASE<USER_IMPL_PTR>*> onDelNotifiersImpl;
};
//-----------------------------------------------------------------------------
inline