Develop Biology
The language of life
bio::chemical::LinearMotif< CONTENT_TYPE > Class Template Reference

#include <LinearMotif.h>

+ Inheritance diagram for bio::chemical::LinearMotif< CONTENT_TYPE >:
+ Collaboration diagram for bio::chemical::LinearMotif< CONTENT_TYPE >:

Public Types

typedef physical::Line Contents
 
- Public Types inherited from bio::physical::Identifiable< StandardDimension >
typedef StandardDimension Id
 
typedef std::vector< IdIds
 
- Public Types inherited from bio::physical::Observer< Perspective< StandardDimension > >
typedef Perspective< StandardDimension > Perspective
 
- Public Types inherited from bio::chemical::UnorderedMotif< CONTENT_TYPE >
typedef physical::Arrangement< CONTENT_TYPE > Contents
 

Public Member Functions

 LinearMotif (const Contents *contents, physical::Perspective< StandardDimension > *perspective=NULL)
 
 LinearMotif (const LinearMotif< CONTENT_TYPE > &toCopy)
 
 LinearMotif (physical::Perspective< StandardDimension > *perspective=NULL)
 
virtual ~LinearMotif ()
 
virtual CONTENT_TYPE AddImplementation (CONTENT_TYPE content)
 
virtual Code Attenuate (const physical::Wave *other)
 
 BIO_DISAMBIGUATE_REQUIRED_CLASS_METHODS (chemical, LinearMotif< CONTENT_TYPE >) BIO_DISAMBIGUATE_OPTIONAL_CLASS_METHODS(physical
 
virtual void ClearImplementation ()
 
virtual CONTENT_TYPE CreateImplementation (StandardDimension id)
 
virtual Code Disattenuate (const physical::Wave *other)
 
virtual Emission ForEachImplementation (ExcitationBase *excitation)
 
virtual CONTENT_TYPE GetByIdImplementation (StandardDimension id)
 
virtual const CONTENT_TYPE GetByIdImplementation (StandardDimension id) const
 
virtual CONTENT_TYPE GetByNameImplementation (Name name)
 
virtual const CONTENT_TYPE GetByNameImplementation (Name name) const
 
virtual CONTENT_TYPE GetOrCreateByIdImplementation (StandardDimension id)
 
virtual CONTENT_TYPE GetOrCreateByNameImplementation (Name name)
 
virtual std::string GetStringFromImplementation (std::string separator=", ")
 
physical::Perspective< StandardDimension > * GetStructuralPerspective ()
 
const physical::Perspective< StandardDimension > * GetStructuralPerspective () const
 
virtual bool HasImplementation (const CONTENT_TYPE &content) const
 
virtual void ImportImplementation (const LinearMotif< CONTENT_TYPE > *other)
 
virtual Code InsertImplementation (CONTENT_TYPE toAdd, const Position position=BOTTOM, const StandardDimension optionalPositionArg=0, const bool transferSubContents=false)
 
- Public Member Functions inherited from bio::chemical::Elementary< LinearMotif< CONTENT_TYPE > >
 Elementary ()
 
 Elementary (const Properties properties)
 
virtual ~Elementary ()
 
void RegisterProperties (const Properties properties)
 
- Public Member Functions inherited from bio::chemical::Class< LinearMotif< CONTENT_TYPE > >
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, LinearMotif< CONTENT_TYPE >) Class(LinearMotif< CONTENT_TYPE > *object
 
- Public Member Functions inherited from bio::physical::Class< T >
 Class (T *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
T * Convert (Wave *wave)
 
virtual operator T* ()
 
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
 
- Public Member Functions inherited from bio::physical::Identifiable< StandardDimension >
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Identifiable< StandardDimension >) explicit Identifiable(Perspective< StandardDimension > *perspective
 
void CloneIntoName (Name name)
 
- Public Member Functions inherited from bio::physical::Observer< Perspective< StandardDimension > >
 Observer (const Observer &other)
 
 Observer (Perspective *perspective=NULL)
 
virtual ~Observer ()
 
virtual PerspectiveGetPerspective () const
 
virtual void SetPerspective (Perspective *perspective)
 
- Public Member Functions inherited from bio::physical::Class< Identifiable< StandardDimension > >
 Class (Identifiable< StandardDimension > *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
Identifiable< StandardDimension > * Convert (Wave *wave)
 
virtual operator Identifiable< StandardDimension > * ()
 
virtual operator Wave * ()
 
- Public Member Functions inherited from bio::log::Writer
 Writer (Engine *logEngine, Filter logFilter)
 
virtual ~Writer ()
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Writer) Writer()
 
void ExternalLog (Filter logFilter, Level level, const char *format,...) const
 
EngineGetLogEngine ()
 
const EngineGetLogEngine () const
 
bool HasLogEngine () const
 
virtual void SetLogEngine (Engine *logEngine)
 
- Public Member Functions inherited from bio::physical::Filterable
 Filterable (Filter filter)
 
virtual ~Filterable ()
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Filterable) Filterable()
 
Filter GetFilter () const
 
virtual void InitializeImplementation (ByteStreams args)
 
virtual Code Reify (Symmetry *symmetry)
 
virtual void SetFilter (Filter filter)
 
virtual SymmetrySpin () const
 
- Public Member Functions inherited from bio::physical::Class< Filterable >
 Class (Filterable *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
FilterableConvert (Wave *wave)
 
virtual operator Filterable * ()
 
virtual operator Wave * ()
 
- Public Member Functions inherited from bio::physical::Class< Writer >
 Class (Writer *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
Writer * Convert (Wave *wave)
 
virtual operator Wave * ()
 
virtual operator Writer * ()
 
- 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::chemical::UnorderedMotif< CONTENT_TYPE >
 UnorderedMotif (const Contents *contents)
 
 UnorderedMotif (const UnorderedMotif< CONTENT_TYPE > *toCopy)
 
virtual ~UnorderedMotif ()
 
virtual CONTENT_TYPE AddImplementation (const CONTENT_TYPE content)
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (chemical, UnorderedMotif< CONTENT_TYPE >) UnorderedMotif()
 
virtual void ClearImplementation ()
 
virtual unsigned long GetCountImplementation () const
 
virtual unsigned int GetNumMatchingImplementation (const Container *other) const
 
virtual std::string GetStringFromImplementation (std::string separator=", ")
 
virtual bool HasAllImplementation (const Container *contents) const
 
virtual bool HasImplementation (const CONTENT_TYPE content) const
 
virtual void ImportImplementation (const UnorderedMotif< CONTENT_TYPE > *other)
 
virtual CONTENT_TYPE RemoveImplementation (const CONTENT_TYPE content)
 
- Public Member Functions inherited from bio::chemical::Class< UnorderedMotif< CONTENT_TYPE > >
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, UnorderedMotif< CONTENT_TYPE >) Class(UnorderedMotif< CONTENT_TYPE > *object
 
- Public Member Functions inherited from bio::chemical::AbstractMotif
 AbstractMotif ()
 
virtual ~AbstractMotif ()
 
virtual void ClearImplementation ()
 
virtual ContainerGetAllImplementation ()
 
virtual const ContainerGetAllImplementation () const
 
virtual unsigned long GetCountImplementation () const
 
virtual std::string GetStringFromImplementation (std::string separator=", ")
 
virtual void ImportImplementation (const void *other)
 

Static Public Member Functions

static LinearMotif< CONTENT_TYPE > Properties GetClassProperties ()
 
- 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)
 
- Static Public Member Functions inherited from bio::chemical::AbstractMotif
static Properties GetClassProperties ()
 

Public Attributes

physical::Perspective< StandardDimension > * m_perspective
 
- Public Attributes inherited from bio::chemical::Class< LinearMotif< CONTENT_TYPE > >
physical::Perspective< StandardDimension > Filter filter
 
physical::Perspective< StandardDimension > * perspective
 
- Public Attributes inherited from bio::physical::Identifiable< StandardDimension >
Id m_id
 
- Public Attributes inherited from bio::chemical::Class< UnorderedMotif< CONTENT_TYPE > >
physical::Perspective< StandardDimension > Filter filter
 
physical::Perspective< StandardDimension > * perspective
 

Additional Inherited Members

- Static Public Attributes inherited from bio::chemical::Elementary< LinearMotif< CONTENT_TYPE > >
static bool hasRegistered
 
- Protected Member Functions inherited from bio::physical::Observer< Perspective< StandardDimension > >
virtual void InitializeImplementation (ByteStreams args)
 
- Protected Member Functions inherited from bio::VirtualBase
 VirtualBase ()
 
virtual ~VirtualBase ()
 
void Initialize (ByteStream arg1)
 
void Initialize (ByteStream arg1, ByteStream arg2)
 
void Initialize (ByteStream arg1, ByteStream arg2, ByteStream arg3)
 
void Initialize (ByteStreams args)
 
virtual void InitializeImplementation (ByteStreams args)=0
 
- Protected Member Functions inherited from bio::log::Writer
virtual void InitializeImplementation (ByteStreams args)
 
void Log (Level level, const char *format,...) const
 
- 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::physical::Class< T >
T * m_object
 
- Protected Attributes inherited from bio::physical::Wave
Wavem_signal
 
Symmetrym_symmetry
 
- Protected Attributes inherited from bio::VirtualBase
bool m_hasBeenInitialized
 
- Protected Attributes inherited from bio::physical::Class< Identifiable< StandardDimension > >
Identifiable< StandardDimension > * m_object
 
- Protected Attributes inherited from bio::physical::Filterable
Filter m_filter
 
- Protected Attributes inherited from bio::physical::Class< Filterable >
Filterablem_object
 
- Protected Attributes inherited from bio::physical::Class< Writer >
Writer * m_object
 
- 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::chemical::AbstractMotif
Containerm_contents
 

Detailed Description

template<typename CONTENT_TYPE>
class bio::chemical::LinearMotif< CONTENT_TYPE >

LinearMotif objects contain pointers to chemical::Classes.

IMPORTANT: CONTENT_TYPE MUST BE A chemical::Class* (which is in the StandardDimension). YOU CANNOT USE LinearMotif WITH TYPES THAT ARE NOT POINTERS TO CHILDREN OF chemical::Class (i.e. a physical::Identifiable<StandardDimension>) Other Dimensions may be supported in a future release. physical::Line and physical::Linear for why.

NOTE: CONTENT_TYPE cannot be "const". cv qualifiers may be supported in a future release but for now, all CONTENT_TYPEs must have the option of being modified. For more on this, see Linear.h.

Template Parameters
CONTENT_TYPEa pointer type to a child of chemical::Class

Definition at line 54 of file LinearMotif.h.

Member Typedef Documentation

◆ Contents

template<typename CONTENT_TYPE >
typedef physical::Line bio::chemical::LinearMotif< CONTENT_TYPE >::Contents

For cleaner code, we redefine Contents.

Definition at line 64 of file LinearMotif.h.

Constructor & Destructor Documentation

◆ LinearMotif() [1/3]

template<typename CONTENT_TYPE >
bio::chemical::LinearMotif< CONTENT_TYPE >::LinearMotif ( physical::Perspective< StandardDimension > *  perspective = NULL)
inlineexplicit
Parameters
perspective

Definition at line 90 of file LinearMotif.h.

91 :
92 Elementary< LinearMotif< CONTENT_TYPE > >(GetClassProperties()),
93 chemical::Class< LinearMotif< CONTENT_TYPE > >(this),
95 {
96 CtorCommon();
97 }
physical::Perspective< StandardDimension > * perspective
Definition: Class.h:80
static LinearMotif< CONTENT_TYPE > Properties GetClassProperties()
Definition: LinearMotif.h:80
physical::Perspective< StandardDimension > * m_perspective
Definition: LinearMotif.h:147

◆ LinearMotif() [2/3]

template<typename CONTENT_TYPE >
bio::chemical::LinearMotif< CONTENT_TYPE >::LinearMotif ( const Contents contents,
physical::Perspective< StandardDimension > *  perspective = NULL 
)
inlineexplicit
Parameters
contents
name
perspective

Definition at line 104 of file LinearMotif.h.

108 :
109 Elementary< LinearMotif< CONTENT_TYPE > >(GetClassProperties()),
110 chemical::Class< LinearMotif< CONTENT_TYPE > >(this),
112 {
113 CtorCommon();
114 this->m_contents->Import(contents);
115 }
virtual void Import(const Container *other)
Definition: Container.cpp:251

References bio::Container::Import(), and bio::chemical::AbstractMotif::m_contents.

◆ LinearMotif() [3/3]

template<typename CONTENT_TYPE >
bio::chemical::LinearMotif< CONTENT_TYPE >::LinearMotif ( const LinearMotif< CONTENT_TYPE > &  toCopy)
inline

Copying a LinearMotif will Clone all contents in toCopy into *this. Keep in mind that dtor will delete the contents of *this.

Parameters
toCopy

Definition at line 122 of file LinearMotif.h.

123 :
124 Elementary< LinearMotif< CONTENT_TYPE > >(toCopy.GetClassProperties()),
125 chemical::Class< LinearMotif< CONTENT_TYPE > >(this),
126 m_perspective(toCopy.m_perspective)
127 {
128 CtorCommon();
129 this->m_contents->Import(toCopy.GetAllImplementation());
130 }

References bio::chemical::AbstractMotif::GetAllImplementation(), bio::Container::Import(), and bio::chemical::AbstractMotif::m_contents.

◆ ~LinearMotif()

template<typename CONTENT_TYPE >
virtual bio::chemical::LinearMotif< CONTENT_TYPE >::~LinearMotif ( )
inlinevirtual

Deletes all the Contents in *this. NOTE: this uses delete, not delete[]. The only way to avoid this is by Clear()ing *this yourself first.

Definition at line 137 of file LinearMotif.h.

138 {
139 this->m_contents->Clear();
140 }
virtual void Clear()
Definition: Container.cpp:265

References bio::Container::Clear(), and bio::chemical::AbstractMotif::m_contents.

Member Function Documentation

◆ AddImplementation()

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::AddImplementation ( CONTENT_TYPE  content)
inlinevirtual

Adds content to *this.

Parameters
content
Returns
t or NULL.

Reimplemented from bio::chemical::UnorderedMotif< CONTENT_TYPE >.

Definition at line 170 of file LinearMotif.h.

171 {
172 return ChemicalCast< CONTENT_TYPE >(Cast< physical::Line* >(this->m_contents)->LinearAccess(this->m_contents->Add(content)));
173 }
virtual Index Add(const ByteStream content)
Definition: Container.cpp:129

References bio::Container::Add(), and bio::chemical::AbstractMotif::m_contents.

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::CreateImplementation().

◆ Attenuate()

template<typename CONTENT_TYPE >
virtual Code bio::chemical::LinearMotif< CONTENT_TYPE >::Attenuate ( const physical::Wave other)
inlinevirtual

Override of Wave method. See that class for details. If other is an Excitation, call ForEach instead.

Parameters
other
Returns
the result of all Attenuations.

Reimplemented from bio::physical::Wave.

Definition at line 472 of file LinearMotif.h.

473 {
475 other,
477 {
478 ForEachImplementation(ChemicalCast< ExcitationBase* >(other));
479 return code::Success();
480 }
481
482 Code ret = code::Success();
483 for (
484 SmartIterator cnt = this->m_contents;
485 !cnt.IsAtBeginning();
486 --cnt
487 )
488 {
489 if (cnt.template As< physical::Identifiable< StandardDimension >* >()->Attenuate(other) != code::Success())
490 {
491 ret = code::UnknownError();
492 }
493 }
494 return ret;
495 }
static Properties GetClassProperties()
Definition: Excitation.h:73
virtual Emission ForEachImplementation(ExcitationBase *excitation)
Definition: LinearMotif.h:524
static Properties GetResonanceBetween(ConstWaves waves)
Definition: Wave.cpp:209
Code UnknownError()
Code Success()

References bio::chemical::Atom::As(), bio::physical::Wave::Attenuate(), bio::chemical::LinearMotif< CONTENT_TYPE >::ForEachImplementation(), bio::chemical::ExcitationBase::GetClassProperties(), bio::physical::Wave::GetResonanceBetween(), bio::chemical::AbstractMotif::m_contents, bio::code::Success(), and bio::code::UnknownError().

◆ BIO_DISAMBIGUATE_REQUIRED_CLASS_METHODS()

template<typename CONTENT_TYPE >
bio::chemical::LinearMotif< CONTENT_TYPE >::BIO_DISAMBIGUATE_REQUIRED_CLASS_METHODS ( chemical  ,
LinearMotif< CONTENT_TYPE >   
)

Ensure virtual methods point to Class implementations. We want to define our own Attenuate & Disattenuate, so we have to ignore the optional class methods for the chemical class.

◆ ClearImplementation()

template<typename CONTENT_TYPE >
virtual void bio::chemical::LinearMotif< CONTENT_TYPE >::ClearImplementation ( )
inlinevirtual

Deletes & clears the contents of *this. NOTE: this uses delete, not delete[].

Reimplemented from bio::chemical::UnorderedMotif< CONTENT_TYPE >.

Definition at line 575 of file LinearMotif.h.

576 {
577 //No need to delete anything, since our Linear wrapper handles that for us.
578 this->m_contents->Clear();
579 }

References bio::Container::Clear(), and bio::chemical::AbstractMotif::m_contents.

◆ CreateImplementation()

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::CreateImplementation ( StandardDimension  id)
inlinevirtual

Create a CONTENT_TYPE from a given Id and adds it to *this. Clones the Wave associated with the given Id. This requires a valid Perspective in *this and for that Perspective to have an Wave registered with the given Id.

Parameters
id
Returns
a newly created CONTENT_TYPE else NULL.

Definition at line 391 of file LinearMotif.h.

394 {
396 return NULL);
397 return this->AddImplementation((this->GetStructuralPerspective()->template GetTypeFromIdAs< CONTENT_TYPE >(id)));
398 }
#define BIO_SANITIZE(test, success, failure)
virtual CONTENT_TYPE AddImplementation(CONTENT_TYPE content)
Definition: LinearMotif.h:170
physical::Perspective< StandardDimension > * GetStructuralPerspective()
Definition: LinearMotif.h:152

References bio::chemical::LinearMotif< CONTENT_TYPE >::AddImplementation(), BIO_SANITIZE, and bio::chemical::LinearMotif< CONTENT_TYPE >::GetStructuralPerspective().

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByIdImplementation(), and bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByNameImplementation().

◆ Disattenuate()

template<typename CONTENT_TYPE >
virtual Code bio::chemical::LinearMotif< CONTENT_TYPE >::Disattenuate ( const physical::Wave other)
inlinevirtual

Override of Wave method. See that class for details.

Parameters
other
Returns
the result of all Disattenuations.

Reimplemented from bio::physical::Wave.

Definition at line 502 of file LinearMotif.h.

503 {
504 Code ret = code::Success();
505 for (
506 SmartIterator cnt = this->m_contents;
507 !cnt.IsAtBeginning();
508 --cnt
509 )
510 {
511 if (cnt.template As< physical::Identifiable< StandardDimension >* >()->Disattenuate(other) != code::Success())
512 {
513 ret = code::UnknownError();
514 }
515 }
516 return ret;
517 }

References bio::chemical::Atom::As(), bio::physical::Wave::Disattenuate(), bio::chemical::AbstractMotif::m_contents, bio::code::Success(), and bio::code::UnknownError().

◆ ForEachImplementation()

template<typename CONTENT_TYPE >
virtual Emission bio::chemical::LinearMotif< CONTENT_TYPE >::ForEachImplementation ( ExcitationBase excitation)
inlinevirtual

Performs the given Excitation on all contents.

Parameters
excitation

Definition at line 524 of file LinearMotif.h.

527 {
528 Emission ret;
529 for (
530 SmartIterator cnt = this->m_contents;
531 !cnt.IsAtBeginning();
532 --cnt
533 )
534 {
535 ByteStream result;
536 excitation->CallDown(
537 cnt.template As< physical::Identifiable< StandardDimension >* >()->AsWave(),
538 &result
539 );
540 ret.push_back(result);
541 }
542 return ret;
543 }

References bio::chemical::Atom::As(), bio::physical::Class< T >::AsWave(), bio::chemical::ExcitationBase::CallDown(), and bio::chemical::AbstractMotif::m_contents.

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::Attenuate(), and bio::chemical::LinearStructureInterface::ForEach().

◆ GetByIdImplementation() [1/2]

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetByIdImplementation ( StandardDimension  id)
inlinevirtual

Implementation for getting by id.

Parameters
id
Returns
a Content of the given id or NULL.

Definition at line 324 of file LinearMotif.h.

327 {
328 Index ret = Cast< physical::Line* >(this->m_contents)->SeekToId(id);
330 return NULL) //level 2 for GetOrCreate.
331
332 return ChemicalCast< CONTENT_TYPE >(Cast< physical::Line* >(this->m_contents)->LinearAccess(ret));
333 }
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure)
uint32_t Index
Definition: Types.h:57

