Webdar 1.0.0
Web user interface to libdar
static_object_library.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef STATIC_OBJECT_LIBRARY_HPP
25#define STATIC_OBJECT_LIBRARY_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <map>
36#include <string>
37
38 // webdar headers
39#include "static_object.hpp"
40
42
47
49{
50public:
51
53
55 static_object_library(const static_object_library & ref) = delete;
56 static_object_library(static_object_library && ref) noexcept = delete;
57 static_object_library & operator = (const static_object_library & ref) = delete;
58 static_object_library & operator = (static_object_library && ref) noexcept = delete;
59 ~static_object_library() = delete;
60
62 static void init();
63
64
67 static const static_object * find_object(const std::string & name);
68
70 static void release();
71
72private:
76 static void add_object_to_library(const std::string & name, static_object * ref);
77
79 static void freeze_library() { frozen = true; };
80
81 // no locking is required as the library is filled once before
82 // multi-thread is started at startup and stays read-only the
83 // rest of the time
84 static std::map<std::string, static_object *> library;
85 static bool frozen;
86};
87
88#endif
library storing static objects in memory
Definition: static_object_library.hpp:49
static void init()
initialize the library once and for all
Definition: static_object_library.cpp:46
static void release()
release all objects added to the library
Definition: static_object_library.cpp:66
static const static_object * find_object(const std::string &name)
Definition: static_object_library.cpp:54
static_object_library()=delete
no object of that class get ever created
common ancestor to all static object, this makes easier to add new object type in the future
Definition: static_object.hpp:42