FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_propertyList.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_PROPERTYLIST_HPP_INCLUDED
18#define _FGE_C_PROPERTYLIST_HPP_INCLUDED
19
20#include "FastEngine/C_property.hpp"
21#include <string>
22#include <unordered_map>
23
24namespace fge
25{
26
35{
36public:
37 using DataType = std::unordered_map<std::string, fge::Property>;
38
39 inline PropertyList() = default;
40 inline PropertyList(PropertyList const& r) = default;
41 inline PropertyList(PropertyList&& r) noexcept = default;
42 inline ~PropertyList() = default;
43
44 inline PropertyList& operator=(PropertyList const& r) = default;
45 inline PropertyList& operator=(PropertyList&& r) noexcept = default;
46
47 inline void delAllProperties();
48 inline void delProperty(std::string const& key);
49
50 template<class T>
51 [[nodiscard]] inline bool findProperty(std::string const& key) const;
52 [[nodiscard]] inline bool findProperty(std::string const& key) const;
53
54 template<class T>
55 inline void setProperty(std::string const& key, T&& value);
56
57 template<class T>
58 [[nodiscard]] inline T* getProperty(std::string const& key);
59 template<class T>
60 [[nodiscard]] inline T const* getProperty(std::string const& key) const;
61 template<class T, class TDefault>
62 [[nodiscard]] inline T& getProperty(std::string const& key, TDefault&& defaultValue);
63
64 [[nodiscard]] inline fge::Property& getProperty(std::string const& key);
65 [[nodiscard]] inline fge::Property const* getProperty(std::string const& key) const;
66
67 [[nodiscard]] inline fge::Property& operator[](std::string const& key);
68 [[nodiscard]] inline fge::Property const* operator[](std::string const& key) const;
69
70 [[nodiscard]] inline std::size_t count() const;
71
72 [[nodiscard]] inline DataType::iterator begin();
73 [[nodiscard]] inline DataType::iterator end();
74 [[nodiscard]] inline DataType::const_iterator begin() const;
75 [[nodiscard]] inline DataType::const_iterator end() const;
76
77 inline void clearAllModificationFlags();
78 [[nodiscard]] inline std::size_t countAllModificationFlags() const;
79
80private:
81 DataType g_data;
82};
83
84} // namespace fge
85
86#include "FastEngine/C_propertyList.inl"
87
88#endif // _FGE_C_PROPERTYLIST_HPP_INCLUDED
A class that map a string to a Property.
Definition C_propertyList.hpp:35
A class that can store any type of data.
Definition C_property.hpp:54