Develop Biology
The language of life
LinearStructureInterface.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) 2021 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
22#pragma once
23
25
26namespace bio {
27namespace chemical {
28
29class ExcitationBase;
30
35 virtual public ThreadSafe,
36 virtual public Atom
37{
38public:
43 {
44 }
45
50 {
51 }
52
62 template < typename T >
63 Code Insert(
64 T toAdd,
65 const Position position = BOTTOM,
66 const StandardDimension optionalPositionArg = 0, // assuming 0 is the InvalidId for all Perspectives.
67 const bool transferSubContents = false
68 )
69 {
70 Code ret = code::GeneralFailure();
71 LockThread();
72 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
73 if (implementer)
74 {
75 ret = implementer->InsertImplementation(
76 toAdd,
77 position,
78 optionalPositionArg,
79 transferSubContents
80 );
81 }
83 return ret;
84 }
85
92 template < typename T >
93 T GetById(StandardDimension id)
94 {
95 T ret = NULL;
96 LockThread();
97 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
98 if (implementer)
99 {
100 ret = implementer->GetByIdImplementation(
101 id
102 );
103 }
104 UnlockThread();
105 return ret;
106 }
107
114 template < typename T >
115 const T GetById(
116 StandardDimension id
117 ) const
118 {
119 T ret = NULL;
120 LockThread();
121 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
122 if (implementer)
123 {
124 ret = implementer->GetByIdImplementation(
125 id
126 );
127 }
128 UnlockThread();
129 return ret;
130 }
131
138 template < typename T >
140 Name name
141 )
142 {
143 T ret = NULL;
144 LockThread();
145 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
146 if (implementer)
147 {
148 ret = implementer->GetByNameImplementation(
149 name
150 );
151 }
152 UnlockThread();
153 return ret;
154 }
155
162 template < typename T >
163 const T GetByName(
164 Name name
165 ) const
166 {
167 T ret = NULL;
168 LockThread();
169 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
170 if (implementer)
171 {
172 ret = implementer->GetByNameImplementation(
173 name
174 );
175 }
176 UnlockThread();
177 return ret;
178 }
179
187 template < typename T >
189 StandardDimension id
190 )
191 {
192 T ret = NULL;
193 LockThread();
194 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
195 if (implementer)
196 {
197 ret = implementer->GetOrCreateByIdImplementation(
198 id
199 );
200 }
201 UnlockThread();
202 return ret;
203 }
204
212 template < typename T >
214 Name name
215 )
216 {
217 T ret = NULL;
218 LockThread();
219 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
220 if (implementer)
221 {
222 ret = implementer->GetOrCreateByNameImplementation(
223 name
224 );
225 }
226 UnlockThread();
227 return ret;
228 }
229
230
235 template < typename T >
236 Emission ForEach(
237 ExcitationBase* excitation
238 )
239 {
240 Emission ret;
241 LockThread();
242 LinearMotif< T >* implementer = this->AsBonded< LinearMotif< T >* >();
243 if (implementer)
244 {
245 ret = implementer->ForEachImplementation(excitation);
246 }
247 UnlockThread();
248 return ret;
249 }
250};
251
252} //chemical namespace
253} //bio namespace
void LockThread() const
Definition: ThreadSafe.cpp:84
void UnlockThread() const
Definition: ThreadSafe.cpp:97
virtual CONTENT_TYPE GetByNameImplementation(Name name)
Definition: LinearMotif.h:357
virtual CONTENT_TYPE GetByIdImplementation(StandardDimension id)
Definition: LinearMotif.h:324
virtual Code InsertImplementation(CONTENT_TYPE toAdd, const Position position=BOTTOM, const StandardDimension optionalPositionArg=0, const bool transferSubContents=false)
Definition: LinearMotif.h:188
virtual CONTENT_TYPE GetOrCreateByIdImplementation(StandardDimension id)
Definition: LinearMotif.h:406
virtual CONTENT_TYPE GetOrCreateByNameImplementation(Name name)
Definition: LinearMotif.h:426
virtual Emission ForEachImplementation(ExcitationBase *excitation)
Definition: LinearMotif.h:524
Emission ForEach(ExcitationBase *excitation)
const T GetById(StandardDimension id) const
Code Insert(T toAdd, const Position position=BOTTOM, const StandardDimension optionalPositionArg=0, const bool transferSubContents=false)
Code GeneralFailure()
Definition: Cell.h:31
const char * Name
Definition: Types.h:46
Position
Definition: Types.h:46
@ BOTTOM
Definition: Types.h:48