Develop Biology
The language of life
bio::physical::Wave Class Reference

#include <Wave.h>

+ Inheritance diagram for bio::physical::Wave:
+ Collaboration diagram for bio::physical::Wave:

Public Member Functions

 Wave (Symmetry *symmetry=NULL)
 
virtual ~Wave ()
 
virtual chemical::AtomAsAtom ()
 
virtual const chemical::AtomAsAtom () const
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual Code Attenuate (const Wave *other)
 
virtual WaveClone () const
 
virtual WaveDemodulate ()
 
virtual const WaveDemodulate () const
 
virtual Code Disattenuate (const Wave *other)
 
virtual Properties GetProperties () const
 
virtual WaveModulate (Wave *signal)
 
virtual Waveoperator* ()
 
virtual const Waveoperator* () const
 
virtual Waveoperator* (Wave *signal)
 
virtual void operator+ (const Wave *other)
 
virtual void operator- (const Wave *other)
 
virtual void operator| (Symmetry *symmetry)
 
virtual Code Reify (Symmetry *symmetry)
 
virtual SymmetrySpin () const
 

Static Public Member Functions

static Properties GetResonanceBetween (const Wave *wave, const Properties &properties)
 
static Properties GetResonanceBetween (const Wave *wave1, const Wave *wave2)
 
static Properties GetResonanceBetween (ConstWaves waves)
 

Protected Attributes

Wavem_signal
 
Symmetrym_symmetry
 

Detailed Description

A Wave is a base class for all Biology objects. Waves can be Periodic but do not have to be. By default, we assume Waves have no discernible frequency, amplitude, or any other Property. This is similar to a chaotic pattern or a wave modulated with enough signals that it becomes indiscernible from white noise / randomness. We do not / cannot make any assumptions about the ordering / pattern of a Wave at this level. Such Properties will only manifest in derived classes.

You should be able to upcast to Wave from any other class. Cloning a Wave should produce a functional fully derived class. This means that all diamond inheritance should be resolved by all children when calling Clone For downcasting to a derived class, you will need to use the chemical::Atom::Bond(...) methodology. See chemical/Atom.h for more info.

Waves may be Modulated to store additional signals and subsequently Demodulated in order to retrieve that original signal. In this way, any Wave can carry any other.

Definition at line 64 of file Wave.h.

Constructor & Destructor Documentation

◆ Wave()

bio::physical::Wave::Wave ( Symmetry symmetry = NULL)

Definition at line 32 of file Wave.cpp.

35 :
37 symmetry
38 ),
40 NULL
41 )
42{
43}
Wave * m_signal
Definition: Wave.h:277
Symmetry * m_symmetry
Definition: Wave.h:272

Referenced by Clone().

◆ ~Wave()

bio::physical::Wave::~Wave ( )
virtual

Definition at line 45 of file Wave.cpp.

46{
48 delete m_symmetry;
49 m_symmetry = NULL,);
50}
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure)

References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and m_symmetry.

Member Function Documentation

◆ AsAtom() [1/2]

virtual chemical::Atom * bio::physical::Wave::AsAtom ( )
inlinevirtual

For Downcasting. Because Wave cannot be virtually inherited and will likely become an ambiguous base, we commit a sin and provide a cheat. This method can be used to resolve any downcasting. For example: this->AsAtom()->As<Whatever>().

Returns
this as an Atom, if possible.

Definition at line 209 of file Wave.h.

210 {
211 return NULL;
212 }

Referenced by bio::chemical::UnorderedStructureInterface::ImportAll(), and bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation().

◆ AsAtom() [2/2]

virtual const chemical::Atom * bio::physical::Wave::AsAtom ( ) const
inlinevirtual

For Downcasting. Because Wave cannot be virtually inherited and will likely become an ambiguous base, we commit a sin and provide a cheat. This method can be used to resolve any downcasting. For example: this->AsAtom()->As<Whatever>().

Returns
this as an Atom, if possible.

Definition at line 221 of file Wave.h.

222 {
223 return NULL;
224 }

◆ AsWave() [1/2]

