diff --git a/core/http/http_session.cpp b/core/http/http_session.cpp index 6c65714..a454f44 100644 --- a/core/http/http_session.cpp +++ b/core/http/http_session.cpp @@ -17,6 +17,22 @@ Object *HTTPSession::get_object(const std::string &key) { return _data[key]; } +void HTTPSession::add_reference(const std::string &key, const Ref &ref) { + std::lock_guard lock(_mutex); + + _reference_data[key] = ref; +} +void HTTPSession::remove_reference(const std::string &key) { + std::lock_guard lock(_mutex); + + _reference_data.erase(key); +} +Ref 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) { std::lock_guard lock(_mutex); @@ -36,6 +52,7 @@ int HTTPSession::get_int(const std::string &key) { void HTTPSession::clear() { _data.clear(); _int_data.clear(); + _reference_data.clear(); } void HTTPSession::reset() { diff --git a/core/http/http_session.h b/core/http/http_session.h index f113c8f..5cdb79e 100644 --- a/core/http/http_session.h +++ b/core/http/http_session.h @@ -2,16 +2,21 @@ #define HTTP_SESSION_H #include "core/object.h" +#include "core/reference.h" #include #include #include class HTTPSession : public Object { 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); Object *get_object(const std::string &key); + void add_reference(const std::string &key, const Ref &ref); + void remove_reference(const std::string &key); + Ref get_reference(const std::string &key); + void add_int(const std::string &key, const int val); void remove_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) std::map _data; + std::map > _reference_data; std::map _int_data; };