References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::chemical::AbstractMotif::m_contents.

Referenced by bio::chemical::LinearStructureInterface::GetById(), bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByIdImplementation(), and bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByNameImplementation().

◆ GetByIdImplementation() [2/2]

template<typename CONTENT_TYPE >
virtual const CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetByIdImplementation ( StandardDimension  id) const
inlinevirtual

const interface for getting by id.

Parameters
id
Returns
a Content of the given id or NULL.

Definition at line 340 of file LinearMotif.h.

343 {
344 Index ret = Cast< physical::Line* >(this->m_contents)->SeekToId(id);
346 return NULL) //level 2 for GetOrCreate.
347
348 return ChemicalCast< CONTENT_TYPE >(Cast< physical::Line* >(this->m_contents)->LinearAccess(ret));
349 }

References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::chemical::AbstractMotif::m_contents.

◆ GetByNameImplementation() [1/2]

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetByNameImplementation ( Name  name)
inlinevirtual

Implementation for getting by name.

Parameters
name
Returns
a CONTENT_TYPE of the given name or NULL.

Definition at line 357 of file LinearMotif.h.

360 {
361 Index ret = Cast< physical::Line* >(this->m_contents)->SeekToName(name);
363 return NULL) //level 2 for GetOrCreate.
364
365 return ChemicalCast< CONTENT_TYPE >(Cast< physical::Line* >(this->m_contents)->LinearAccess(ret));
366 }

