Develop Biology
The language of life
bio::genetic::Localization Class Reference

#include <Localization.h>

+ Inheritance diagram for bio::genetic::Localization:
+ Collaboration diagram for bio::genetic::Localization:

Public Member Functions

virtual ~Localization ()
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Localization) explicit Localization(Site site
 
virtual Name GetNameOfSite () const
 
virtual Site GetSite () const
 
virtual chemical::SubstanceSeek (chemical::Substance *seekIn) const
 
virtual void SetNameOfSite (Name name)
 
virtual void SetSite (Site site)
 

Public Attributes

Name name
 

Protected Member Functions

chemical::SubstanceResolvePrevious (chemical::Substance *seekIn) const
 

Protected Attributes

Name m_name
 
Localizationm_previous
 
Site m_site
 
chemical::ExcitationBasemc_method
 

Detailed Description

Localizations are a chain of named places. Each place is a different Localization, which has more places (Localizations) around it. This system allows us to traverse arbitrarily complex spaces with ease.

In order to use a standard interface with arbitrarily complex containers, we rely on physical::Perspective::AssociateType(), chemical::Excitation, and the chemical/structure system to provide us with a means of translating a Site (AssociateType) into a class method (Excitation) that is used to query a container by Name (structure). See genetic/Macros.h for an easy way to define all that (its not nearly as hard to use as it is to implement).

For specifying a series of places, we use the already existing physical::Wave Modulation system in reverse order; meaning the Modulated signal is what should be evaluated BEFORE *this. Evaluation here means Localization::Seek() (past tense as Sought). If you can imagine a real-life wave being modulated, that is, having smaller waves that it carries, then visualizing this system should be easy: the largest wave is what we really want to do, which can only happen once the smaller waves have been resolved; so, we take a large wave of interest and look deeper and deeper into its more subtle fluctuations as we search larger and larger contexts, until we find what we are seeking.

To create a localization, first select the kind of place you want from the available LocalizationTypes (in the localization_type namespace). Next, note the Name of the desired place. And, lastly, instantiate a Localization. If you would like to identify a place within another place, simple repeat and Modulate the first Localization with the second. For example, if you want to identify where the bathroom is within a restaurant, we would start with a Localization like {localization_site::Room(), "Bathroom"}, which might cause us to ask the nearest person for the "Bathroom". Next, we would create another Localization along the lines of {localization_site::StreetAddress(), "MyFavoriteRestaurant"}. In this case, StreetAddress would tell us to use a navigation app and maybe a car or taxi service to "extract" the restaurant form the world. Then, we say bathroomLocalization % restaurantLocalization. Thus, we end up with all the information necessary to "extract" the "Bathroom" from "MyFavoriteRestaurant".

Definition at line 56 of file Localization.h.

Constructor & Destructor Documentation

◆ ~Localization()

bio::genetic::Localization::~Localization ( )
virtual

Definition at line 43 of file Localization.cpp.

44{
45 if (m_name)
46 {
47 delete[] m_name;
48 m_name = NULL;
49 }
50 if (mc_method)
51 {
52 delete mc_method;
53 mc_method = NULL;
54 }
55}
chemical::ExcitationBase * mc_method
Definition: Localization.h:125

Member Function Documentation

◆ BIO_DISAMBIGUATE_ALL_CLASS_METHODS()

bio::genetic::Localization::BIO_DISAMBIGUATE_ALL_CLASS_METHODS ( physical  ,
Localization   
)

Ensure virtual methods point to Class implementations.

Parameters
site
name

◆ GetNameOfSite()

Name bio::genetic::Localization::GetNameOfSite ( ) const
virtual

Get the Name to use with m_site.

Returns
m_name.

Definition at line 114 of file Localization.cpp.

115{
116 return m_name;
117}

◆ GetSite()

Site bio::genetic::Localization::GetSite ( ) const
virtual

Get m_site.

Returns
m_site.

Definition at line 129 of file Localization.cpp.

130{
131 return m_site;
132}

◆ ResolvePrevious()

chemical::Substance * bio::genetic::Localization::ResolvePrevious ( chemical::Substance seekIn) const
protected

To be run at the top of Seek.

Parameters
seekIn
Returns
the result of Seeking through all Modulated Localizations.

Definition at line 57 of file Localization.cpp.

58{
59 BIO_SANITIZE(seekIn, ,
60 return seekIn);
61
62 //TODO: What if *this has been Modulated with something other than a Localization?
63 Localization* previous = ForceCast< Localization* >(Demodulate());
64
65 if (previous)
66 {
67 seekIn = previous->Seek(seekIn);
68 }
69 return seekIn;
70}
#define BIO_SANITIZE(test, success, failure)
virtual Wave * Demodulate()
Definition: Wave.cpp:99

References BIO_SANITIZE, and Seek().

◆ Seek()

chemical::Substance * bio::genetic::Localization::Seek ( chemical::Substance seekIn) const
virtual

Find some place by following a chain of Localizations. Will recurse upward, following m_previous for as long as possible.

Parameters
seekIn
Returns
a Substance somewhere within the Substance provided or NULL.

Reimplemented in bio::genetic::Insertion.

Definition at line 72 of file Localization.cpp.

73{
74 seekIn = ResolvePrevious(seekIn);
75
76 BIO_SANITIZE(seekIn, ,
77 return seekIn);
78
79 if (m_site == LocalizationSitePerspective::InvalidId())
80 {
81 return seekIn;
82 }
83
85 return NULL)
86 ByteStream newName(m_name);
87 (const_cast< chemical::ExcitationBase* >(mc_method))->EditArg(
88 0,
89 newName
90 );
91 ByteStream result;
93 seekIn->AsWave(),
94 result
95 );
96 chemical::Substance* extract = ChemicalCast< chemical::Substance* >(Cast< physical::Wave* >(result.IKnowWhatImDoing())); //This is about as safe as we can get right now.
97 BIO_SANITIZE(extract, ,
98 return NULL)
99 return extract;
100}
virtual void CallDown(physical::Wave *wave, ByteStream *ret) const
Definition: Excitation.h:109
chemical::Substance * ResolvePrevious(chemical::Substance *seekIn) const

