Phasor  01.00.10.059
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Alias.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Player.h"
4 #include "../Commands.h"
5 #include "../PhasorThread.h"
6 #include "../../Libraries/sqlitepp.h"
7 #include <string>
8 
9 namespace halo { namespace alias
10 {
11  class CAliasError : public std::runtime_error
12  {
13  public:
14  CAliasError(const char* msg) : std::runtime_error(msg) {}
15  };
16 
18  {
19  private:
20  std::unique_ptr<sqlite::SQLiteResult> result;
21  bool has_error;
22  std::string err_msg;
23 
24  void HasResult();
25  void SaveError(const char* err);
26 
27  protected:
28  std::unique_ptr<COutStream> stream;
29 
30  public:
31  CAliasEvent(std::unique_ptr<COutStream> stream);
32  virtual ~CAliasEvent();
33 
34  // return true to indicate there's a result
35  virtual bool ProcessQuery() = 0;
36  virtual void ProcessResult();
37 
38  // inherited from PhasorThread
39  virtual void OnEventAux(PhasorThread& thread) override;
40  virtual void OnEventMain(PhasorThread& thread) override;
41  };
42 
44  {
45  private:
46  std::string hash;
47  std::wstring name;
48 
49  public:
50  AliasEventAddPlayer(std::unique_ptr<COutStream> stream,
51  const std::string& hash, const std::wstring& name);
52  virtual bool ProcessQuery() override;
53  };
54 
56  {
57  private:
58  std::string hash;
59  protected:
60  std::unique_ptr<sqlite::SQLiteResult> result;
61 
62  public:
63  AliasEventQueryHash(std::unique_ptr<COutStream> out, const std::string& hash);
64  bool ProcessQuery() override;
65  void ProcessResult() override;
66  };
67 
69  {
70  private:
71  std::string player;
72  protected:
73  std::unique_ptr<sqlite::SQLiteResult> result;
74 
75  public:
76  AliasEventQueryPlayer(std::unique_ptr<COutStream> out, const std::string& player);
77  bool ProcessQuery() override;
78  void ProcessResult() override;
79  };
80 
81  void Initialize();
82  void OnPlayerJoin(s_player& player);
83  bool ExecuteEvent(std::shared_ptr<CAliasEvent> e);
84 
85  // Server commands
86  using namespace commands;
90 
91 }}