libbio
Loading...
Searching...
No Matches
Covalent.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
24#include "Atom.h"
27
28namespace bio {
29//not chemical.
30
39template < class T >
40class Covalent :
41 virtual public chemical::Atom
42{
43public:
48 //@formatter:off
50 mT(::bio::pointer_arena::New< T >())
51 #else
52 mT(new T())
53 #endif
54 //@formatter:on
55 {
57 }
58
63 mT(NULL)
64 {
65 if (other.mT)
66 {
67 //@formatter:off
68 #if BIO_COMPACT_POINTER_STORAGE
69 mT = ::bio::pointer_arena::NewCopy< T >(*other.mT);
70 #else
71 mT = new T(*other.mT);
72 #endif
73 //@formatter:on
75 }
76 }
77
81 virtual ~Covalent()
82 {
83 #if BIO_COMPACT_POINTER_STORAGE
85 #else
86 delete mT;
87 #endif
88 }
89
94 {
95 if (this == &other)
96 {
97 return *this;
98 }
99 if (mT)
100 {
102 //@formatter:off
103 #if BIO_COMPACT_POINTER_STORAGE
105 #else
106 delete mT;
107 #endif
108 //@formatter:on
109 mT = NULL;
110 }
111 if (other.mT)
112 {
113 //@formatter:off
114 #if BIO_COMPACT_POINTER_STORAGE
115 mT = ::bio::pointer_arena::NewCopy< T >(*other.mT);
116 #else
117 mT = new T(*other.mT);
118 #endif
119 //@formatter:on
121 }
122 return *this;
123 }
124
129 {
130 return mT;
131 }
132
137 {
138 return mT;
139 }
140
141protected:
143};
144
145} //bio namespace
#define BIO_COMPACT_POINTER_STORAGE
Definition OptimizeMacros.h:87
Definition Covalent.h:42
virtual ~Covalent()
Definition Covalent.h:81
Pointer< const T > Object() const
Definition Covalent.h:136
Covalent(const Covalent &other)
Definition Covalent.h:62
Pointer< T > mT
Definition Covalent.h:142
Covalent & operator=(const Covalent &other)
Definition Covalent.h:93
Pointer< T > Object()
Definition Covalent.h:128
Covalent()
Definition Covalent.h:47
Definition Pointer.h:115
T * Get() const
Definition Pointer.h:271
Definition Atom.h:154
Valence FormBond(T toBond, BondType type=bond_type::Unknown())
Definition Atom.h:404
bool BreakBond(T toDisassociate, BondType type=bond_type::Unknown())
Definition Atom.h:475
BondType Covalent()
void Delete(T *raw)
Definition PointerArena.h:525
Definition FinalCell.h:29