libbio
Loading...
Searching...
No Matches
Final.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
22#pragma once
23
25
26namespace bio {
27
37template < class CLASS>
38class Final :
39 public TransparentWrapper< CLASS >
40{
41public:
42
48 {
49 }
50
54 explicit Final(const Name& name):
56 {
57 }
58
62 explicit Final(const Id& id):
64 {
65 }
66
71 {
72
73 }
74
75 //START: operators
76
77 operator Id() const
78 {
79 return this->mT.operator Id();
80 }
81
83 {
84 return this->mT.operator Pointer< physical::Wave >();
85 }
86
87 template < typename AS >
88 operator AS()
89 {
90 return this->mT.template As< AS >();
91 }
92
94 {
95 return this->mT.operator|(symmetry);
96 }
97
99 {
100 return this->mT.operator*(signal);
101 }
102
104 {
105 return this->mT.operator*();
106 }
107
109 {
110 return this->mT.operator*();
111 }
112
114 {
115 this->mT.operator+(other);
116 }
117
119 {
120 return this->mT.operator-(other);
121 }
122
123 bool operator==(const Id id) const
124 {
125 return this->mT.operator==(id);
126 }
127
128 bool operator==(const Name& name) const
129 {
130 return this->mT.operator==(name);
131 }
132
134 {
135 return this->mT.operator==(other);
136 }
137
138 //END: operators
139
140 //START: ...::Class<> methods
141
143 {
144 return this->mT.Clone();
145 }
147 {
148 return this->mT.AsWave();
149 }
151 {
152 return this->mT.AsWave();
153 }
155 {
156 return this->mT.RegisterProperties(properties);
157 }
159 {
160 return this->mT.GetProperties();
161 }
163 {
164 return this->mT.AsAtom();
165 }
167 {
168 return this->mT.AsAtom();
169 }
171 {
172 return this->mT.Modulate(signal);
173 }
175 {
176 return this->mT.Demodulate();
177 }
179 {
180 return this->mT.Demodulate();
181 }
183 {
184 return this->mT.Attenuate(other);
185 }
187 {
188 return this->mT.Disattenuate(other);
189 }
191 {
192 return this->mT.AsLogWriter();
193 }
194 void Log(
196 const char* format,
198 ) const
199 {
200 return this->mT.Log(
201 level,
202 format,
203 args
204 );
205}
206 template < typename ENVIRONMENT >
211 template < typename ENVIRONMENT >
213 {
214 return this->mT.template GetEnvironment< ENVIRONMENT >();
215 }
216 template < typename ENVIRONMENT >
218 {
219 return this->mT.template GetEnvironment< ENVIRONMENT >();
220 }
221
222 //END: ...::Class<> methods
223
224 //START: chemical::UnorderedStructureInterface methods
225
226 template < typename T >
227 T Add(const T t)
228 {
229 return this->mT.template Add< T >(t);
230 }
231
232 template < typename T >
233 Code Remove(const T t)
234 {
235 return this->mT.template Remove< T >(t);
236 }
237
238 template < typename T >
240 {
241 return this->mT.template Import< T >(other);
242 }
243
244 template < typename T >
246 {
247 return this->mT.template Import< T >(other);
248 }
249
250 template < typename T >
251 void Import(const ::bio::Arrangement< T >& other)
252 {
253 return this->mT.template Import< T >(other);
254 }
255
257 {
258 return this->mT.ImportAll(other);
259 }
260
261 template < typename T >
263 {
264 return this->mT.template GetCount< T >();
265 }
266
267 template < typename T >
269 {
270 return this->mT.template GetAll< T >();
271 }
272
273 template < typename T >
275 {
276 return this->mT.template GetAll< T >();
277 }
278
279 template < typename T >
280 bool Has(T content) const
281 {
282 return this->mT.template Has< T >(content);
283 }
284
285 template < typename T >
287 {
288 return this->mT.template GetNumMatching< T >(other);
289 }
290
291 template < typename T >
293 {
294 return this->mT.template HasAll< T >(contents);
295 }
296
297 template < typename T >
298 void Clear()
299 {
300 return this->mT.template Clear< T >();
301 }
302
303 template < typename T >
304 std::string GetStringFrom(std::string separator = ", ")
305 {
306 return this->mT.template GetStringFrom< T >(separator);
307 }
308
309 template < typename T >
310 void Log()
311 {
312 return this->mT.template Log< T >();
313 }
314
315 //END: chemical::UnorderedStructureInterface methods
316
317 //START: chemical::LinearStructureInterface methods
318
319 template < typename T >
321 T toAdd,
322 const Position position = BOTTOM,
323 const Id optionalPositionArg = 0,
324 const bool transferSubContents = false
325 )
326 {
327 return this->mT.template Insert< T >(
328 toAdd,
329 position,
332 );
333 }
334
335 template < typename T >
336 T GetById(const Id& id)
337 {
338 return this->mT.template GetById< T >(id);
339 }
340
341 template < typename T >
342 const T GetById(const Id& id) const
343 {
344 return this->mT.template GetById< T >(id);
345 }
346
347 template < typename T >
349 {
350 return this->mT.template GetByName< T >(name);
351 }
352
353 template < typename T >
354 const T GetByName(const Name& name) const
355 {
356 return this->mT.template GetByName< T >(name);
357 }
358
359 template < typename T >
360 T GetOrCreateById(const Id& id)
361 {
362 return this->mT.template GetOrCreateById< T >(id);
363 }
364
365 template < typename T >
367 {
368 return this->mT.template GetOrCreateByName< T >(name);
369 }
370
371 template < typename T >
376
377 //END: chemical::LinearStructureInterface methods
378
379 //START: chemical::Substance methods
380
381 void Enable()
382 {
383 return this->mT.Enable();
384 }
385 void Disable()
386 {
387 return this->mT.Disable();
388 }
389 bool IsEnabled() const
390 {
391 return this->mT.IsEnabled();
392 }
393
394 //END: chemical::Substance methods
395
396 //START: chemical::Atom methods
397
398 template < typename T >
400 {
401 return this->mT.template As< T >();
402 }
403
404 template < typename T >
405 const T As() const
406 {
407 return this->mT.template As< T >();
408 }
409
410 template < typename T >
412 T toBond,
414 {
415 return this->mT.template FormBond< T >(toBond, type);
416 }
417
418 template < typename T >
422 {
423 return this->mT.template BreakBond< T >(toDisassociate, type);
424 }
425
426 // Final<>::GetAllBonds is a thin shim around chemical::Atom::GetAllBonds,
427 // which is BIO_DEPRECATED at v6 per RFC_ATOM_THREADSAFE_BOND_LOCK.md §5.
428 // We mark the Final<> shim BIO_DEPRECATED too so external consumers
429 // see one warning per call site, then suppress the diagnostic on the
430 // shim body so the forwarding call itself doesn't double-warn.
431 #if defined(__GNUC__) || defined(__clang__)
432 #pragma GCC diagnostic push
433 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
434 #endif
435 BIO_DEPRECATED("Use Final<>::ForEachBond / ForEachBondMutable; GetAllBonds bypasses the per-Atom lock. See RFC_ATOM_THREADSAFE_BOND_LOCK.md §5.")
436 Pointer< chemical::Bonds > GetAllBonds()
437 {
438 return this->mT.GetAllBonds();
439 }
440
441 BIO_DEPRECATED("Use Final<>::ForEachBond / ForEachBondMutable; GetAllBonds bypasses the per-Atom lock. See RFC_ATOM_THREADSAFE_BOND_LOCK.md §5.")
442 Pointer< const chemical::Bonds > GetAllBonds() const
443 {
444 return this->mT.GetAllBonds();
445 }
446 #if defined(__GNUC__) || defined(__clang__)
447 #pragma GCC diagnostic pop
448 #endif
449
450 //END: chemical::Atom methods
451
452 //START: log::Writer methods
453
454 void Log(
456 const char* format,
457 ...
458 ) const
459 {
462 this->mT.Log(level, format, args);
463 va_end(args);
464 }
465
466 //END: log::Writer methods
467
468 //START: physical::Identifiable< Id > methods
469
470 Name GetName() const
471 {
472 return this->mT.GetName();
473 }
474
475 Id GetId() const
476 {
477 return this->mT.GetId();
478 }
479
480 void SetName(const Name& name)
481 {
482 return this->mT.SetName(name);
483 }
484
485 void SetId(const Id& id)
486 {
487 return this->mT.SetId(id);
488 }
489
490 bool IsName(const Name& name) const
491 {
492 return this->mT.IsName(name);
493 }
494
495 bool IsNameInsensitive(const Name& name) const
496 {
497 return this->mT.IsNameInsensitive(name);
498 }
499
500 bool IsId(const Id& id) const
501 {
502 return this->mT.IsId(id);
503 }
504
506 {
507 return this->mT.SetPerspective(perspective);
508 }
509
510 void MakeWave(bool force = false)
511 {
512 return this->mT.MakeWave();
513 }
514
516 {
517 return this->mT.GetPerspective();
518 }
519
520 //END: physical::Identifiable< Id > methods
521
522 //START: physical::Wave methods (some of these defined above).
523
525 {
526 return this->mT.Spin();
527 }
528
530 {
531 return this->mT.Reify(symmetry);
532 }
533
534 //END: physical::Wave methods
535};
536
537} //bio namespace
#define BIO_DEPRECATED(message)
Definition LanguageMacros.h:62
Definition Final.h:40
Final()
Definition Final.h:46
Pointer< const physical::Wave > Demodulate() const
Definition Final.h:178
Pointer< const physical::Wave > AsWave() const
Definition Final.h:150
Code Reify(Pointer< const physical::Symmetry > symmetry)
Definition Final.h:529
T GetOrCreateByName(const Name &name)
Definition Final.h:366
const Pointer< ENVIRONMENT > GetEnvironment() const
Definition Final.h:217
Pointer< physical::Wave > operator*(Pointer< physical::Wave > signal)
Definition Final.h:98
void Clear()
Definition Final.h:298
void Log(LogLevel level, const char *format,...) const
Definition Final.h:454
Final(const Id &id)
Definition Final.h:62
Id GetId() const
Definition Final.h:475
void SetEnvironment(Pointer< ENVIRONMENT > environment)
Definition Final.h:207
T GetById(const Id &id)
Definition Final.h:336
bool IsId(const Id &id) const
Definition Final.h:500
T GetOrCreateById(const Id &id)
Definition Final.h:360
Pointer< ENVIRONMENT > GetEnvironment()
Definition Final.h:212
Pointer< physical::Wave > Demodulate()
Definition Final.h:174
Final(const Name &name)
Definition Final.h:54
Pointer< physical::Wave > AsWave()
Definition Final.h:146
bool operator==(const Name &name) const
Definition Final.h:128
const T GetByName(const Name &name) const
Definition Final.h:354
bool Has(T content) const
Definition Final.h:280
T As()
Definition Final.h:399
void SetPerspective(Pointer< physical::Perspective< Id > > perspective)
Definition Final.h:505
Pointer< const Container > GetAll() const
Definition Final.h:274
bool IsNameInsensitive(const Name &name) const
Definition Final.h:495
unsigned int GetNumMatching(Pointer< const Container > other) const
Definition Final.h:286
bool operator==(const physical::Identifiable< Id > &other) const
Definition Final.h:133
void operator+(Pointer< const physical::Wave > other)
Definition Final.h:113
void SetName(const Name &name)
Definition Final.h:480
Properties GetProperties() const
Definition Final.h:158
void operator-(Pointer< const physical::Wave > other)
Definition Final.h:118
void Import(Pointer< const chemical::LinearMotif< T > > other)
Definition Final.h:245
Pointer< const physical::Wave > operator*() const
Definition Final.h:108
Pointer< physical::Wave > Clone() const
Definition Final.h:142
void Import(Pointer< const chemical::UnorderedMotif< T > > other)
Definition Final.h:239
T Add(const T t)
Definition Final.h:227
bool FormBond(T toBond, BondType type=bond_type::Unknown())
Definition Final.h:411
Pointer< chemical::Atom > AsAtom()
Definition Final.h:162
Index GetCount() const
Definition Final.h:262
Pointer< physical::Perspective< Id > > GetPerspective() const
Definition Final.h:515
void Import(const ::bio::Arrangement< T > &other)
Definition Final.h:251
Pointer< Container > GetAll()
Definition Final.h:268
bool IsName(const Name &name) const
Definition Final.h:490
void Enable()
Definition Final.h:381
Pointer< physical::Wave > operator*()
Definition Final.h:103
Code Insert(T toAdd, const Position position=BOTTOM, const Id optionalPositionArg=0, const bool transferSubContents=false)
Definition Final.h:320
Code Disattenuate(Pointer< const physical::Wave > other)
Definition Final.h:186
const T As() const
Definition Final.h:405
bool IsEnabled() const
Definition Final.h:389
bool BreakBond(T toDisassociate, BondType type=bond_type::Unknown())
Definition Final.h:419
bool operator==(const Id id) const
Definition Final.h:123
Code ImportAll(Pointer< const physical::Wave > other)
Definition Final.h:256
void SetId(const Id &id)
Definition Final.h:485
Code Remove(const T t)
Definition Final.h:233
std::string GetStringFrom(std::string separator=", ")
Definition Final.h:304
Pointer< physical::Wave > Modulate(Pointer< physical::Wave > signal)
Definition Final.h:170
Pointer< const physical::Symmetry > Spin() const
Definition Final.h:524
Pointer< const ::bio::log::Writer > AsLogWriter() const
Definition Final.h:190
void Log()
Definition Final.h:310
void operator|(Pointer< physical::Symmetry > symmetry)
Definition Final.h:93
const T GetById(const Id &id) const
Definition Final.h:342
void Log(::bio::LogLevel level, const char *format, va_list args) const
Definition Final.h:194
Pointer< chemical::Bonds > GetAllBonds()
Definition Final.h:436
void MakeWave(bool force=false)
Definition Final.h:510
chemical::Emission ForEach(Pointer< chemical::ExcitationBase > excitation)
Definition Final.h:372
T GetByName(const Name &name)
Definition Final.h:348
bool RegisterProperties(const Properties &properties)
Definition Final.h:154
~Final()
Definition Final.h:70
void Disable()
Definition Final.h:385
Code Attenuate(Pointer< const physical::Wave > other)
Definition Final.h:182
Name GetName() const
Definition Final.h:470
Pointer< const chemical::Atom > AsAtom() const
Definition Final.h:166
bool HasAll(Pointer< const Container > contents) const
Definition Final.h:292
Definition Pointer.h:115
Definition String.h:55
Definition TransparentWrapper.h:64
CLASS mT
Definition TransparentWrapper.h:150
Definition LinearMotif.h:133
Definition UnorderedMotif.h:65
BondType Unknown()
Definition FinalCell.h:29
Position
Definition chemical/common/Types.h:59
@ BOTTOM
Definition chemical/common/Types.h:61