/*
* Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
-/*
- $Revision: 1.13 $
- $Date: 2010/03/04 12:22:41 $
- $Author: faust $
+ * Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
#ifndef PLUGIN_RUNNER_H
#define PLUGIN_RUNNER_H
-#include <pthread.h>
+
+#include "stg/plugin.h"
+#include "stg/module_settings.h"
+#include "stg/os_int.h"
+
#include <string>
+#include <stdexcept>
-#include "base_plugin.h"
-#include "base_settings.h"
-#include "traffcounter.h"
-#include "tariffs.h"
-#include "admins.h"
-#include "users.h"
+class SETTINGS;
+class ADMINS;
+class TARIFFS;
+class USERS;
+class SERVICES;
+class CORPORATIONS;
+class TRAFFCOUNTER;
+class STORE;
-using namespace std;
//-----------------------------------------------------------------------------
-class PLUGIN_RUNNER
-{
+class PLUGIN_RUNNER {
public:
- PLUGIN_RUNNER(const string & pluginFileName,
+ struct Error : public std::runtime_error {
+ Error(const std::string & msg) : runtime_error(msg) {}
+ };
+
+ PLUGIN_RUNNER(const std::string & pluginFileName,
const MODULE_SETTINGS & ms,
- ADMINS * admins,
- TARIFFS * tariffs,
- USERS * users,
- TRAFFCOUNTER * tc,
- BASE_STORE * store,
- const SETTINGS * s);
- PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue);
+ ADMINS & admins,
+ TARIFFS & tariffs,
+ USERS & users,
+ SERVICES & services,
+ CORPORATIONS & corporations,
+ TRAFFCOUNTER & traffcounter,
+ STORE & store,
+ const SETTINGS & settings);
~PLUGIN_RUNNER();
- PLUGIN_RUNNER & operator=(const PLUGIN_RUNNER & rvalue);
-
int Start();
int Stop();
int Reload();
int Restart();
- bool IsRunning();
-
- const string & GetStrError() const;
- BASE_PLUGIN * GetPlugin();
- const string & GetFileName() const { return pluginFileName; };
+ bool IsRunning() { return m_plugin.IsRunning(); }
- int Load();
- int Unload();
+ const std::string & GetStrError() const { return errorStr; }
+ PLUGIN & GetPlugin() { return m_plugin; }
+ const std::string & GetFileName() const { return pluginFileName; }
- uint16_t GetStartPosition() const;
- uint16_t GetStopPosition() const;
+ uint16_t GetStartPosition() const { return m_plugin.GetStartPosition(); }
+ uint16_t GetStopPosition() const { return m_plugin.GetStopPosition(); }
private:
- string pluginFileName;
- string pluginSettingFileName;
-
- BASE_PLUGIN * plugin;
- int isPluginLoaded;
- string errorStr;
+ PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue);
+ PLUGIN_RUNNER & operator=(const PLUGIN_RUNNER & rvalue);
+ PLUGIN & Load(const MODULE_SETTINGS & ms,
+ ADMINS & admins,
+ TARIFFS & tariffs,
+ USERS & users,
+ SERVICES & services,
+ CORPORATIONS & corporations,
+ TRAFFCOUNTER & traffcounter,
+ STORE & store,
+ const SETTINGS & settings);
+
+ std::string pluginFileName;
void * libHandle;
- bool isRunning;
- ADMINS * admins;
- TARIFFS * tariffs;
- USERS * users;
- BASE_STORE * store;
- TRAFFCOUNTER * traffCnt;
- const SETTINGS * stgSettings;
- MODULE_SETTINGS modSettings;
+ PLUGIN & m_plugin;
+ std::string errorStr;
};
//-----------------------------------------------------------------------------
#endif //PLUGIN_RUNNER_H
-
-