Samchon Framework for CPP  1.0.0
Server.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 #include <samchon/protocol/IServer.hpp>
4 #include <samchon/protocol/IProtocol.hpp>
5 
6 #include <samchon/Dictionary.hpp>
7 #include <samchon/SmartPointer.hpp>
8 #include <samchon/library/RWMutex.hpp>
9 
10 namespace samchon
11 {
12 namespace library
13 {
14  class SQLi;
15  class SQLStatement;
16 };
17 namespace protocol
18 {
19 namespace service
20 {
21  class IPUserPair;
22  class User;
23  class Client;
24 
48  class SAMCHON_FRAMEWORK_API Server
49  : private Dictionary<SmartPointer<User>>,
50  public IServer
51  {
52  friend class IPUserPair;
53  friend class User;
54 
55  private:
56  typedef Dictionary<SmartPointer<User>> super;
57 
58  protected:
62  virtual auto NAME() const->std::string = 0;
63 
68 
69  private:
70  library::RWMutex mtx;
71 
76 
80  size_t sequence;
81 
82  public:
86  Server();
87  virtual ~Server();
88 
89  /* =========================================================
90  GETTERS
91  ========================================================= */
92  auto getSQLi() const->library::SQLi*;
93 
94  /* =========================================================
95  ACCESSORS OF MAP
96  ========================================================= */
100  auto size() const->size_t;
101 
107  auto begin() const->const_iterator;
108 
114  auto end() const->const_iterator;
115 
116  protected:
117  /* =========================================================
118  ABSTRACT METHODS
119  ========================================================= */
123  virtual auto createUser()->User* = 0;
124 
128  virtual void addClient(Socket*) override;
129 
130  private:
131  void eraseUser(const std::string &);
132  };
133 };
134 };
135 };
Customized std::map.
Definition: Map.hpp:88
An interface of a physical server.
Definition: IServer.hpp:43
Definition: RWMutex.hpp:4
Dictionary< std::shared_ptr< IPUserPair > > ipMap
Dictionary of issuer of session ID of each ip.
Definition: Server.hpp:75
Relationship between IP address and User for issuing session.
Definition: IPUserPair.hpp:51
User containing Client(s) with session-id.
Definition: User.hpp:56
A server for (cloud) service.
Definition: Server.hpp:48
A SQL interface; DBMS connector.
Definition: SQLi.hpp:42
library::SQLi * sqli
SQLi for archiving log.
Definition: Server.hpp:67
size_t sequence
Sequence for issuing session ID.
Definition: Server.hpp:80
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7