References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::chemical::AbstractMotif::m_contents.

Referenced by bio::chemical::LinearStructureInterface::GetByName().

◆ GetByNameImplementation() [2/2]

template<typename CONTENT_TYPE >
virtual const CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetByNameImplementation ( Name  name) const
inlinevirtual

Implementation for getting by name.

Parameters
name
Returns
a CONTENT_TYPE of the given name or NULL.

Definition at line 373 of file LinearMotif.h.

376 {
377 Index ret = Cast< physical::Line* >(this->m_contents)->SeekToName(name);
379 return NULL) //level 2 for GetOrCreate.
380
381 return ChemicalCast< CONTENT_TYPE >(Cast< physical::Line* >(this->m_contents)->LinearAccess(ret));
382 }

References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::chemical::AbstractMotif::m_contents.

◆ GetClassProperties()

template<typename CONTENT_TYPE >
static LinearMotif< CONTENT_TYPE > Properties bio::chemical::LinearMotif< CONTENT_TYPE >::GetClassProperties ( )
inlinestatic

Add property::Linear() to what is given by AbstractMotif.

Returns
{Structural(), Linear()}

Definition at line 80 of file LinearMotif.h.

81 {
83 ret.push_back(property::Linear());
84 return ret;
85 }
static Properties GetClassProperties()
Property Linear()
uint8_t Properties
Definition: Types.h:58

