#include <utility>
#include "stg/common.h"
-#include "stg/plugin_creator.h"
#include "smux.h"
#include "utils.h"
namespace
{
-PLUGIN_CREATOR<SMUX> smc;
bool SPrefixLess(const Sensors::value_type & a,
const Sensors::value_type & b)
}
-extern "C" PLUGIN * GetPlugin();
-
-PLUGIN * GetPlugin()
+extern "C" STG::Plugin* GetPlugin()
{
-return smc.GetPlugin();
+ static SMUX plugin;
+ return &plugin;
}
SMUX_SETTINGS::SMUX_SETTINGS()
password()
{}
-int SMUX_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
+int SMUX_SETTINGS::ParseSettings(const STG::ModuleSettings & s)
{
-PARAM_VALUE pv;
-std::vector<PARAM_VALUE>::const_iterator pvi;
+STG::ParamValue pv;
+std::vector<STG::ParamValue>::const_iterator pvi;
int p;
pv.param = "Port";
}
SMUX::SMUX()
- : PLUGIN(),
- users(NULL),
+ : users(NULL),
tariffs(NULL),
admins(NULL),
services(NULL),
corporations(NULL),
traffcounter(NULL),
- errorStr(),
- smuxSettings(),
- settings(),
- thread(),
- mutex(),
running(false),
stopped(true),
needReconnect(false),
lastReconnectTry(0),
reconnectTimeout(1),
sock(-1),
- smuxHandlers(),
- pdusHandlers(),
- sensors(),
- tables(),
- notifiers(),
addUserNotifier(*this),
delUserNotifier(*this),
addDelTariffNotifier(*this),
- logger(GetPluginLogger(GetStgLogger(), "smux"))
+ logger(STG::PluginLogger::get("smux"))
{
pthread_mutex_init(&mutex, NULL);
return 0;
}
-int SMUX::Reload()
+int SMUX::Reload(const STG::ModuleSettings & /*ms*/)
{
if (Stop())
return -1;
return true;
}
-void SMUX::SetNotifier(USER_PTR userPtr)
+void SMUX::SetNotifier(UserPtr userPtr)
{
notifiers.push_back(CHG_AFTER_NOTIFIER(*this, userPtr));
-userPtr->GetProperty().tariffName.AddAfterNotifier(¬ifiers.back());
+userPtr->GetProperties().tariffName.AddAfterNotifier(¬ifiers.back());
}
-void SMUX::UnsetNotifier(USER_PTR userPtr)
+void SMUX::UnsetNotifier(UserPtr userPtr)
{
std::list<CHG_AFTER_NOTIFIER>::iterator it = notifiers.begin();
while (it != notifiers.end())
{
if (it->GetUserPtr() == userPtr)
{
- userPtr->GetProperty().tariffName.DelAfterNotifier(&(*it));
+ userPtr->GetProperties().tariffName.DelAfterNotifier(&(*it));
notifiers.erase(it);
break;
}
int h = users->OpenSearch();
assert(h && "USERS::OpenSearch is always correct");
-USER_PTR u;
+UserPtr u;
while (!users->SearchNext(h, &u))
SetNotifier(u);
std::list<CHG_AFTER_NOTIFIER>::iterator it(notifiers.begin());
while (it != notifiers.end())
{
- it->GetUserPtr()->GetProperty().tariffName.DelAfterNotifier(&(*it));
+ it->GetUserPtr()->GetProperties().tariffName.DelAfterNotifier(&(*it));
++it;
}
notifiers.clear();