libbio
Loading...
Searching...
No Matches
Classes | Functions
bio::chemical::structure Namespace Reference

Classes

struct  LinearMotifContentTypeId
 
struct  LinearMotifDispatch
 
struct  LinearMotifDispatch< T, true >
 
struct  MotifCandidate
 
struct  PointerContentRequest
 
struct  WrappedLinearMotifDispatch
 
struct  WrappedLinearMotifDispatch< T, true >
 

Functions

void TryAddWaveCollectVisitor (const Bond &bond, void *ctx)
 
bool TryAddWaveToAnyMotif (Pointer< physical::Wave > host, Pointer< physical::Wave > payload)
 
bool TryShareWaveWithAnyMotif (Pointer< physical::Wave > host, Pointer< physical::Wave > payload)
 
template<typename MOTIF >
bool IsBondedMotifType (Pointer< const physical::Wave > bonded)
 
void MotifCandidateCollectVisitor (const Bond &bond, void *ctx)
 
template<typename T >
Pointer< UnorderedMotif< T > > ResolveUnorderedMotif (Pointer< UnorderedStructureInterface > self)
 
template<typename T >
Pointer< const UnorderedMotif< T > > ResolveUnorderedMotif (Pointer< const UnorderedStructureInterface > self)
 
template<typename T >
Pointer< LinearMotif< T > > ResolveLinearMotif (Pointer< UnorderedStructureInterface > self)
 
template<typename T >
Pointer< const LinearMotif< T > > ResolveLinearMotif (Pointer< const UnorderedStructureInterface > self)
 

Function Documentation

◆ IsBondedMotifType()

template<typename MOTIF >
bool bio::chemical::structure::IsBondedMotifType ( Pointer< const physical::Wave bonded)

◆ MotifCandidateCollectVisitor()

void bio::chemical::structure::MotifCandidateCollectVisitor ( const Bond bond,
void ctx 
)
inline

◆ ResolveLinearMotif() [1/2]

template<typename T >
Pointer< const LinearMotif< T > > bio::chemical::structure::ResolveLinearMotif ( Pointer< const UnorderedStructureInterface self)

◆ ResolveLinearMotif() [2/2]

template<typename T >
Pointer< LinearMotif< T > > bio::chemical::structure::ResolveLinearMotif ( Pointer< UnorderedStructureInterface self)

◆ ResolveUnorderedMotif() [1/2]

template<typename T >
Pointer< const UnorderedMotif< T > > bio::chemical::structure::ResolveUnorderedMotif ( Pointer< const UnorderedStructureInterface self)

◆ ResolveUnorderedMotif() [2/2]

template<typename T >
Pointer< UnorderedMotif< T > > bio::chemical::structure::ResolveUnorderedMotif ( Pointer< UnorderedStructureInterface self)

◆ TryAddWaveCollectVisitor()

void bio::chemical::structure::TryAddWaveCollectVisitor ( const Bond bond,
void ctx 
)
inline

Try to install a clone of payload into any motif on host that accepts it.

Walks host->AsAtom() bonds (via ForEachBond at v6) looking for AbstractMotif bonds. For each motif, clones the payload and asks the motif to accept the clone via AddWaveByContentType. The first motif whose ChemicalCast<CONTENT_TYPE>(clone) succeeds — i.e. the payload is the motif's CONTENT_TYPE or a subclass — adopts the clone and we return true. Clones rejected by all motifs are deleted before we return false.

Why "try-add-on-each" rather than "match-typeid-then-add": the host's motifs store the contentTypeId of their declared CONTENT_TYPE (e.g. Protein*), but payloads in the canonical flow are typically subclasses (e.g. CanonicalFlowTestProtein*) with their own distinct typeIds. Strict typeId equality misses these. Delegating to AddWaveByContentType lets each motif's ChemicalCast handle the inheritance walk.

Why "clone first, give the clone to the motif" rather than handing the original: LinearMotif::AddImplementation takes ownership of the added pointer (Linearize + SetShared(false)), so any other holder of the original payload would double-free at teardown. The canonical use is Gene → Translate → Insertion, where the Gene's DNA retains the source Protein template and the host receives a fresh copy. Cloning here keeps that contract intact without requiring upstream callers to clone themselves.

Used by genetic::Insertion::Seek's polymorphic-dispatch fast path (lib/bio/src/genetic/localization/Insertion.cpp). The non-template shape is what makes this useful: Insertion has a payload it knows only as Substance* statically; we delegate the type-matching to each motif.

Parameters
hostthe Wave whose Atom bonds to search.
payloadthe Wave to clone-and-insert.
Returns
true if any motif accepted a clone of the payload; false otherwise.

◆ TryAddWaveToAnyMotif()

bool bio::chemical::structure::TryAddWaveToAnyMotif ( Pointer< physical::Wave host,
Pointer< physical::Wave payload 
)
inline

◆ TryShareWaveWithAnyMotif()

bool bio::chemical::structure::TryShareWaveWithAnyMotif ( Pointer< physical::Wave host,
Pointer< physical::Wave payload 
)
inline

Try to install payload into any motif on host that accepts it, WITHOUT cloning and WITHOUT taking ownership.

Identical bond-walk + motif-accept logic as TryAddWaveToAnyMotif, but routes through AddSharedWaveByContentType — the motif holds the pointer by reference rather than adopting it. The original owner (typically a Gene's DNA::mProtein) remains responsible for the payload's lifetime.

A core wiring primitive (neural axon/dendrite synapse formation, gene expression via RNAPolymerase). The v9 Protein-sharing Expressor path that also used it was removed; this mechanism is independent of that feature. Plasmid authors who use this path don't need their Protein subclasses to be cloneable (no per-instance Class<T> + BIO_DISAMBIGUATE_ALL_CLASS_METHODS scaffolding) — see lib/bio/README.md's Plasmid Integration section for the two integration shapes and the lifetime contract.

IMPORTANT: shared semantics require the host's lifetime to be ≤ the payload's lifetime. The canonical use case is process-singleton plasmids that stay loaded for the process lifetime; hosts that outlive their Plasmid would dangle on these motif slots.

Parameters
hostthe Wave whose Atom bonds to search.
payloadthe Wave to share-add.
Returns
true if any motif accepted the payload by reference; false otherwise.