guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
session_storage.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <mutex>
26#include <optional>
27#include <string>
28#include <unordered_map>
29
30#include "storage.hpp"
31
32namespace guillaume
33{
34
58 class SessionStorage: public Storage
59 {
60 private:
61 static std::unordered_map<std::string, std::string>
62 _storage;
63 static std::mutex _mutex;
64
65 public:
66 using Storage::setItem;
67
71 SessionStorage(void) = default;
72
76 ~SessionStorage(void) override = default;
77
84 void setItem(const std::string &key, const std::string &value) override;
85
92 std::optional<std::string> getItem(const std::string &key) override;
93
99 void removeItem(const std::string &key) override;
100
105 void clear(void) override;
106 };
107
108} // namespace guillaume
~SessionStorage(void) override=default
Destroy the handle. The items are kept.
void removeItem(const std::string &key) override
Delete the item stored under a key. Does nothing when there is none.
void clear(void) override
Delete every session item of the process, including those written through other SessionStorage object...
SessionStorage(void)=default
Create a handle on the process-wide session items.
void setItem(const std::string &key, const std::string &value) override
Store a string under a key, replacing the item already stored under that key, if any.
std::optional< std::string > getItem(const std::string &key) override
Read the text stored under a key.
A key-value store of strings, modelled on the web Storage API (setItem, getItem, removeItem,...
Definition storage.hpp:67
virtual void setItem(const std::string &key, const std::string &value)=0
Store a string under a key, replacing the item already stored under that key, if any.
A C++20 UI framework for desktop and XR, built as an entity-component-system.