permission.h
1 /*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2021 <copyright holder> <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 
20 #ifndef PERMISSION
21 #define PERMISSION
22 
23 
24 #include <string>
25 #include <memory>
26 
27 #include "tools/route.h"
28 #include "security/user.h"
29 
30 
31 namespace NAF
32 {
33  namespace Security
34  {
35  enum class ActionType;
36  class Permission;
37  }
38 }
39 
40 
41 enum class NAF::Security::ActionType
42 {
43  kCreate
44  ,kRead
45  ,kUpdate
46  ,kDelete
47 };
48 
50 {
51  public:
52  Permission();
53  Permission(Tools::Route route_, std::shared_ptr<User> user_, ActionType action_type);
54 
55  Tools::Route& get_route()
56  {
57  auto& var = route_;
58  return var;
59  }
60  std::shared_ptr<User>& get_user()
61  {
62  auto& var = user_;
63  return var;
64  }
65  ActionType get_action_type() const { return action_type_; }
66 
67  void set_route(Tools::Route route) { route_ = route; }
68  void set_action_type(ActionType& action_type) { action_type_ = action_type; }
69 
70  private:
71  Tools::Route route_;
72  std::shared_ptr<User> user_;
73  ActionType action_type_;
74 };
75 
76 
77 #endif // PERMISSION
Definition: permission.h:50
Definition: route.h:49