Develop Biology
The language of life
Line.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
24
25namespace bio {
26namespace physical {
27
28Line::Line(Index expectedSize)
29 :
30 Arrangement< Linear >(expectedSize)
31{
32
33}
34
36{
37
38}
39
41{
42 return Cast< Identifiable< StandardDimension >* >(OptimizedAccess(index));
43}
44
45const ByteStream Line::Access(const Index index) const
46{
47 return Cast< Identifiable< StandardDimension >* >(OptimizedAccess(index));
48}
49
50bool Line::AreEqual(Index internal, const ByteStream external) const
51{
52 BIO_SANITIZE(external.Is< Identifiable< StandardDimension >* >(),,return false)
53 return OptimizedAccess(internal) == external.template As< const Identifiable< StandardDimension >* >();
54}
55
57{
58 return OptimizedAccess(index);
59}
60
62{
63 return OptimizedAccess(index);
64}
65
67{
68 if (!m_tempItt)
69 {
71 }
73 for (; !m_tempItt->IsAtBeginning(); --m_tempItt)
74 {
75 if (LinearAccess(m_tempItt->GetIndex())->IsName(name))
76 {
77 return m_tempItt->GetIndex();
78 }
79 }
80 return InvalidIndex();
81}
82
83Index Line::SeekToId(StandardDimension id)
84{
85 if (!m_tempItt)
86 {
88 }
90 for (; !m_tempItt->IsAtBeginning(); --m_tempItt)
91 {
92 if (LinearAccess(m_tempItt->GetIndex())->IsId(id))
93 {
94 return m_tempItt->GetIndex();
95 }
96 }
97 return InvalidIndex();
98}
99
100} //physical namespace
101} //bio namespace
#define BIO_SANITIZE(test, success, failure)
bool Is() const
Definition: ByteStream.h:183
virtual Iterator * ConstructClassIterator(const Index index=InvalidIndex()) const
Definition: Container.cpp:285
Iterator * m_tempItt
Definition: Container.h:350
virtual Index GetEndIndex() const
Definition: Container.cpp:69
bool MoveTo(const Index index)
Definition: Iterator.cpp:48
virtual bool IsAtBeginning() const
Definition: Iterator.cpp:58
Index GetIndex() const
Definition: Iterator.cpp:43
virtual Linear OptimizedAccess(Index index)
Definition: Arrangement.h:128
virtual Index SeekToId(StandardDimension id)
Definition: Line.cpp:83
virtual ~Line()
Definition: Line.cpp:35
Line(Index expectedSize=2)
Definition: Line.cpp:28
virtual Identifiable< StandardDimension > * LinearAccess(Index index)
Definition: Line.cpp:56
virtual bool AreEqual(Index internal, const ByteStream external) const
Definition: Line.cpp:50
virtual Index SeekToName(Name name)
Definition: Line.cpp:66
ByteStream Access(const Index index)
Definition: Line.cpp:40
Definition: Cell.h:31
uint32_t Index
Definition: Types.h:57
const char * Name
Definition: Types.h:46
const Index InvalidIndex()
Definition: Types.cpp:26