]> git.stg.codes - stg.git/blob - include/stg/store.h
Public interfaces: part 1
[stg.git] / include / stg / store.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 #pragma once
22
23 #include "stg/message.h"
24 #include "stg/user_stat.h" // TraffStat is not forwardable
25
26 #include <string>
27 #include <vector>
28 #include <map>
29
30 namespace STG
31 {
32
33 struct UserConf;
34 struct CorpConf;
35 struct ServiceConf;
36 struct AdminConf;
37 struct TariffData;
38 struct ModuleSettings;
39 class DirTraff;
40
41 //-----------------------------------------------------------------------------
42 struct Store {
43     virtual ~Store() = default;
44
45     virtual int GetUsersList(std::vector<std::string>* usersList) const = 0;
46     virtual int AddUser(const std::string& login) const = 0;
47     virtual int DelUser(const std::string& login) const = 0;
48     virtual int SaveUserStat(const UserStat& stat, const std::string& login) const = 0;
49     virtual int SaveUserConf(const UserConf& conf, const std::string& login) const = 0;
50     virtual int RestoreUserStat(UserStat* stat, const std::string& login) const = 0;
51     virtual int RestoreUserConf(UserConf* conf, const std::string& login) const = 0;
52
53     virtual int WriteUserChgLog(const std::string& login,
54                                 const std::string& admLogin,
55                                 uint32_t admIP,
56                                 const std::string& paramName,
57                                 const std::string& oldValue,
58                                 const std::string& newValue,
59                                 const std::string& message = "") const = 0;
60
61     virtual int WriteUserConnect(const std::string& login, uint32_t ip) const = 0;
62
63     virtual int WriteUserDisconnect(const std::string& login,
64                                     const DirTraff& up,
65                                     const DirTraff& down,
66                                     const DirTraff& sessionUp,
67                                     const DirTraff& sessionDown,
68                                     double cash,
69                                     double freeMb,
70                                     const std::string& reason) const = 0;
71
72     virtual int WriteDetailedStat(const TraffStat& statTree,
73                                   time_t lastStat,
74                                   const std::string& login) const = 0;
75
76     virtual int AddMessage(Message* msg, const std::string& login) const = 0;
77     virtual int EditMessage(const Message& msg, const std::string& login) const = 0;
78     virtual int GetMessage(uint64_t id, Message* msg, const std::string& login) const = 0;
79     virtual int DelMessage(uint64_t id, const std::string& login) const = 0;
80     virtual int GetMessageHdrs(std::vector<Message::Header>* hdrsList, const std::string& login) const = 0;
81
82     virtual int SaveMonthStat(const UserStat& stat, int month, int year, const std::string& login) const = 0;
83
84     virtual int GetAdminsList(std::vector<std::string>* adminsList) const = 0;
85     virtual int SaveAdmin(const AdminConf& ac) const = 0;
86     virtual int RestoreAdmin(AdminConf* ac, const std::string& login) const = 0;
87     virtual int AddAdmin(const std::string& login) const = 0;
88     virtual int DelAdmin(const std::string& login) const = 0;
89
90     virtual int GetTariffsList(std::vector<std::string>* tariffsList) const = 0;
91     virtual int AddTariff(const std::string& name) const = 0;
92     virtual int DelTariff(const std::string& name) const = 0;
93     virtual int SaveTariff(const TariffData& td, const std::string& tariffName) const = 0;
94     virtual int RestoreTariff(TariffData* td, const std::string& tariffName) const = 0;
95
96     virtual int GetCorpsList(std::vector<std::string>* corpsList) const = 0;
97     virtual int SaveCorp(const CorpConf& cc) const = 0;
98     virtual int RestoreCorp(CorpConf* cc, const std::string& name) const = 0;
99     virtual int AddCorp(const std::string& name) const = 0;
100     virtual int DelCorp(const std::string& name) const = 0;
101
102     virtual int GetServicesList(std::vector<std::string>* corpsList) const = 0;
103     virtual int SaveService(const ServiceConf& sc) const = 0;
104     virtual int RestoreService(ServiceConf* sc, const std::string& name) const = 0;
105     virtual int AddService(const std::string& name) const = 0;
106     virtual int DelService(const std::string& name) const = 0;
107
108     virtual void SetSettings(const ModuleSettings& s) = 0;
109     virtual int ParseSettings() = 0;
110     virtual const std::string& GetStrError() const = 0;
111     virtual const std::string& GetVersion() const = 0;
112 };
113 //-----------------------------------------------------------------------------
114 }