◆ AsWave() [2/2]

◆ Attenuate()

◆ Clone()

◆ Demodulate() [1/2]

Wave * bio::physical::Wave::Demodulate ( )
virtual

Treats *this as a carrier wave.

Returns
the signal carried by *this.

Definition at line 99 of file Wave.cpp.

100{
101 return m_signal;
102}

References m_signal.

Referenced by bio::chemical::Atom::Attenuate(), bio::chemical::Atom::Disattenuate(), and operator*().

◆ Demodulate() [2/2]

const Wave * bio::physical::Wave::Demodulate ( ) const
virtual

Treats *this as a carrier wave.

Returns
the signal carried by *this.

Definition at line 104 of file Wave.cpp.

105{
106 return m_signal;
107}

References m_signal.

◆ Disattenuate()

◆ GetProperties()

Properties bio::physical::Wave::GetProperties ( ) const
virtual

Waves, depending on their behavior, can have different Properties. GetProperties can be used for determining how to downcast *this. The Properties returned dictate what a Wave can do and / or what can be done with one. If we treat Properties as fourier components of a waveform, we could restate GetProperties as GetPeriodicComponents. In this context, "what a wave can do" and "what can be done with a wave" can be expressed as "which systems resonate with the wave in question" or "which systems have comparable periodic components", which is true here as well: when 2 Waves have the same Properties (i.e. Resonate with each other) they can be treated the same in some regard (perhaps they are "numeric" and can be "added") and when 2 waves have comparable properties, they can interact with each other. It is up to you and other users of this framework to determine which Properties to use where. This is your space, so make use of it when you feel it's appropriate. NOTE: Waves do not actually have m_properties. This method MUST be implemented by children in order to work. If using any chemical::Class or beyond, this method will be implemented for you. See chemical/Class.h for more info.

Returns
the Properties of *this (empty vector unless overridden).

Reimplemented in bio::cellular::PeakCarrierWave, bio::chemical::ExcitationBase, bio::chemical::ExcitationWithoutArgument< WAVE, RETURN >, bio::chemical::ExcitationWithArgument< WAVE, RETURN, ARGUMENT >, bio::chemical::ExcitationWithTwoArguments< WAVE, RETURN, ARGUMENT1, ARGUMENT2 >, and bio::physical::Periodic.

Definition at line 142 of file Wave.cpp.

143{
144 Properties ret;
145 return ret;
146}
uint8_t Properties
Definition: Types.h:58

References bio::Properties.

Referenced by GetResonanceBetween().

◆ GetResonanceBetween() [1/3]

Properties bio::physical::Wave::GetResonanceBetween ( const Wave wave,
const Properties properties 
)
static

Ease of use method for getting the Resonance between a Wave and a set of Properties

Parameters
wave
properties
Returns
the number of overlapping Properties between the Wave and Properties given.

Definition at line 148 of file Wave.cpp.

152{
153 class TempWave :
154 public Wave
155 {
156 public:
157 TempWave(Properties p)
158 :
159 m_properties(p)
160 {
161 }
162
163 ~TempWave()
164 {
165 }
166
167 virtual Properties GetProperties() const
168 {
169 return m_properties;
170 }
171
172 Properties m_properties;
173 };
174
175 ConstWaves waves;
176 waves.push_back(
177 wave
178 );
179 TempWave* twave = new TempWave(properties);
180 waves.push_back(
181 twave
182 );
183
185 waves
186 );
187
188 delete twave;
189 return ret;
190}
virtual Properties GetProperties() const
Definition: Wave.cpp:142
static Properties GetResonanceBetween(ConstWaves waves)
Definition: Wave.cpp:209
std::vector< const Wave * > ConstWaves
Definition: Wave.h:51

References GetProperties(), GetResonanceBetween(), and bio::Properties.

◆ GetResonanceBetween() [2/3]

Properties bio::physical::Wave::GetResonanceBetween ( const Wave wave1,
const Wave wave2 
)
static

Ease of use method for getting the Resonance between just 2 waves, rather than n.

Parameters
wave1
wave2
Returns
the number of overlapping Properties between both waves given.