References bio::chemical::AbstractMotif::GetClassProperties(), bio::property::Linear(), and bio::Properties.

◆ GetOrCreateByIdImplementation()

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByIdImplementation ( StandardDimension  id)
inlinevirtual

Tries to find a Content of the given id in *this and, optionally, the Contents beneath. If such an object doesn't exist, one is created from its Wave.

Parameters
id
Returns
A CONTENT_TYPE of the given id.

Definition at line 406 of file LinearMotif.h.

409 {
410 CONTENT_TYPE ret = this->GetByIdImplementation(
411 id
412 );
413 if (ret)
414 {
415 return ret;
416 }
417 return this->CreateImplementation(id);
418 }
virtual CONTENT_TYPE GetByIdImplementation(StandardDimension id)
Definition: LinearMotif.h:324
virtual CONTENT_TYPE CreateImplementation(StandardDimension id)
Definition: LinearMotif.h:391

References bio::chemical::LinearMotif< CONTENT_TYPE >::CreateImplementation(), and bio::chemical::LinearMotif< CONTENT_TYPE >::GetByIdImplementation().

Referenced by bio::chemical::LinearStructureInterface::GetOrCreateById().

◆ GetOrCreateByNameImplementation()

template<typename CONTENT_TYPE >
virtual CONTENT_TYPE bio::chemical::LinearMotif< CONTENT_TYPE >::GetOrCreateByNameImplementation ( Name  name)
inlinevirtual

Tries to find a Content of the given id in *this and, optionally, the Contents beneath. If such an object doesn't exist, one is created from its Wave.

Parameters
name
Returns
A CONTENT_TYPE of the given id.

Definition at line 426 of file LinearMotif.h.

429 {
431 return NULL);
432 //We convert to Id in case the Name is not already registered in the desired Perspective.
433 StandardDimension id = this->GetStructuralPerspective()->GetIdFromName(name);
434 CONTENT_TYPE ret = this->GetByIdImplementation(id);
435 if (ret)
436 {
437 return ret;
438 }
439 return this->CreateImplementation(id);
440 }
virtual Id GetIdFromName(Name name)
Definition: Perspective.h:212

References BIO_SANITIZE, bio::chemical::LinearMotif< CONTENT_TYPE >::CreateImplementation(), bio::chemical::LinearMotif< CONTENT_TYPE >::GetByIdImplementation(), bio::physical::Perspective< DIMENSION >::GetIdFromName(), and bio::chemical::LinearMotif< CONTENT_TYPE >::GetStructuralPerspective().

Referenced by bio::chemical::LinearStructureInterface::GetOrCreateByName().

◆ GetStringFromImplementation()

template<typename CONTENT_TYPE >
virtual std::string bio::chemical::LinearMotif< CONTENT_TYPE >::GetStringFromImplementation ( std::string  separator = ", ")
inlinevirtual

Gets the Names of all Contents and puts them into a string.

Parameters
separatore.g. ", ", the default, or just " ".
Returns
the Contents of *this as a string.

Reimplemented from bio::chemical::UnorderedMotif< CONTENT_TYPE >.

Definition at line 550 of file LinearMotif.h.

551 {
552 std::string ret = "";
553
554 for (
555 SmartIterator cnt(
556 this->m_contents,
557 this->m_contents->GetBeginIndex());
558 !cnt.IsAtEnd();
559 ++cnt
560 )
561 {
562 ret += cnt.template As< physical::Identifiable< StandardDimension >* >()->GetName();
563 if (cnt.GetIndex() != this->m_contents->GetEndIndex() - 1)
564 {
565 ret += separator;
566 }
567 }
568 return ret;
569 }
virtual Index GetBeginIndex() const
Definition: Container.cpp:64

References bio::Container::GetBeginIndex(), bio::SmartIterator::IsAtEnd(), and bio::chemical::AbstractMotif::m_contents.

◆ GetStructuralPerspective() [1/2]

template<typename CONTENT_TYPE >
physical::Perspective< StandardDimension > * bio::chemical::LinearMotif< CONTENT_TYPE >::GetStructuralPerspective ( )
inline

◆ GetStructuralPerspective() [2/2]

