Develop Biology
The language of life
Insertion.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) 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
26
27namespace bio {
28namespace genetic {
29
30Insertion::Insertion(
31 chemical::Substance* toInsert,
32 Site site,
33 Name name
34)
35 :
36 physical::Class< Insertion >(this),
37 Localization(
38 0,
39 name
40 ),
41 m_toInsert(toInsert)
42{
43 SetSite(site); //virtual means nothing to ctors; do it again.
44}
45
46Insertion::~Insertion()
47{
48
49}
50
51chemical::Substance* Insertion::Seek(chemical::Substance* insertIn) const
52{
53 insertIn = ResolvePrevious(insertIn);
54
55 BIO_SANITIZE(insertIn && m_toInsert, ,
56 return insertIn);
57
58 if (m_site == InsertionSitePerspective::InvalidId())
59 {
60 return insertIn;
61 }
62
63 BIO_SANITIZE(mc_method, ,
64 return NULL)
65 ByteStream insertion(m_toInsert);
66 (const_cast< chemical::ExcitationBase* >(mc_method))->EditArg(
67 0,
68 insertion
69 );
70 ByteStream result;
71 mc_method->CallDown(
72 insertIn->AsWave(),
73 result
74 );
75 chemical::Substance* insert = ChemicalCast< chemical::Substance* >(Cast< physical::Wave* >(result.IKnowWhatImDoing())); //This is about as safe as we can get right now.
76 BIO_SANITIZE(insert, ,
77 return NULL)
78 return insert;
79}
80
81void Insertion::SetSite(Site site)
82{
83 //Assume Sites & Sites always match exactly.
84 m_site = site;
85 mc_method = InsertionSitePerspective::Instance().GetNewObjectFromIdAs< chemical::ExcitationBase* >(m_site);
86}
87
88void Insertion::InsertThis(chemical::Substance* toInsert)
89{
90 m_toInsert = toInsert;
91}
92
93chemical::Substance* Insertion::GetWhatWillBeInserted()
94{
95 return m_toInsert;
96}
97
98} //genetic namespace
99} //bio namespace
#define BIO_SANITIZE(test, success, failure)
void * IKnowWhatImDoing()
Definition: ByteStream.cpp:78
virtual Wave * AsWave()
Definition: Class.h:99
Definition: Cell.h:31
const char * Name
Definition: Types.h:46