QtWebApp
httpsession.h
Go to the documentation of this file.
1 
6 #ifndef HTTPSESSION_H
7 #define HTTPSESSION_H
8 
9 #include <QByteArray>
10 #include <QVariant>
11 #include <QReadWriteLock>
12 #include "httpglobal.h"
13 
14 namespace stefanfrings {
15 
23 class DECLSPEC HttpSession {
24 
25 public:
26 
32  HttpSession(const bool canStore=false);
33 
38  HttpSession(const HttpSession& other);
39 
44  HttpSession& operator= (const HttpSession& other);
45 
49  virtual ~HttpSession();
50 
52  QByteArray getId() const;
53 
58  bool isNull() const;
59 
61  void set(const QByteArray& key, const QVariant& value);
62 
64  void remove(const QByteArray& key);
65 
67  QVariant get(const QByteArray& key) const;
68 
70  bool contains(const QByteArray& key) const;
71 
77  QMap<QByteArray,QVariant> getAll() const;
78 
84  qint64 getLastAccess() const;
85 
91  void setLastAccess();
92 
93 private:
94 
95  struct HttpSessionData {
96 
98  QByteArray id;
99 
101  qint64 lastAccess;
102 
104  int refCount;
105 
107  QReadWriteLock lock;
108 
110  QMap<QByteArray,QVariant> values;
111 
112  };
113 
115  HttpSessionData* dataPtr;
116 
117 };
118 
119 } // end of namespace
120 
121 #endif // HTTPSESSION_H
This class stores data for a single HTTP session.
Definition: httpsession.h:23