libbio
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bio::chemical::Bond Class Reference

#include <Bond.h>

Public Member Functions

 Bond ()
 
 Bond (AtomicNumber id, Pointer< physical::Wave > bonded, BondType type=bond_type::Unknown())
 
 Bond (AtomicNumber id, Pointer< physical::Wave > bonded, BondType type, bool ownsBonded)
 
 ~Bond ()
 
bool operator== (const AtomicNumber id) const
 
bool operator== (const Bond &other) const
 
bool Form (AtomicNumber id, Pointer< physical::Wave > bonded, BondType type=bond_type::Unknown())
 
bool Form (AtomicNumber id, Pointer< physical::Wave > bonded, BondType type, bool ownsBonded)
 
AtomicNumber GetId () const
 
Pointer< physical::WaveGetBonded ()
 
Pointer< const physical::WaveGetBonded () const
 
Pointer< physical::WaveDetachBondedForWrite ()
 
bool IsBondedShared () const
 
bool IsBondedOwned () const
 
BondType GetType () const
 
bool OwnsBonded () const
 
bool IsEmpty () const
 
void Break ()
 

Detailed Description

Bonds are used by Atom to form relationships to Waves.
These can be thought of as edges in a directed graph.
See Atom.h for more info.

NOTE: Bonds may currently only be of a single BondType. This may change in a future release.

Constructor & Destructor Documentation

◆ Bond() [1/3]

bio::chemical::Bond::Bond ( )

◆ Bond() [2/3]

bio::chemical::Bond::Bond ( AtomicNumber  id,
Pointer< physical::Wave bonded,
BondType  type = bond_type::Unknown() 
)
Parameters
id
bonded
type

◆ Bond() [3/3]

bio::chemical::Bond::Bond ( AtomicNumber  id,
Pointer< physical::Wave bonded,
BondType  type,
bool  ownsBonded 
)

◆ ~Bond()

bio::chemical::Bond::~Bond ( )

Member Function Documentation

◆ Break()

void bio::chemical::Bond::Break ( )

Empties the contents of *this.

◆ DetachBondedForWrite()

Pointer< physical::Wave > bio::chemical::Bond::DetachBondedForWrite ( )

COPY-ON-WRITE detach: if mBonded is an owning reference shared with another bond (e.g. a COW-shared clone), deep-copy it (via physical::Wave::Clone()) into a private owned reference and re-point *this at the copy; then return the now uniquely-owned bonded for mutation. A unique owning bond is mutated in place (no copy). A borrowed bond is never detached (the real owner manages it) — its raw bonded is returned as-is. The CALLER MUST hold the host Atom's EXCLUSIVE lock (this re-points the bond's storage). RFC_BONDED_COW_HANDLE §12.

Returns
the uniquely-owned (post-detach) bonded Wave, or NULL if empty.

◆ Form() [1/2]

bool bio::chemical::Bond::Form ( AtomicNumber  id,
Pointer< physical::Wave bonded,
BondType  type,
bool  ownsBonded 
)

◆ Form() [2/2]

bool bio::chemical::Bond::Form ( AtomicNumber  id,
Pointer< physical::Wave bonded,
BondType  type = bond_type::Unknown() 
)

Update the contents of *this.
Only works if *this IsEmpty().

Parameters
id
bonded
type
Returns
true if *this was updated; false otherwise (e.g. if *this is already pointing to something)

◆ GetBonded() [1/2]

Pointer< physical::Wave > bio::chemical::Bond::GetBonded ( )
Returns
the mBonded of *this.

◆ GetBonded() [2/2]

Pointer< const physical::Wave > bio::chemical::Bond::GetBonded ( ) const
Returns
the mBonded of *this.

◆ GetId()

AtomicNumber bio::chemical::Bond::GetId ( ) const
Returns
the mId of *this.

◆ GetType()

BondType bio::chemical::Bond::GetType ( ) const
Returns
the mType of *this.

◆ IsBondedOwned()

bool bio::chemical::Bond::IsBondedOwned ( ) const
Returns
true iff mBonded is an OWNING reference (its CowPtr deletes the payload on last release and is copy-on-write shareable). False for borrowed references and empty bonds. Lets CloneBondsFrom COW-SHARE owning bonded payloads while still deep-cloning borrowed-but-DEEP ones (e.g. Surface-Managed bonds, whose lifetime a manager owns — sharing those would double-free).

◆ IsBondedShared()

bool bio::chemical::Bond::IsBondedShared ( ) const
Returns
true iff mBonded is an OWNING reference shared with another bond (refcount

‍1) — i.e. a mutable access must copy-on-write detach it. Borrowed and uniquely owned bonds return false: they are mutated in place, no detach (and so need no exclusive lock). RFC_BONDED_COW_HANDLE §12.

◆ IsEmpty()

bool bio::chemical::Bond::IsEmpty ( ) const
Returns
whether or not *this points to anything.

◆ operator==() [1/2]

bool bio::chemical::Bond::operator== ( const AtomicNumber  id) const
Parameters
id
Returns
whether or not the given id matches that of *this.

◆ operator==() [2/2]

bool bio::chemical::Bond::operator== ( const Bond other) const
Parameters
other
Returns
whether or not id of other matches that of *this.

◆ OwnsBonded()

bool bio::chemical::Bond::OwnsBonded ( ) const
Returns
whether this Bond owns (and must delete) its bonded payload. Derived from the CowPtr's ownership (IsBondedOwned()) rather than a stored flag — an owning bond is one whose CowPtr deletes the payload on last release (i.e. formed with ownsBonded || type == AutoDelete()).

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