mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-02-20 15:14:26 +01:00
Added reference support to the session.
This commit is contained in:
parent
ed434b7f68
commit
8318e0257a
@ -17,6 +17,22 @@ Object *HTTPSession::get_object(const std::string &key) {
|
|||||||
return _data[key];
|
return _data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTTPSession::add_reference(const std::string &key, const Ref<Reference> &ref) {
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
|
_reference_data[key] = ref;
|
||||||
|
}
|
||||||
|
void HTTPSession::remove_reference(const std::string &key) {
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
|
_reference_data.erase(key);
|
||||||
|
}
|
||||||
|
Ref<Reference> HTTPSession::get_reference(const std::string &key) {
|
||||||
|
//don't lock here
|
||||||
|
|
||||||
|
return _reference_data[key];
|
||||||
|
}
|
||||||
|
|
||||||
void HTTPSession::add_int(const std::string &key, const int val) {
|
void HTTPSession::add_int(const std::string &key, const int val) {
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
@ -36,6 +52,7 @@ int HTTPSession::get_int(const std::string &key) {
|
|||||||
void HTTPSession::clear() {
|
void HTTPSession::clear() {
|
||||||
_data.clear();
|
_data.clear();
|
||||||
_int_data.clear();
|
_int_data.clear();
|
||||||
|
_reference_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPSession::reset() {
|
void HTTPSession::reset() {
|
||||||
|
@ -2,16 +2,21 @@
|
|||||||
#define HTTP_SESSION_H
|
#define HTTP_SESSION_H
|
||||||
|
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
|
#include "core/reference.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class HTTPSession : public Object {
|
class HTTPSession : public Object {
|
||||||
public:
|
public:
|
||||||
void add_object(const std::string &key,Object *obj);
|
void add_object(const std::string &key, Object *obj);
|
||||||
void remove_object(const std::string &key);
|
void remove_object(const std::string &key);
|
||||||
Object *get_object(const std::string &key);
|
Object *get_object(const std::string &key);
|
||||||
|
|
||||||
|
void add_reference(const std::string &key, const Ref<Reference> &ref);
|
||||||
|
void remove_reference(const std::string &key);
|
||||||
|
Ref<Reference> get_reference(const std::string &key);
|
||||||
|
|
||||||
void add_int(const std::string &key, const int val);
|
void add_int(const std::string &key, const int val);
|
||||||
void remove_int(const std::string &key);
|
void remove_int(const std::string &key);
|
||||||
int get_int(const std::string &key);
|
int get_int(const std::string &key);
|
||||||
@ -29,6 +34,7 @@ protected:
|
|||||||
|
|
||||||
//todo make something similar to godot's variant. (Or get godot's variant lol)
|
//todo make something similar to godot's variant. (Or get godot's variant lol)
|
||||||
std::map<std::string, Object *> _data;
|
std::map<std::string, Object *> _data;
|
||||||
|
std::map<std::string, Ref<Reference> > _reference_data;
|
||||||
std::map<std::string, int> _int_data;
|
std::map<std::string, int> _int_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user