sessions_manager.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2023 Jose F Rivas C <email>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef NAF_TOOLS_SESSIONSMANAGER
20 #define NAF_TOOLS_SESSIONSMANAGER
21 
22 
23 #include <string>
24 #include <map>
25 #include <mutex>
26 #include <exception>
27 
28 #include "Poco/Exception.h"
29 
30 #include "extras/session.h"
31 #include "functions/action.h"
32 #include "tools/output_logger.h"
33 #include "query/parameter.h"
34 #include "tools/dvalue.h"
35 
36 namespace NAF
37 {
38  namespace Tools
39  {
40  class SessionsManager;
41  }
42 }
43 
44 
46 {
47  public:
49  ~SessionsManager();
50 
51  static std::map<std::string, NAF::Extras::Session>& get_sessions()
52  {
53  auto& var = sessions_;
54  return var;
55  }
56 
57  static void ReadSessions_();
58  static NAF::Extras::Session& CreateSession_(std::string user, std::string path, int max_age);
59  static void DeleteSession_(std::string id);
60 
61  protected:
62  static bool SessionExists_(std::string id);
63 
64  private:
65  static std::mutex mutex_;
66  static std::map<std::string, NAF::Extras::Session> sessions_;
67 };
68 
69 #endif // NAF_TOOLS_SESSIONSMANAGER
Definition: session.h:45
Definition: sessions_manager.h:46