Definition at line 192 of file Wave.cpp.

196{
197 ConstWaves waves;
198 waves.push_back(
199 wave1
200 );
201 waves.push_back(
202 wave2
203 );
204 return GetResonanceBetween(
205 waves
206 );
207}

References GetResonanceBetween().

◆ GetResonanceBetween() [3/3]

Properties bio::physical::Wave::GetResonanceBetween ( ConstWaves  waves)
static

Check how (and if) 2 Waves Resonate with each other. Resonance is defined as a commonality between 2 or more Waves. This is a little bit more generic than real life resonance, which is strictly a measure of increased amplitude when 2 or more waves interact. Here, Waves interacting could mean an increase in aperiodic behavior, where no frequency has any single discernible change to it, or any number of other complex transformations.

Parameters
waves
Returns
the number of overlapping Properties between both waves given.

Definition at line 209 of file Wave.cpp.

212{
213 Properties overlap;
214 BIO_SANITIZE(waves.size() && waves[0], ,
215 return overlap);
216 overlap = waves[0]->GetProperties();
217 BIO_SANITIZE_AT_SAFETY_LEVEL_2(waves.size() > 1, ,
218 return overlap);
219 std::vector< Properties::iterator > remBuffer;
220
221 for (
222 ConstWaves::const_iterator wav = waves.begin()++;
223 wav != waves.end();
224 ++wav
225 )
226 {
227 BIO_SANITIZE(*wav, ,
228 continue);
229
230 Properties wavProperties = (*wav)->GetProperties();
231 remBuffer.clear();
232 for (
233 Properties::iterator prp = overlap.begin();
234 prp != overlap.end();
235 ++prp
236 )
237 {
238 if (std::find(
239 wavProperties.begin(),
240 wavProperties.end(),
241 *prp
242 ) != wavProperties.end())
243 {
244 remBuffer.push_back(
245 prp
246 );
247 }
248 }
249 for (
250 std::vector< Properties::iterator >::iterator rem = remBuffer.begin();
251 rem != remBuffer.end();
252 ++rem
253 )
254 {
255 overlap.erase(
256 *rem
257 );
258 }
259 }
260 return overlap;
261}
#define BIO_SANITIZE(test, success, failure)

References BIO_SANITIZE, BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::Properties.

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::Attenuate(), bio::chemical::Atom::Attenuate(), bio::chemical::Atom::Disattenuate(), GetResonanceBetween(), bio::chemical::UnorderedStructureInterface::ImportAll(), and bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation().

◆ Modulate()

Wave * bio::physical::Wave::Modulate ( Wave signal)
virtual

This will overwrite any signal currently carried by *this.

Returns
the signal Modulated.

Definition at line 91 of file Wave.cpp.

94{
95 m_signal = signal;
96 return this;
97}

References m_signal.

Referenced by bio::cellular::PeakCarrierWave::PeakCarrierWave(), and operator*().

◆ operator*() [1/3]

Wave * bio::physical::Wave::operator* ( )
virtual

Demodulate operator (i.e. not "dereference")

Returns
Demodulate()

Definition at line 118 of file Wave.cpp.

119{
120 return Demodulate();
121}
virtual Wave * Demodulate()
Definition: Wave.cpp:99

References Demodulate().

◆ operator*() [2/3]

const Wave * bio::physical::Wave::operator* ( ) const
virtual

Demodulate operator (i.e. not "dereference")

Returns
Demodulate()

Definition at line 123 of file Wave.cpp.

124{
125 return Demodulate();
126}

References Demodulate().

◆ operator*() [3/3]

Wave * bio::physical::Wave::operator* ( Wave signal)
virtual

Modulate operator (i.e. not "multiply")

Parameters
signal
Returns
Modulate(signal)

Definition at line 109 of file Wave.cpp.

112{
113 return Modulate(
114 signal
115 );
116}
virtual Wave * Modulate(Wave *signal)
Definition: Wave.cpp:91

References Modulate().

◆ operator+()

void bio::physical::Wave::operator+ ( const Wave other)
virtual

Makes other interfere with *this. Attenuates other.

