#include <string>
#include <vector>
-#include <map>
-#include "base_store.h"
+#include "stg/store.h"
+#include "stg/logger.h"
-// Minimal DB version is 5
-// Recommended DB version is 6 (support FreeMb logging on disconnects)
-#define DB_MIN_VERSION 5
+// Minimal DB version is 7
+// Recommended DB version is 7 (support full month stats)
+#define DB_MIN_VERSION 7
-extern "C" BASE_STORE * GetStore();
-
-class POSTGRESQL_STORE : public BASE_STORE {
+class POSTGRESQL_STORE : public STORE {
public:
POSTGRESQL_STORE();
virtual ~POSTGRESQL_STORE();
double cash,
double freeMb,
const std::string & reason) const;
- int WriteDetailedStat(const std::map<IP_DIR_PAIR, STAT_NODE> & statTree,
+ int WriteDetailedStat(const TRAFF_STAT & statTree,
time_t lastStat,
const std::string & login) const;
// Tariffs
int GetTariffsList(std::vector<std::string> * tariffsList) const;
int AddTariff(const std::string & name) const;
- int DelTariff(const string & name) const;
+ int DelTariff(const std::string & name) const;
int SaveTariff(const TARIFF_DATA & td, const std::string & tariffName) const;
int RestoreTariff(TARIFF_DATA * td, const std::string & tariffName) const;
int DelService(const std::string & name) const;
// Settings
- inline void SetSettings(const MODULE_SETTINGS & s) { settings = s; };
+ inline void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int ParseSettings();
- inline const string & GetStrError() const { return strError; };
- inline const string & GetVersion() const { return versionString; };
+ inline const std::string & GetStrError() const { return strError; }
+ inline const std::string & GetVersion() const { return versionString; }
private:
+ POSTGRESQL_STORE(const POSTGRESQL_STORE & rvalue);
+ POSTGRESQL_STORE & operator=(const POSTGRESQL_STORE & rvalue);
+
int StartTransaction() const;
int CommitTransaction() const;
int RollbackTransaction() const;
int EscapeString(std::string & value) const;
- std::string Int2TS(uint32_t value) const;
- uint32_t TS2Int(const std::string & value) const;
+ std::string Int2TS(time_t value) const;
+ time_t TS2Int(const std::string & value) const;
int SaveStat(const USER_STAT & stat, const std::string & login, int year = 0, int month = 0) const;
MODULE_SETTINGS settings;
mutable pthread_mutex_t mutex;
mutable int version;
+ int retries;
PGconn * connection;
-};
-extern const volatile time_t stgTime;
+ PLUGIN_LOGGER logger;
+};
#endif //POSTGRESQL_STORE_H