References bio::physical::Class< T >::AsWave(), BIO_SANITIZE, and bio::ByteStream::IKnowWhatImDoing().

Referenced by ResolvePrevious().

◆ SetNameOfSite()

void bio::genetic::Localization::SetNameOfSite ( Name  name)
virtual

Set m_name.

Parameters
name

Definition at line 102 of file Localization.cpp.

103{
104 if (m_name)
105 {
106 delete[] m_name;
107 }
109 name,
110 m_name
111 );
112}
void CloneInto(const char *source, const char *&target)
Definition: String.cpp:236

References bio::string::CloneInto().

◆ SetSite()

void bio::genetic::Localization::SetSite ( Site  site)
virtual

Set m_site.

Parameters
site

Reimplemented in bio::genetic::Insertion.

Definition at line 119 of file Localization.cpp.

120{
121 m_site = site;
122 if (mc_method)
123 {
124 delete mc_method;
125 }
126 mc_method = LocalizationSitePerspective::Instance().GetNewObjectFromIdAs< chemical::ExcitationBase* >(m_site);
127}

Member Data Documentation

◆ m_name

Name bio::genetic::Localization::m_name
protected

Definition at line 123 of file Localization.h.

◆ m_previous

Localization* bio::genetic::Localization::m_previous
protected

Definition at line 124 of file Localization.h.

◆ m_site

Site bio::genetic::Localization::m_site
protected

Definition at line 122 of file Localization.h.

◆ mc_method

chemical::ExcitationBase* bio::genetic::Localization::mc_method
protected

Definition at line 125 of file Localization.h.

◆ name

Name bio::genetic::Localization::name
Initial value:
= NULL
)

Definition at line 74 of file Localization.h.


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