FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_tunnel.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_TUNNEL_HPP_INCLUDED
18#define _FGE_C_TUNNEL_HPP_INCLUDED
19
20#include <vector>
21
22namespace fge
23{
24
25template<class T>
26class TunnelGate;
27
28template<class T>
29class Tunnel
30{
31public:
32 Tunnel() = default;
33 Tunnel(fge::Tunnel<T>& r) = delete;
34 Tunnel(fge::Tunnel<T>&& r) noexcept;
35 ~Tunnel();
36
37 fge::Tunnel<T>& operator=(fge::Tunnel<T>& r) = delete;
38 fge::Tunnel<T>& operator=(fge::Tunnel<T>&& r) noexcept;
39
40 bool knock(fge::TunnelGate<T>& gate, bool anonymous = false);
41 bool addGate(fge::TunnelGate<T>& gate, bool anonymous = false);
42
43 bool isAnonymous(fge::TunnelGate<T> const& gate) const;
44
45 void closeGate(std::size_t index);
46 void closeAnonymousGate(std::size_t index);
47 void closeGate(fge::TunnelGate<T>& gate);
48 void closeAll();
49
50 T* get(std::size_t index) const;
51 T* getAnonymous(std::size_t index) const;
52 [[nodiscard]] std::size_t getGatesSize() const;
53 [[nodiscard]] std::size_t getAnonymousGatesSize() const;
54
55 T* operator[](std::size_t index) const;
56
57private:
58 std::vector<fge::TunnelGate<T>*> g_gates;
59 std::vector<fge::TunnelGate<T>*> g_anonymousGates;
60};
61
62template<class T>
64{
65public:
66 TunnelGate();
67 TunnelGate(fge::TunnelGate<T> const& gate);
68 TunnelGate(fge::TunnelGate<T>&& gate) noexcept;
69 explicit TunnelGate(T* data);
71
72 fge::TunnelGate<T>& operator=(fge::TunnelGate<T> const& gate);
73 fge::TunnelGate<T>& operator=(fge::TunnelGate<T>&& gate) noexcept;
74
75 bool openTo(fge::Tunnel<T>& tunnel, bool anonymous = false);
76 void close();
77 [[nodiscard]] bool isOpen() const;
78
79 void setData(T* val);
80 T const* getData() const;
81 T* getData();
82
83 void setLock(bool val);
84 [[nodiscard]] bool isLocked() const;
85
86 fge::Tunnel<T>* getTunnel() const;
87
88private:
89 friend class Tunnel<T>;
90
91 T* g_data;
92 fge::Tunnel<T>* g_tunnel;
93 bool g_locked;
94};
95
96} // namespace fge
97
98#include <FastEngine/C_tunnel.inl>
99
100#endif // _FGE_C_TUNNEL_HPP_INCLUDED
Definition C_tunnel.hpp:64
TunnelGate()
TunnelGate.
Definition C_tunnel.inl:204
Definition C_tunnel.hpp:30