]> git.stg.codes - stg.git/blob - projects/stargazer/plugin_runner.h
Set services and corps to plugins
[stg.git] / projects / stargazer / plugin_runner.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  */
20
21 /*
22  $Revision: 1.13 $
23  $Date: 2010/03/04 12:22:41 $
24  $Author: faust $
25  */
26
27 #ifndef PLUGIN_RUNNER_H
28 #define PLUGIN_RUNNER_H
29
30 #include <string>
31
32 #include "stg/module_settings.h"
33 #include "stg/plugin.h"
34 #include "stg/os_int.h"
35
36 class SETTINGS_IMPL;
37 class ADMINS_IMPL;
38 class TARIFFS_IMPL;
39 class USERS_IMPL;
40 class SERVICES_IMPL;
41 class CORPORATIONS_IMPL;
42 class TRAFFCOUNTER;
43 class STORE;
44
45 //-----------------------------------------------------------------------------
46 class PLUGIN_RUNNER {
47 public:
48     PLUGIN_RUNNER(const std::string & pluginFileName,
49                   const MODULE_SETTINGS & ms,
50                   ADMINS_IMPL * admins,
51                   TARIFFS_IMPL * tariffs,
52                   USERS_IMPL * users,
53                   SERVICES_IMPL * services,
54                   CORPORATIONS_IMPL * corporations,
55                   TRAFFCOUNTER * tc,
56                   STORE * store,
57                   const SETTINGS_IMPL * s);
58     PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue);
59     ~PLUGIN_RUNNER();
60
61     PLUGIN_RUNNER & operator=(const PLUGIN_RUNNER & rvalue);
62
63     int             Start();
64     int             Stop();
65     int             Reload();
66     int             Restart();
67     bool            IsRunning();
68
69     const std::string & GetStrError() const { return errorStr; }
70     PLUGIN *        GetPlugin();
71     const std::string & GetFileName() const { return pluginFileName; }
72
73     int             Load();
74     int             Unload();
75
76     uint16_t        GetStartPosition() const { return plugin->GetStartPosition(); }
77     uint16_t        GetStopPosition() const { return plugin->GetStopPosition(); }
78
79 private:
80     std::string     pluginFileName;
81     std::string     pluginSettingFileName;
82
83     PLUGIN *        plugin;
84     bool            isPluginLoaded;
85     std::string     errorStr;
86
87     void *          libHandle;
88     bool            isRunning;
89
90     ADMINS_IMPL *   admins;
91     TARIFFS_IMPL *  tariffs;
92     USERS_IMPL *    users;
93     SERVICES_IMPL * services;
94     CORPORATIONS_IMPL * corps;
95     STORE *         store;
96     TRAFFCOUNTER *  traffCnt;
97     const SETTINGS_IMPL * stgSettings;
98     MODULE_SETTINGS modSettings;
99 };
100 //-----------------------------------------------------------------------------
101 #endif //PLUGIN_RUNNER_H