Develop Biology
The language of life
PeriodicTable.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
24
25namespace bio {
26namespace chemical {
27
34class Element :
35 public Substance
36{
37public:
39 :
40 m_type(NULL)
41 {
42 }
43
44 virtual ~Element()
45 {
46 }
47
53};
54
56{
57
58}
59
61{
62
63}
64
66{
67 Properties ret;
68 Element* element = ForceCast< Element* >(Perspective::GetTypeFromId(id));
69 BIO_SANITIZE(element, ,
70 return ret);
71 LockThread();
72 ret = element->GetAllAsVector< Property >();
74 return ret;
75}
76
78{
80}
81
83 AtomicNumber id,
84 Property property
85)
86{
87 Properties properties;
88 properties.push_back(property);
89 return RecordPropertiesOf(
90 id,
91 properties
92 );
93}
94
96 Name name,
97 Property property
98)
99{
100 return RecordPropertyOf(
101 GetIdFromName(name),
102 property
103 );
104}
105
107 AtomicNumber id,
108 Properties properties
109)
110{
111 typename Hadits::iterator hdt = Find(id);
112 BIO_SANITIZE_AT_SAFETY_LEVEL_2(hdt == this->m_hadits.end(), ,
113 return InvalidId());
114
115 LockThread();
116 Element* element = ForceCast< Element* >(hdt->m_type);
117 if (!element)
118 {
119 element = new Element();
120 hdt->m_type = element->AsWave();
121 }
122 element->Import< Property >(properties);
123 UnlockThread();
124 return id;
125}
126
128 Name name,
129 Properties properties
130)
131{
132 return RecordPropertiesOf(
133 GetIdFromName(name),
134 properties
135 );
136}
137
139{
140 Element* element = ForceCast< Element* >(Perspective::GetTypeFromId(id));
141 BIO_SANITIZE(element, ,
142 return NULL);
143 return element->m_type;
144}
145
147 AtomicNumber id,
148 physical::Wave* type
149)
150{
151 Element* element = ForceCast< Element* >(Perspective::GetTypeFromId(id));
152 BIO_SANITIZE(element, ,
153 return false);
154 LockThread();
155 element->m_type = type;
156 UnlockThread();
157 return true;
158}
159
161{
162 Element* element = ForceCast< Element* >(Perspective::GetTypeFromId(id));
163 BIO_SANITIZE(element, ,
164 return false);
165 LockThread();
166 element->m_type = NULL;
167 UnlockThread();
168 return true;
169}
170
171} //chemical namespace
172} //bio namespace
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure)
#define BIO_SANITIZE(test, success, failure)
void LockThread() const
Definition: ThreadSafe.cpp:84
void UnlockThread() const
Definition: ThreadSafe.cpp:97
physical::Wave * m_type
const Properties GetPropertiesOf() const
virtual const physical::Wave * GetTypeFromId(AtomicNumber id) const
AtomicNumber RecordPropertiesOf(AtomicNumber id, Properties properties)
AtomicNumber RecordPropertyOf(AtomicNumber id, Property property)
virtual bool DisassociateType(AtomicNumber id)
virtual bool AssociateType(AtomicNumber id, physical::Wave *type)
void Import(const UnorderedMotif< T > *other)
virtual Wave * AsWave()
Definition: Class.h:99
virtual Id GetIdWithoutCreation(Name name) const
Definition: Perspective.h:310
uint16_t AtomicNumber
Definition: Types.h:72
Definition: Cell.h:31
const char * Name
Definition: Types.h:46
uint8_t Properties
Definition: Types.h:58