Parameters
other

Definition at line 128 of file Wave.cpp.

131{
132 Attenuate(other);
133}
virtual Code Attenuate(const Wave *other)
Definition: Wave.cpp:81

References Attenuate().

◆ operator-()

void bio::physical::Wave::operator- ( const Wave other)
virtual

Removes the interference of other from *this. Disattenuates other.

Parameters
other

Definition at line 135 of file Wave.cpp.

138{
139 Disattenuate(other);
140}
virtual Code Disattenuate(const Wave *other)
Definition: Wave.cpp:86

References Disattenuate().

◆ operator|()

void bio::physical::Wave::operator| ( Symmetry symmetry)
virtual

Reifies *this. (*myParticle) | jsonAxis("...");

Parameters
symmetry

Definition at line 72 of file Wave.cpp.

75{
76 Reify(
77 symmetry
78 );
79}
virtual Code Reify(Symmetry *symmetry)
Definition: Wave.cpp:64

References Reify().

◆ Reify()

Code bio::physical::Wave::Reify ( Symmetry symmetry)
virtual

Reifying a Wave takes a Symmetry and realizes it by copying the values supplied into *this. Will update m_symmetry to the Symmetry provided but do nothing else. You should override Reify to update the contents of *this from the given Symmetry. Calling the parent method after is optional. See Quantum.h for an example interface.

Parameters
symmetry

Reimplemented in bio::chemical::Atom, bio::molecular::Molecule, bio::molecular::Surface, bio::physical::Filterable, bio::physical::Periodic, and bio::physical::Quantum< T >.

Definition at line 64 of file Wave.cpp.

67{
68 (*m_symmetry) = *symmetry;
69 return code::Success();
70}
Code Success()

References bio::code::Success().

Referenced by operator|().

◆ Spin()

Symmetry * bio::physical::Wave::Spin ( ) const
virtual

Spinning a Wave produces a Symmetry. Waves can be Rotated about any number of Axes. Spinning a Wave along one dimension (one Axis) would be the equivalent of reflecting that Wave or, possibly, refracting, dispersing, or otherwise altering the wave (e.g. if the Axis acted like a prism, rather than a mirror). When a Wave is Spun around multiple dimensions, the resulting Symmetry and effected transformations may not fall under any single property characteristic of real waves. Thus we treat Waves more like particles with a discrete spin.

You can visualize this by imagining a triangle that is then folded over to produce a polygon. Reflecting a triangle about 1 axis generates a rectangle, 2 a square, 3 a hexagon, 4 an octagon, and so on (sides = 3 + fibonacci sequence, starting at 0). Though, in this system, Axes do not overlap, so 1/2 of the polygon is discarded, once n >= 2. In this way, Spin() generates a triangle and you decide the shape by specifying how many Axes to Rotate the Symmetry about.

You should override Spin to update m_symmetry, then return the parent method. See Quantum.h for an example interface.

Returns
m_symmetry.

Reimplemented in bio::chemical::Atom, bio::molecular::Molecule, bio::molecular::Surface, bio::physical::Filterable, bio::physical::Periodic, and bio::physical::Quantum< T >.

Definition at line 59 of file Wave.cpp.

60{
61 return m_symmetry;
62}

References m_symmetry.

Referenced by bio::physical::Axis::operator|(), bio::physical::Filterable::Spin(), bio::physical::Periodic::Spin(), and bio::physical::Quantum< T >::Spin().

Member Data Documentation

◆ m_signal

Wave* bio::physical::Wave::m_signal
protected

for Modulation.

Definition at line 277 of file Wave.h.

Referenced by Demodulate(), and Modulate().

◆ m_symmetry

Symmetry* bio::physical::Wave::m_symmetry
protected

We cache our Symmetry here to avoid excessive new & deletes when Spinning & Reifying *this.

Definition at line 272 of file Wave.h.

Referenced by ~Wave(), bio::physical::Filterable::Spin(), bio::physical::Periodic::Spin(), bio::physical::Quantum< T >::Spin(), and Spin().


The documentation for this class was generated from the following files: