libbio
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
bio::physical::Linear Class Reference

#include <Linear.h>

Collaboration diagram for bio::physical::Linear:
Collaboration graph
[legend]

Public Member Functions

 Linear (Pointer< Identifiable< Id > > component, bool shared=true, ::std::ptrdiff_t derivedOffset=0)
 
 Linear (const Linear &toCopy)
 
 ~Linear ()
 
bool operator== (Pointer< const Identifiable< Id > > component) const
 
bool operator== (const Linear &other) const
 
 operator Pointer< Identifiable< Id > > ()
 
 operator Pointer< const Identifiable< Id > > () const
 
Identifiable< Id > & operator* ()
 
const Identifiable< Id > & operator* () const
 
Pointer< Identifiable< Id > > operator-> ()
 
Pointer< const Identifiable< Id > > operator-> () const
 
template<typename T >
T As () const
 
::std::ptrdiff_t GetDerivedOffset () const
 
void SetDerivedOffset (::std::ptrdiff_t offset)
 
bool IsShared () const
 
void SetShared (bool shouldShare)
 

Protected Attributes

Pointer< Identifiable< Id > > mComponent
 
bool mShared
 
::std::ptrdiff_t mDerivedOffset
 

Detailed Description

Linear is a ____pointer interface for Biology.

This class is used by Line and chemical::LinearMotifs, see those classes for more info.

Lines contain logic for handling their CONTENT_TYPE by Id, Name, and other potentials innate to the Identifiable<Id>. The term "linear" comes from the idea that instead of a 0 dimensional pile of objects, as are Arrangements, *this can be ordered along at least 1 dimension (i.e. the Id).

Current features:

  1. Shared: determines whether or not mComponent will be deleted with *this.

Future features:

  1. Const: determines whether or not *this can be changed.

NOTE: Linear is NOT VIRTUAL!
This is done to save space in lists. Because we do not need a vtable, we shan't have one!

NOTE: we should support Dimensions other than the Id. However, the limitations of chemical::Atom::Bonds prevent us from indexing more than 1 template variable from ____Interfaces (e.g. Structure).
Id here, mirrors what is used by chemical::Class and does not require any additional template specialization.
Plus, not supporting other Dimensions makes for cleaner inheritance / downstream code.
Support for other Dimensions may be added in a future release.

NOTE: Linear wrappers are Shared by default to avoid destructive action by temporaries.
Sharing should be removed when undesired.

Constructor & Destructor Documentation

◆ Linear() [1/2]

bio::physical::Linear::Linear ( Pointer< Identifiable< Id > >  component,
bool  shared = true,
::std::ptrdiff_t  derivedOffset = 0 
)
Parameters
component
shared

◆ Linear() [2/2]

bio::physical::Linear::Linear ( const Linear toCopy)

NOTE: This sets mShared to true!

Parameters
toCopy

◆ ~Linear()

bio::physical::Linear::~Linear ( )

Will delete mComponent iff !mShared.

Member Function Documentation

◆ As()

template<typename T >
T bio::physical::Linear::As ( ) const
inline

Access the originally stored pointer type using the cached offset. This avoids RTTI/virtual-base cast issues when Linear wraps Identifiables.

Template Parameters
Ta Pointer type matching what was originally stored.
Returns
the derived pointer or NULL.

◆ GetDerivedOffset()

::std::ptrdiff_t bio::physical::Linear::GetDerivedOffset ( ) const
inline
Returns
the stored derived-pointer offset.

◆ IsShared()

bool bio::physical::Linear::IsShared ( ) const
Returns
whether or not *this is mShared.

◆ operator Pointer< const Identifiable< Id > >()

bio::physical::Linear::operator Pointer< const Identifiable< Id > > ( ) const
Returns
mComponent

◆ operator Pointer< Identifiable< Id > >()

bio::physical::Linear::operator Pointer< Identifiable< Id > > ( )
Returns
mComponent

◆ operator*() [1/2]

Identifiable< Id > & bio::physical::Linear::operator* ( )
Returns
mComponent

◆ operator*() [2/2]

const Identifiable< Id > & bio::physical::Linear::operator* ( ) const
Returns
mComponent

◆ operator->() [1/2]

Pointer< Identifiable< Id > > bio::physical::Linear::operator-> ( )
Returns
mComponent

◆ operator->() [2/2]

Pointer< const Identifiable< Id > > bio::physical::Linear::operator-> ( ) const
Returns
mComponent

◆ operator==() [1/2]

bool bio::physical::Linear::operator== ( const Linear other) const

NOTE: Comparison should be handled by Identifiable, i.e. by Id.

Parameters
other
Returns
whether the other's component matches that of *this.

◆ operator==() [2/2]

bool bio::physical::Linear::operator== ( Pointer< const Identifiable< Id > >  component) const

NOTE: Comparison should be handled by Identifiable, i.e. by Id.

Parameters
component
Returns
whether the component of *this matches the given component.

◆ SetDerivedOffset()

void bio::physical::Linear::SetDerivedOffset ( ::std::ptrdiff_t  offset)
inline

Update the stored derived-pointer offset.

Parameters
offsetbytes from Identifiable* to the original pointer type.

◆ SetShared()

void bio::physical::Linear::SetShared ( bool  shouldShare)

Sets mShared in *this.

Parameters
shouldShare

Member Data Documentation

◆ mComponent

Pointer< Identifiable< Id > > bio::physical::Linear::mComponent
protected

◆ mDerivedOffset

::std::ptrdiff_t bio::physical::Linear::mDerivedOffset
protected

◆ mShared

bool bio::physical::Linear::mShared
protected

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