libbio
Loading...
Searching...
No Matches
SafelyAccess.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) 2022 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
36template < class CLASS >
38{
39public:
44 mClass(&CLASS::Instance())
45 {
46 this->CommonConstructor();
47 }
48
54 mClass(toAccess)
55 {
56 this->CommonConstructor();
57 }
58
63 {
64 this->mClass->UnlockThread();
65 }
66
72 {
73 return this->mClass;
74 }
75
81 {
82 return this->mClass;
83 }
84
90 {
91 return mClass;
92 }
93
99 {
100 return mClass;
101 }
102
103private:
104 Pointer< CLASS > mClass;
105
106 void CommonConstructor()
107 {
108 BIO_ASSERT(this->mClass)
109 this->mClass->LockThread();
110 }
111
112 //remove copy ctors.
113 SafelyAccess(SafelyAccess const &);
114 void operator=(SafelyAccess const &);
115};
116
117} // bio namespace
#define BIO_ASSERT(condition)
Definition AssertMacros.h:31
Definition Pointer.h:115
Definition SafelyAccess.h:38
Pointer< CLASS > operator->()
Definition SafelyAccess.h:71
SafelyAccess()
Definition SafelyAccess.h:43
Pointer< CLASS > operator*()
Definition SafelyAccess.h:89
Pointer< const CLASS > operator->() const
Definition SafelyAccess.h:80
Pointer< const CLASS > operator*() const
Definition SafelyAccess.h:98
SafelyAccess(Pointer< CLASS > toAccess)
Definition SafelyAccess.h:53
~SafelyAccess()
Definition SafelyAccess.h:62
Definition FinalCell.h:29