Develop Biology
The language of life
Bond.cpp
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#include "bio/chemical/Bond.h"
24#include "bio/physical/Wave.h"
26
27namespace bio {
28namespace chemical {
29
31 :
32 m_id(PeriodicTable::InvalidId()),
33 m_bonded(NULL),
34 m_type(bond_type::Empty())
35{
36}
37
39 AtomicNumber id,
40 physical::Wave* bonded,
41 BondType type
42)
43 :
44 m_id(id),
45 m_bonded(bonded),
46 m_type(type)
47{
48}
49
51{
52
53}
54
56 AtomicNumber id,
57 physical::Wave* bonded,
58 BondType type
59)
60{
61 BIO_SANITIZE(bonded, ,
62 return false);
63 m_id = id;
64 m_bonded = bonded;
65 m_type = type;
66 return true;
67}
68
70{
71 return m_id;
72}
73
75{
76 return m_bonded;
77}
78
80{
81 return m_bonded;
82}
83
84BondType Bond::GetType() const
85{
86 return m_type;
87}
88
89bool Bond::IsEmpty() const
90{
91 return m_bonded == NULL && m_type == bond_type::Empty();
92}
93
95{
96 //leave m_id intact.
97 m_bonded = NULL;
98 m_type = bond_type::Empty();
99}
100
101bool Bond::operator==(const AtomicNumber id) const
102{
103 return m_id == id;
104}
105
106bool Bond::operator==(const Bond& other) const
107{
108 return m_id == other.m_id;
109}
110
111} //chemical namespace
112} //bio namespace
#define BIO_SANITIZE(test, success, failure)
bool IsEmpty() const
Definition: Bond.cpp:89
bool operator==(const AtomicNumber id) const
Definition: Bond.cpp:101
BondType GetType() const
Definition: Bond.cpp:84
bool Form(AtomicNumber id, physical::Wave *bonded, BondType type=bond_type::Unknown())
Definition: Bond.cpp:55
AtomicNumber GetId() const
Definition: Bond.cpp:69
physical::Wave * GetBonded()
Definition: Bond.cpp:74
BondType Empty()
uint16_t AtomicNumber
Definition: Types.h:72
Definition: Cell.h:31