libbio
Loading...
Searching...
No Matches
SafelyAccessShared.h
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2026 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21#pragma once
22
25
26namespace bio
27{
28
71template < class CLASS >
73{
74public:
79 mClass(&CLASS::Instance())
80 {
81 this->CommonConstructor();
82 }
83
89 mClass(toAccess)
90 {
91 this->CommonConstructor();
92 }
93
98 {
99 this->mClass->UnlockMutexShared();
100 }
101
109 {
110 return this->mClass;
111 }
112
118 {
119 return mClass;
120 }
121
122private:
123 Pointer< CLASS > mClass;
124
125 void CommonConstructor()
126 {
127 BIO_ASSERT(this->mClass)
128 this->mClass->LockMutexShared();
129 }
130
131 // Non-copyable; matches SafelyAccess<T>.
133 void operator=(SafelyAccessShared const &);
134};
135
136} // bio namespace
#define BIO_ASSERT(condition)
Definition AssertMacros.h:31
Definition Pointer.h:115
Definition SafelyAccessShared.h:73
~SafelyAccessShared()
Definition SafelyAccessShared.h:97
SafelyAccessShared(Pointer< CLASS > toAccess)
Definition SafelyAccessShared.h:88
SafelyAccessShared()
Definition SafelyAccessShared.h:78
Pointer< const CLASS > operator->() const
Definition SafelyAccessShared.h:108
Pointer< const CLASS > operator*() const
Definition SafelyAccessShared.h:117
Definition FinalCell.h:29