Develop Biology
The language of life
bio::chemical::UnorderedStructureInterface Class Reference

#include <UnorderedStructureInterface.h>

+ Inheritance diagram for bio::chemical::UnorderedStructureInterface:
+ Collaboration diagram for bio::chemical::UnorderedStructureInterface:

Public Member Functions

 UnorderedStructureInterface ()
 
virtual ~UnorderedStructureInterface ()
 
template<typename T >
Add (const T t)
 
template<typename T >
void Clear ()
 
template<typename T >
ContainerGetAll ()
 
template<typename T >
const ContainerGetAll () const
 
template<typename T >
std::vector< T > GetAllAsVector ()
 
template<typename T >
const std::vector< T > GetAllAsVector () const
 
template<typename T >
unsigned long GetCount () const
 
template<typename T >
unsigned int GetNumMatching (const Container *other) const
 
template<typename T >
std::string GetStringFrom (std::string separator=", ")
 
template<typename T >
bool Has (T content) const
 
template<typename T >
bool HasAll (const Container *contents) const
 
template<typename T >
void Import (const std::vector< T > &other)
 
template<typename T >
void Import (const UnorderedMotif< T > *other)
 
Code ImportAll (const physical::Wave *other)
 
template<typename T >
Remove (const T t)
 
- Public Member Functions inherited from bio::ThreadSafe
 ThreadSafe ()
 
 ThreadSafe (const ThreadSafe &toCopy)
 
virtual ~ThreadSafe ()
 
void LockThread () const
 
void UnlockThread () const
 
- Public Member Functions inherited from bio::chemical::Atom
 Atom (const Atom &other)
 
virtual ~Atom ()
 
template<typename T >
As ()
 
template<typename T >
const T As () const
 
template<typename T >
AsBonded ()
 
template<typename T >
const T AsBonded () const
 
template<typename T >
AsBondedQuantum ()
 
template<typename T >
const T AsBondedQuantum () const
 
virtual Code Attenuate (const Wave *other)
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Atom) explicit Atom()
 
template<typename T >
bool BreakBond (T toDisassociate, BondType type=bond_type::Unknown())
 
virtual Code Disattenuate (const Wave *other)
 
template<typename T >
bool FormBond (T toBond, BondType type=bond_type::Unknown())
 
BondsGetAllBonds ()
 
const BondsGetAllBonds () const
 
WaveGetBonded (Valence position)
 
const WaveGetBonded (Valence position) const
 
template<typename T >
Valence GetBondPosition () const
 
Valence GetBondPosition (AtomicNumber bondedId) const
 
Valence GetBondPosition (Name typeName) const
 
template<typename T >
BondType GetBondType () const
 
BondType GetBondType (Valence position) const
 
template<typename T >
 operator T ()
 
virtual Code Reify (physical::Symmetry *symmetry)
 
virtual physical::SymmetrySpin () const
 
