Develop Biology
The language of life
Molecule.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
27#include "Surface.h"
29
30namespace bio {
31namespace molecular {
32
72class Molecule :
73 public Class< Molecule >,
74 public physical::Perspective< StandardDimension >,
75 public chemical::LinearMotif< Surface* >
76{
77public:
78
84
89 &MoleculePerspective::Instance(),
91
92
96 Molecule(const Molecule& toCopy);
97
101 virtual ~Molecule();
102
111 template < typename T >
112 StandardDimension Use(
113 Name varName,
114 T* varPtr
115 )
116 {
117 BIO_SANITIZE(!RotateTo(varName), ,
118 return InvalidId());
119 Surface* toAdd = new Surface(
120 varName,
121 this
122 );
123 toAdd->Use(varPtr);
124 Add< Surface* >(toAdd);
125 return toAdd->GetId();
126 }
127
135 StandardDimension Define(Name varName)
136 {
137 BIO_SANITIZE(!RotateTo(varName), ,
138 return InvalidId());
139 Surface* toAdd = new Surface(
140 varName,
141 this
142 );
143 Add< Surface* >(toAdd);
144 return toAdd->GetId();
145 }
146
154 template < typename T >
155 StandardDimension Define(Name varName)
156 {
157 BIO_SANITIZE(!RotateTo(varName), ,
158 return InvalidId());
159 Surface* toAdd = new Surface(
160 varName,
161 this
162 );
163 toAdd->Manage(new T());
164 Add< Surface* >(toAdd);
165 return toAdd->GetId();
166 }
167
177 template < typename T >
178 StandardDimension Define(
179 Name varName,
180 const T& assignment
181 )
182 {
183 BIO_SANITIZE(!RotateTo(varName), ,
184 return InvalidId());
185 Surface* toAdd = new Surface(
186 varName,
187 this
188 );
189 toAdd->Manage(new T(assignment));
190 Add< Surface* >(toAdd);
191 return toAdd->GetId();
192 }
193
201 virtual Surface* RotateTo(StandardDimension surfaceId);
202
208 virtual const Surface* RotateTo(StandardDimension surfaceId) const;
209
215 template < typename T >
216 T RotateTo(StandardDimension surfaceId) const
217 {
218 return ChemicalCast< T >(RotateTo(surfaceId));
219 }
220
227 virtual Surface* RotateTo(Name surfaceName);
228
234 virtual const Surface* RotateTo(Name surfaceName) const;
235
241 template < typename T >
242 T RotateTo(Name surfaceName) const
243 {
244 return ChemicalCast< T >(RotateTo(surfaceName));
245 }
246
253 virtual bool DuplicateFrom(
254 Molecule* source,
255 Name surface
256 );
257
264 virtual bool TransferFrom(
265 Molecule* source,
266 Name surface
267 );
268
273 virtual physical::Symmetry* Spin() const;
274
280 virtual Code Reify(physical::Symmetry* symmetry);
281
288 virtual Surface* operator()(StandardDimension surfaceId);
289
290 virtual const Surface* operator()(StandardDimension surfaceId) const;
291
292 template < typename T >
293 Surface* operator()(StandardDimension surfaceId)
294 {
295 return ChemicalCast< T >(RotateTo(surfaceId));
296 }
297
298 virtual Surface* operator()(Name name);
299
300 virtual const Surface* operator()(Name name) const;
301
302 template < typename T >
303 Surface* operator()(Name surfaceName)
304 {
305 return ChemicalCast< T >(RotateTo(surfaceName));
306 }
315 virtual Molecule* operator<<(Surface* source);
316
325 virtual Surface* operator>>(Surface* target);
326
333 virtual Molecule* operator<<(Molecule* source);
334
342 virtual Molecule* operator>>(Molecule* target);
343};
344
345
346} //molecular namespace
347} //bio namespace
#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(ns, class,...)
#define BIO_SANITIZE(test, success, failure)
T RotateTo(StandardDimension surfaceId) const
Definition: Molecule.h:216
virtual bool TransferFrom(Molecule *source, Name surface)
Definition: Molecule.cpp:105
T RotateTo(Name surfaceName) const
Definition: Molecule.h:242
Surface * operator()(Name surfaceName)
Definition: Molecule.h:303
BIO_DISAMBIGUATE_ALL_CLASS_METHODS(molecular, Molecule) BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(molecular
virtual Surface * operator()(StandardDimension surfaceId)
Definition: Molecule.cpp:127
virtual Surface * RotateTo(StandardDimension surfaceId)
Definition: Molecule.cpp:48
StandardDimension Define(Name varName)
Definition: Molecule.h:155
virtual physical::Symmetry * Spin() const
Definition: Molecule.cpp:180
StandardDimension Define(Name varName, const T &assignment)
Definition: Molecule.h:178
Surface * operator()(StandardDimension surfaceId)
Definition: Molecule.h:293
virtual Surface * operator>>(Surface *target)
Definition: Molecule.cpp:155
virtual Molecule * operator<<(Surface *source)
Definition: Molecule.cpp:147
virtual Code Reify(physical::Symmetry *symmetry)
Definition: Molecule.cpp:186
StandardDimension Define(Name varName)
Definition: Molecule.h:135
StandardDimension Use(Name varName, T *varPtr)
Definition: Molecule.h:112
virtual bool DuplicateFrom(Molecule *source, Name surface)
Definition: Molecule.cpp:84
T Manage(T varPtr)
Definition: Surface.h:97
Filter Molecular()
Definition: Cell.h:31
const char * Name
Definition: Types.h:46