template<typename CONTENT_TYPE >
const physical::Perspective< StandardDimension > * bio::chemical::LinearMotif< CONTENT_TYPE >::GetStructuralPerspective ( ) const
inline
Returns
the m_perspective used by *this.

Definition at line 160 of file LinearMotif.h.

161 {
162 return m_perspective;
163 }

References bio::chemical::LinearMotif< CONTENT_TYPE >::m_perspective.

◆ HasImplementation()

template<typename CONTENT_TYPE >
virtual bool bio::chemical::LinearMotif< CONTENT_TYPE >::HasImplementation ( const CONTENT_TYPE &  content) const
inlinevirtual

Check for content. Dereferences content (i.e. prevents pointer comparison (unless**)).

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

Definition at line 448 of file LinearMotif.h.

449 {
450 return this->m_contents->Has(content);
451 }
bool Has(const ByteStream content) const
Definition: Container.cpp:232

References bio::Container::Has(), and bio::chemical::AbstractMotif::m_contents.

◆ ImportImplementation()

template<typename CONTENT_TYPE >
virtual void bio::chemical::LinearMotif< CONTENT_TYPE >::ImportImplementation ( const LinearMotif< CONTENT_TYPE > *  other)
inlinevirtual

Copy the contents of another container into *this. Clone()s each element.

Parameters
other

Definition at line 458 of file LinearMotif.h.

459 {
460 BIO_SANITIZE(other, ,
461 return);
462
463 this->m_contents->Import(other->m_contents);
464 }

References BIO_SANITIZE, bio::Container::Import(), and bio::chemical::AbstractMotif::m_contents.

◆ InsertImplementation()

template<typename CONTENT_TYPE >
virtual Code bio::chemical::LinearMotif< CONTENT_TYPE >::InsertImplementation ( CONTENT_TYPE  toAdd,
const Position  position = BOTTOM,
const StandardDimension  optionalPositionArg = 0,
const bool  transferSubContents = false 
)
inlinevirtual

Adds a Content in *this at the indicated position. Multiple contents of the same id will cause the previously existing Content to be removed.

NOTE: THIS DESTROYS INDEX INTEGRITY. Indices will be rearranged to accommodate the insertion, making any cached Index invalid.