- Public Member Functions inherited from bio::physical::Class< Atom >
 Class (Atom *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
Atom * Convert (Wave *wave)
 
virtual operator Atom * ()
 
virtual operator Wave * ()
 
- Public Member Functions inherited from bio::physical::Wave
 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
 

Additional Inherited Members

- Static Public Member Functions inherited from bio::physical::Wave
static Properties GetResonanceBetween (const Wave *wave, const Properties &properties)
 
static Properties GetResonanceBetween (const Wave *wave1, const Wave *wave2)
 
static Properties GetResonanceBetween (ConstWaves waves)
 
- Protected Member Functions inherited from bio::chemical::Atom
virtual bool BreakBondImplementation (Wave *toDisassociate, AtomicNumber id, BondType type)
 
virtual bool FormBondImplementation (Wave *toBond, AtomicNumber id, BondType type)
 
- Protected Attributes inherited from bio::chemical::Atom
Bonds m_bonds
 
- Protected Attributes inherited from bio::physical::Class< Atom >
Atom * m_object
 
- Protected Attributes inherited from bio::physical::Wave
Wavem_signal
 
Symmetrym_symmetry
 

Detailed Description

Interface methods for all UnorderedMotif classes.

Definition at line 34 of file UnorderedStructureInterface.h.

Constructor & Destructor Documentation

◆ UnorderedStructureInterface()

bio::chemical::UnorderedStructureInterface::UnorderedStructureInterface ( )
inline

Definition at line 43 of file UnorderedStructureInterface.h.

44 {
45 }

◆ ~UnorderedStructureInterface()

virtual bio::chemical::UnorderedStructureInterface::~UnorderedStructureInterface ( )
inlinevirtual

Definition at line 50 of file UnorderedStructureInterface.h.

51 {
52 }

Member Function Documentation

◆ Add()

template<typename T >
T bio::chemical::UnorderedStructureInterface::Add ( const T  t)
inline

Adds to *this using the appropriate interface for T. Does not allow duplicates.

Template Parameters
T
Parameters
t
Returns
the t inserted or 0; 0 if T is invalid.

Definition at line 63 of file UnorderedStructureInterface.h.

64 {
65 T ret = 0;
66 LockThread();
67 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
68 if (implementer)
69 {
70 ret = implementer->AddImplementation(t);
71 }
73 return ret;
74 }
void LockThread() const
Definition: ThreadSafe.cpp:84
void UnlockThread() const
Definition: ThreadSafe.cpp:97

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::AddImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

Referenced by bio::genetic::GenomeDefault::GenomeDefault(), bio::genetic::RNAPolymerase::Activate(), and bio::molecular::Molecule::operator>>().

◆ Clear()

template<typename T >
void bio::chemical::UnorderedStructureInterface::Clear ( )
inline

Removes all T from *this. Does not delete the contents! Does nothing if T is invalid.

Template Parameters
T

Definition at line 302 of file UnorderedStructureInterface.h.

303 {
304 LockThread();
305 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
306 if (implementer)
307 {
308 implementer->ClearImplementation();
309 }
310 UnlockThread();
311 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::ClearImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ GetAll() [1/2]

template<typename T >
Container * bio::chemical::UnorderedStructureInterface::GetAll ( )
inline

USE WITH CAUTION!!!

Template Parameters
T
Returns
A pointer to all contents in *this; 0 if T is invalid.

Definition at line 202 of file UnorderedStructureInterface.h.

203 {
204 Container* ret = 0;
205 LockThread();
206 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
207 if (implementer)
208 {
209 ret = implementer->GetAllImplementation();
210 }
211 UnlockThread();
212 return ret;
213 }

References bio::chemical::AbstractMotif::GetAllImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

Referenced by bio::genetic::RNAPolymerase::Activate(), and bio::chemical::Axis::Rotate().

◆ GetAll() [2/2]

template<typename T >
const Container * bio::chemical::UnorderedStructureInterface::GetAll ( ) const
inline

Safer, const version of above.

Template Parameters
T
Returns
A pointer to all contents in *this; 0 if T is invalid.

Definition at line 222 of file UnorderedStructureInterface.h.

223 {
224 Container* ret = 0;
225 LockThread();
226 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
227 if (implementer)
228 {
229 ret = implementer->GetAllImplementation();
230 }
231 UnlockThread();
232 return ret;
233 }

References bio::chemical::AbstractMotif::GetAllImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ GetAllAsVector() [1/2]

template<typename T >
std::vector< T > bio::chemical::UnorderedStructureInterface::GetAllAsVector ( )
inline

Ease of use wrapper around casting the contents of *this as a std::vector.

Template Parameters
T
Returns
the contents of *this casted to an std::vector.

Definition at line 338 of file UnorderedStructureInterface.h.

339 {
340 return this->template GetAll< T >()->
341 template AsVector< T >();
342 }

Referenced by bio::chemical::PeriodicTableImplementation::GetPropertiesOf().

◆ GetAllAsVector() [2/2]

template<typename T >
const std::vector< T > bio::chemical::UnorderedStructureInterface::GetAllAsVector ( ) const
inline

Ease of use wrapper around casting the contents of *this as a std::vector.

Template Parameters
T
Returns
the contents of *this casted to an std::vector.

Definition at line 350 of file UnorderedStructureInterface.h.

351 {
352 return this->template GetAll< T >()->
353 template AsVector< T >();
354 }

◆ GetCount()

template<typename T >
unsigned long bio::chemical::UnorderedStructureInterface::GetCount ( ) const
inline

Gives the number of T in *this

Template Parameters
T
Returns
the size of contents; 0 if T is invalid.

Definition at line 182 of file UnorderedStructureInterface.h.

183 {
184 unsigned long ret = 0;
185 LockThread();
186 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
187 if (implementer)
188 {
189 ret = implementer->GetCountImplementation();
190 }
191 UnlockThread();
192 return ret;
193 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::GetCountImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ GetNumMatching()

template<typename T >
unsigned int bio::chemical::UnorderedStructureInterface::GetNumMatching ( const Container other) const
inline

Gives the number of matching contents between *this & other.

Parameters
other
Returns
quantity overlap with other; 0 if T is invalid.

Definition at line 262 of file UnorderedStructureInterface.h.

263 {
264 unsigned int ret = 0;
265 LockThread();
266 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
267 if (implementer)
268 {
269 ret = implementer->GetNumMatchingImplementation(other);
270 }
271 UnlockThread();
272 return ret;
273 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::GetNumMatchingImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ GetStringFrom()

template<typename T >
std::string bio::chemical::UnorderedStructureInterface::GetStringFrom ( std::string  separator = ", ")
inline

Get the Contents of *this as a string.

Parameters
separatore.g. ", ", the default, or just " ".
Returns
the Contents of *this as a string; "" if T is invalid.

Definition at line 319 of file UnorderedStructureInterface.h.

320 {
321 std::string ret = "";
322 LockThread();
323 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
324 if (implementer)
325 {
326 ret = implementer->GetStringFromImplementation(separator);
327 }
328 UnlockThread();
329 return ret;
330 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::GetStringFromImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ Has()

template<typename T >
bool bio::chemical::UnorderedStructureInterface::Has ( content) const
inline

Check for content.

Template Parameters
T
Parameters
content
Returns
whether or not content exists in *this; false if T is invalid.

Definition at line 243 of file UnorderedStructureInterface.h.

244 {
245 bool ret = false;
246 LockThread();
247 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
248 if (implementer)
249 {
250 ret = implementer->HasImplementation(content);
251 }
252 UnlockThread();
253 return ret;
254 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::HasImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

◆ HasAll()

template<typename T >
bool bio::chemical::UnorderedStructureInterface::HasAll ( const Container contents) const
inline

Check if *this contains all of the given contents Should NOT check if the given contents contain all those of *this.

Parameters
content
Returns
whether or not the given contents exists in *this

Definition at line 282 of file UnorderedStructureInterface.h.

283 {
284 bool ret = false;
285 LockThread();
286 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
287 if (implementer)
288 {
289 ret = implementer->HasAllImplementation(contents);
290 }
291 UnlockThread();
292 return ret;
293 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::HasAllImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

Referenced by bio::genetic::RNAPolymerase::Activate(), and bio::chemical::Reaction::ReactantsMeetRequirements().

◆ Import() [1/2]

template<typename T >
void bio::chemical::UnorderedStructureInterface::Import ( const std::vector< T > &  other)
inline

Copy the contents of a vector into *this. Will only work if *this contains an UnorderedMotif of the given type. Does nothing if T is invalid.

Template Parameters
T
Parameters
other

Definition at line 124 of file UnorderedStructureInterface.h.

125 {
126 for (
127 typename std::vector< T >::const_iterator otr = other.begin();
128 otr != other.end();
129 ++otr
130 )
131 {
132 this->Add< T >(*otr);
133 }
134 }

◆ Import() [2/2]

template<typename T >
void bio::chemical::UnorderedStructureInterface::Import ( const UnorderedMotif< T > *  other)
inline

Copy the contents of another container into *this. Does nothing if T is invalid.

Template Parameters
T
Parameters
other

Definition at line 105 of file UnorderedStructureInterface.h.

106 {
107 LockThread();
108 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
109 if (implementer)
110 {
111 implementer->ImportImplementation(other);
112 }
113 UnlockThread();
114 }

References bio::chemical::UnorderedMotif< CONTENT_TYPE >::ImportImplementation(), bio::ThreadSafe::LockThread(), and bio::ThreadSafe::UnlockThread().

Referenced by bio::cellular::Tissue::DifferentiateCells(), bio::molecular::Molecule::operator>>(), bio::molecular::Vesicle::operator>>=(), and bio::chemical::PeriodicTableImplementation::RecordPropertiesOf().

◆ ImportAll()

Code bio::chemical::UnorderedStructureInterface::ImportAll ( const physical::Wave other)
inline

This method does way more than it should reasonably be able to. Here, we take advantage of some of the Biology features that are starting to form. Primarily, we leverage physical::Properties and Bonds (per Atom) to search through the pseudo-vtable of Atom, find all StructuralComponents in *this and attempt to Import the corresponding StructuralComponents of other. This method side-steps the typical inheritance encapsulation in order to prevent child classes from having to override this method and account for each new UnorderedMotif they add. In other words, complexity here removes repeated code downstream.

Parameters
other

Definition at line 142 of file UnorderedStructureInterface.h.

143 {
144 BIO_SANITIZE(other && other->AsAtom(), ,
145 return code::BadArgument1())
146
147 Code ret = code::Success();
148
149 LockThread(); // in case m_bonds changes.
150 Bond* bondBuffer;
151 for (
152 SmartIterator bnd = other->AsAtom()->GetAllBonds()->End();
153 !bnd.IsAtBeginning();
154 --bnd
155 )
156 {
157 bondBuffer = bnd;
158 if (bondBuffer->IsEmpty())
159 {
160 continue;
161 }
163 bondBuffer->GetBonded(),
165 {
166 continue;
167 }
168 const physical::Wave* otherBond = other->AsAtom()->GetBonded(other->AsAtom()->GetBondPosition(bondBuffer->GetId()));
169 (Cast< AbstractMotif* >(bondBuffer->GetBonded()))->ImportImplementation(otherBond); //actual work
170 }
171 UnlockThread();
172
173 return ret;
174 }
#define BIO_SANITIZE(test, success, failure)
static Properties GetClassProperties()
Bonds * GetAllBonds()
Definition: Atom.cpp:224
virtual chemical::Atom * AsAtom()
Definition: Wave.h:209
static Properties GetResonanceBetween(ConstWaves waves)
Definition: Wave.cpp:209
Code BadArgument1()
Code Success()

References bio::physical::Wave::AsAtom(), bio::code::BadArgument1(), BIO_SANITIZE, bio::Container::End(), bio::chemical::Atom::GetAllBonds(), bio::chemical::Bond::GetBonded(), bio::chemical::Atom::GetBonded(), bio::chemical::Atom::GetBondPosition(), bio::chemical::AbstractMotif::GetClassProperties(), bio::chemical::Bond::GetId(), bio::physical::Wave::GetResonanceBetween(), bio::SmartIterator::IsAtBeginning(), bio::chemical::Bond::IsEmpty(), bio::ThreadSafe::LockThread(), bio::code::Success(), and bio::ThreadSafe::UnlockThread().

◆ Remove()

template<typename T >
T bio::chemical::UnorderedStructureInterface::Remove ( const T  t)
inline

Removes t from *this using the appropriate handler for T.

Template Parameters
T
Parameters
t
Returns
the removed content or 0; 0 if T is invalid.

Definition at line 84 of file UnorderedStructureInterface.h.

85 {
86 T ret = 0;
87 LockThread();
88 UnorderedMotif< T >* implementer = this->AsBonded< UnorderedMotif< T >* >();
89 if (implementer)
90 {
91 ret = implementer->RemoveImplementation(t);
92 }
94 return ret;
95 }

References bio::ThreadSafe::LockThread(), bio::chemical::UnorderedMotif< CONTENT_TYPE >::RemoveImplementation(), and bio::ThreadSafe::UnlockThread().

Referenced by bio::molecular::Molecule::TransferFrom().


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