TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DBUpdater.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef DBUpdater_h__
19 #define DBUpdater_h__
20 
21 #include "DatabaseEnv.h"
22 
23 #include <string>
24 #include <boost/filesystem.hpp>
25 
26 class TC_DATABASE_API UpdateException : public std::exception
27 {
28 public:
29  UpdateException(std::string const& msg) : _msg(msg) { }
30  ~UpdateException() throw() { }
31 
32  char const* what() const throw() override { return _msg.c_str(); }
33 
34 private:
35  std::string const _msg;
36 };
37 
39 {
42 };
43 
45 {
47  : updated(0), recent(0), archived(0) { }
48 
49  UpdateResult(size_t const updated_, size_t const recent_, size_t const archived_)
50  : updated(updated_), recent(recent_), archived(archived_) { }
51 
52  size_t updated;
53  size_t recent;
54  size_t archived;
55 };
56 
58 {
59 public:
60  static std::string GetCorrectedMySQLExecutable();
61 
62  static bool CheckExecutable();
63 
64 private:
65  static std::string& corrected_path();
66 };
67 
68 template <class T>
70 {
71 public:
72  using Path = boost::filesystem::path;
73 
74  static inline std::string GetConfigEntry();
75 
76  static inline std::string GetTableName();
77 
78  static std::string GetBaseFile();
79 
80  static bool IsEnabled(uint32 const updateMask);
81 
82  static BaseLocation GetBaseLocationType();
83 
84  static bool Create(DatabaseWorkerPool<T>& pool);
85 
86  static bool Update(DatabaseWorkerPool<T>& pool);
87 
88  static bool Populate(DatabaseWorkerPool<T>& pool);
89 
90 private:
91  static QueryResult Retrieve(DatabaseWorkerPool<T>& pool, std::string const& query);
92  static void Apply(DatabaseWorkerPool<T>& pool, std::string const& query);
93  static void ApplyFile(DatabaseWorkerPool<T>& pool, Path const& path);
94  static void ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& host, std::string const& user,
95  std::string const& password, std::string const& port_or_socket, std::string const& database, Path const& path);
96 };
97 
98 #endif // DBUpdater_h__
Definition: DBUpdater.h:41
Definition: DBUpdater.h:26
#define TC_DATABASE_API
Definition: Define.h:122
~UpdateException()
Definition: DBUpdater.h:30
size_t recent
Definition: DBUpdater.h:53
Definition: DBUpdater.h:57
BaseLocation
Definition: DBUpdater.h:38
size_t archived
Definition: DBUpdater.h:54
std::string const _msg
Definition: DBUpdater.h:35
char * query(struct soap *soap)
Definition: httpget.cpp:244
Definition: DBUpdater.h:40
static bool CheckExecutable()
Definition: DBUpdater.cpp:47
Definition: DBUpdater.h:44
boost::filesystem::path Path
Definition: DBUpdater.h:72
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
char const * what() const override
Definition: DBUpdater.h:32
std::string GetTableName(std::string const &str)
Definition: PlayerDump.cpp:127
static std::string GetCorrectedMySQLExecutable()
Definition: DBUpdater.cpp:39
Definition: DBUpdater.h:69
UpdateResult()
Definition: DBUpdater.h:46
size_t updated
Definition: DBUpdater.h:52
Definition: DatabaseWorkerPool.h:48
static std::string & corrected_path()
Definition: DBUpdater.cpp:77
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150
UpdateException(std::string const &msg)
Definition: DBUpdater.h:29
UpdateResult(size_t const updated_, size_t const recent_, size_t const archived_)
Definition: DBUpdater.h:49