Parameters
toAddwhat to add. IMPORTANT: This must not already be in a LinearMotif (i.e. create a clone() before adding it to another destination).
positiondetermines where in *this the Content is added.
optionalPositionArgIf a position is specified, the optionalPositionArg is the id of the Content referenced (e.g. BEFORE, MyContentId()).
transferSubContentsallows all of the Contents within a conflicting Content to be copied into the new Content, before the conflicting Content is deleted (similar to renaming an upper directory while preserving it's contents).
Returns
Status of addition (e.g. success or failure).

Definition at line 188 of file LinearMotif.h.

194 {
195 BIO_SANITIZE(toAdd, ,
196 return code::MissingArgument1())
197
198 Code ret = code::Success();
199
200 SmartIterator toReplace(
201 this->m_contents,
202 InvalidIndex());
203
204 //Remove conflicts
205 for (
206 SmartIterator cnt = this->m_contents->End();
207 !cnt.IsAtBeginning();
208 --cnt
209 )
210 {
211 if (cnt.template As< CONTENT_TYPE >()->IsId(toAdd->GetId()))
212 {
213 //Not an error, but potentially worth noting.
215
216 toReplace = cnt;
217 break; //Only find 1 conflict, as no others should exist.
218 }
219 }
220
221 CONTENT_TYPE addition = CloneAndCast< CONTENT_TYPE >(toAdd);
222 BIO_SANITIZE(addition, ,
223 return code::GeneralFailure())
224
225 if (this->m_contents->IsAllocated(toReplace.GetIndex())) //i.e. GetIndex() != 0.
226 {
227 if (transferSubContents)
228 {
229 //NOTE: THIS REMOVES ALL STRUCTURAL COMPONENTS IN toReplace
230 // WHICH ARE NOT EXPLICITLY IN addition
231 //This makes sense but is bound to be a bug at some point...
232
233 CONTENT_TYPE toReplaceCasted = toReplace.template As< CONTENT_TYPE >();
234 //addition->ImportAll(toReplaceCasted); //<- inaccessible, so we replicate the function here.
235
236 Bond* bondBuffer;
237 for (
238 SmartIterator bnd = addition->AsAtom()->GetAllBonds()->End();
239 !bnd.IsAtBeginning();
240 --bnd
241 )
242 {
243 bondBuffer = bnd;
244 if (bondBuffer->IsEmpty())
245 {
246 continue;
247 }
249 bondBuffer->GetBonded(),
251 {
252 continue;
253 }
254 const physical::Wave* otherBond = toReplaceCasted->AsAtom()->GetBonded(toReplaceCasted->AsAtom()->GetBondPosition(bondBuffer->GetId()));
255 Cast< AbstractMotif* >(bondBuffer->GetBonded())->ImportImplementation(otherBond); //actual work
256 }
257 }
258 this->m_contents->Erase(toReplace);
259 }
260
261 switch (position)
262 {
263 case TOP:
264 {
265 this->m_contents->Insert(
266 addition,
267 this->m_contents->GetBeginIndex());
268 break;
269 }
270 case BEFORE:
271 {
272 Index placement = Cast< physical::Line* >(this->m_contents)->SeekToId(optionalPositionArg);
273 if (!placement)
274 {
275 return code::GeneralFailure();
276 }
277 BIO_SANITIZE(Cast< physical::Line* >(this->m_contents)->LinearAccess(placement)->GetPerspective() == addition->GetPerspective(), ,
278 return code::GeneralFailure());
279
280 this->m_contents->Insert(
281 addition,
282 placement
283 );
284 break;
285 }
286 case AFTER:
287 {
288 Index placement = Cast< physical::Line* >(this->m_contents)->SeekToId(optionalPositionArg);
289 if (!placement)
290 {
291 return code::GeneralFailure();
292 }
293 BIO_SANITIZE(Cast< physical::Line* >(this->m_contents)->LinearAccess(placement)->GetPerspective() == addition->GetPerspective(), ,
294 return code::GeneralFailure());
295
296 this->m_contents->Insert(
297 addition,
298 ++placement
299 );
300 break;
301 }
302 case BOTTOM:
303 {
304 this->m_contents->Insert(
305 addition,
306 this->m_contents->GetEndIndex());
307 break;
308 }
309 default:
310 {
311 this->m_contents->Add(addition);
312 break;
313 }
314 } //switch
315
316 return ret;
317 }
Code SuccessfullyReplaced()
Code GeneralFailure()
Code MissingArgument1()
const Index InvalidIndex()
Definition: Types.cpp:26
@ AFTER
Definition: Types.h:49
@ BOTTOM
Definition: Types.h:48
@ TOP
Definition: Types.h:47
@ BEFORE
Definition: Types.h:50

References bio::Container::Add(), bio::AFTER, bio::physical::Wave::AsAtom(), bio::BEFORE, BIO_SANITIZE, bio::BOTTOM, bio::Container::End(), bio::Container::Erase(), bio::code::GeneralFailure(), bio::Container::GetBeginIndex(), bio::chemical::Bond::GetBonded(), bio::chemical::Atom::GetBonded(), bio::chemical::AbstractMotif::GetClassProperties(), bio::Container::GetEndIndex(), bio::chemical::Bond::GetId(), bio::SmartIterator::GetIndex(), bio::physical::Observer< Perspective< StandardDimension > >::GetPerspective(), bio::physical::Wave::GetResonanceBetween(), bio::Container::Insert(), bio::InvalidIndex(), bio::Container::IsAllocated(), bio::SmartIterator::IsAtBeginning(), bio::chemical::Bond::IsEmpty(), bio::chemical::AbstractMotif::m_contents, bio::code::MissingArgument1(), bio::code::Success(), bio::code::SuccessfullyReplaced(), and bio::TOP.

Referenced by bio::chemical::LinearStructureInterface::Insert().

Member Data Documentation

◆ m_perspective

template<typename CONTENT_TYPE >
physical::Perspective< StandardDimension >* bio::chemical::LinearMotif< CONTENT_TYPE >::m_perspective

Each LinearMotif may use a different Perspective for identifying its contents. This Perspective will be used for Name <-> Id matching, Wave->Clone()ing, etc. See bio/physical/Perspective.h for more details.

Definition at line 147 of file LinearMotif.h.

Referenced by bio::chemical::LinearMotif< CONTENT_TYPE >::GetStructuralPerspective().


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