Chemical Data Processing Library C++ API - Version 1.1.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CDPL::Chem::Reaction Class Referenceabstract

Reaction. More...

#include <Reaction.hpp>

+ Inheritance diagram for CDPL::Chem::Reaction:

Public Types

typedef std::shared_ptr< ReactionSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated Reaction instances. More...
 
typedef Util::IndexedElementIterator< const Molecule, ConstComponentAccessor > ConstComponentIterator
 A constant random access iterator used to iterate over the components of the reaction. More...
 
typedef Util::IndexedElementIterator< Molecule, ComponentAccessor > ComponentIterator
 A mutable random access iterator used to iterate over the components of the reaction. More...
 
typedef std::function< void(Reaction &, const Reaction &)> CopyPostprocessingFunction
 
- Public Types inherited from CDPL::Base::PropertyContainer
typedef PropertyMap::value_type PropertyEntry
 A Base::LookupKey / Base::Any pair that stores the property value for a given property key. More...
 
typedef PropertyMap::const_iterator ConstPropertyIterator
 A constant iterator used to iterate over the property entries. More...
 

Public Member Functions

virtual ~Reaction ()
 Virtual destructor. More...
 
virtual void clear ()=0
 Removes all components and clears all properties of the reaction. More...
 
virtual std::size_t getNumComponents () const =0
 Returns the number of reaction components. More...
 
virtual std::size_t getNumComponents (unsigned int role) const =0
 Returns the number of reaction components with the specified role. More...
 
virtual unsigned int getComponentRole (const Molecule &mol) const =0
 Returns the reaction role of the specified component. More...
 
virtual std::size_t getComponentIndex (const Molecule &mol) const =0
 Returns the index of the specified reaction component. More...
 
virtual bool containsComponent (const Molecule &mol) const =0
 Tells whether the specified molecule is a component of this reaction. More...
 
ConstComponentIterator getComponentsBegin () const
 Returns a constant iterator pointing to the beginning of the reaction components. More...
 
ComponentIterator getComponentsBegin ()
 Returns a mutable iterator pointing to the beginning of the reaction components. More...
 
ConstComponentIterator getComponentsEnd () const
 Returns a constant iterator pointing to the end of the reaction components. More...
 
ComponentIterator getComponentsEnd ()
 Returns a mutable iterator pointing to the end of the reaction components. More...
 
ConstComponentIterator begin () const
 Returns a constant iterator pointing to the beginning of the reaction components. More...
 
ComponentIterator begin ()
 Returns a mutable iterator pointing to the beginning of the reaction components. More...
 
ConstComponentIterator end () const
 Returns a constant iterator pointing to the end of the reaction components. More...
 
ComponentIterator end ()
 Returns a mutable iterator pointing to the end of the reaction components. More...
 
ConstComponentIterator getComponentsBegin (unsigned int role) const
 Returns a constant iterator pointing to the beginning of the reaction components with the specified role. More...
 
ComponentIterator getComponentsBegin (unsigned int role)
 Returns a mutable iterator pointing to the beginning of the reaction components with the specified role. More...
 
ConstComponentIterator getComponentsEnd (unsigned int role) const
 Returns a constant iterator pointing to the end of the reaction components with the specified role. More...
 
ComponentIterator getComponentsEnd (unsigned int role)
 Returns a mutable iterator pointing to the end of the reaction components with the specified role. More...
 
virtual const MoleculegetComponent (std::size_t idx) const =0
 Returns a const reference to the reaction component at index idx. More...
 
virtual MoleculegetComponent (std::size_t idx)=0
 Returns a non-const reference to the reaction component at index idx. More...
 
virtual const MoleculegetComponent (std::size_t idx, unsigned int role) const =0
 Returns a const reference to the reaction component at index idx in the list of components with the specified role. More...
 
virtual MoleculegetComponent (std::size_t idx, unsigned int role)=0
 Returns a non-const reference to the reaction component at index idx in the list of components with the specified role. More...
 
virtual MoleculeaddComponent (unsigned int role)=0
 Creates a new reaction component with the specified role. More...
 
virtual void swapComponentRoles (unsigned int role1, unsigned int role2)=0
 Swaps the reaction roles of the component sets specified by role1 and role2. More...
 
virtual void removeComponent (std::size_t idx)=0
 Removes the reaction component at the specified index. More...
 
virtual void removeComponent (std::size_t idx, unsigned int role)=0
 Removes the reaction component at index idx in the list of components with the specified role. More...
 
ComponentIterator removeComponent (const ComponentIterator &it)
 Removes the reaction component specified by the iterator it. More...
 
virtual void removeComponents (unsigned int role)=0
 Removes all components with the specified role. More...
 
virtual SharedPointer clone () const =0
 Creates a copy of the current reaction state. More...
 
virtual void copy (const Reaction &rxn)=0
 Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn. More...
 
Reactionoperator= (const Reaction &rxn)
 Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn. More...
 
- Public Member Functions inherited from CDPL::Base::PropertyContainer
std::size_t getNumProperties () const
 Returns the number of property entries. More...
 
template<typename T >
void setProperty (const LookupKey &key, T &&val)
 Sets the value of the property specified by key to val. More...
 
template<typename T >
const T & getProperty (const LookupKey &key) const
 Returns the value of the property specified by key as a const reference to an object of type T. More...
 
template<typename T >
const T & getPropertyOrDefault (const LookupKey &key, const T &def_val) const
 Returns the value of the property specified by key as a const reference to an object of type T, or the default value def_val if a stored value does not exist. More...
 
const AnygetProperty (const LookupKey &key, bool throw_=false) const
 Returns the value of the property specified by key. More...
 
bool isPropertySet (const LookupKey &key) const
 Tells whether or not a value has been assigned to the property specified by key. More...
 
ConstPropertyIterator getPropertiesBegin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator getPropertiesEnd () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
ConstPropertyIterator begin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator end () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
bool removeProperty (const LookupKey &key)
 Clears the value of the property specified by key. More...
 
void clearProperties ()
 Clears all property values. More...
 
void addProperties (const PropertyContainer &cntnr)
 Adds the property value entries in the PropertyContainer instance cntnr. More...
 
void copyProperties (const PropertyContainer &cntnr)
 Replaces the current set of properties by a copy of the entries in cntnr. More...
 
void swap (PropertyContainer &cntnr)
 Exchanges the properties of this container with the properties of the container cntnr. More...
 
const PropertyContainergetProperties () const
 Returns a const reference to itself. More...
 

Static Public Member Functions

static void registerCopyPostprocessingFunction (const CopyPostprocessingFunction &func)
 

Protected Member Functions

void invokeCopyPostprocessingFunctions (const Reaction &src_rxn)
 
- Protected Member Functions inherited from CDPL::Base::PropertyContainer
 PropertyContainer ()
 Constructs an empty PropertyContainer instance. More...
 
 PropertyContainer (const PropertyContainer &cntnr)
 Constructs a copy of the PropertyContainer instance cntnr. More...
 
virtual ~PropertyContainer ()
 Virtual destructor. More...
 
PropertyContaineroperator= (const PropertyContainer &cntnr)
 Assignment operator. More...
 

Detailed Description

Reaction.

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated Reaction instances.

◆ ConstComponentIterator

A constant random access iterator used to iterate over the components of the reaction.

◆ ComponentIterator

A mutable random access iterator used to iterate over the components of the reaction.

◆ CopyPostprocessingFunction

Constructor & Destructor Documentation

◆ ~Reaction()

virtual CDPL::Chem::Reaction::~Reaction ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ clear()

virtual void CDPL::Chem::Reaction::clear ( )
pure virtual

Removes all components and clears all properties of the reaction.

Implemented in CDPL::Chem::BasicReaction.

◆ getNumComponents() [1/2]

virtual std::size_t CDPL::Chem::Reaction::getNumComponents ( ) const
pure virtual

Returns the number of reaction components.

Returns
The number of reaction components.

Implemented in CDPL::Chem::BasicReaction.

◆ getNumComponents() [2/2]

virtual std::size_t CDPL::Chem::Reaction::getNumComponents ( unsigned int  role) const
pure virtual

Returns the number of reaction components with the specified role.

Parameters
roleA flag that specifies the reaction role (see namespace Chem::ReactionRole).
Returns
The number of reaction components with the specified role.
Exceptions
Base::ValueErrorif the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ getComponentRole()

virtual unsigned int CDPL::Chem::Reaction::getComponentRole ( const Molecule mol) const
pure virtual

Returns the reaction role of the specified component.

If the specified molecule is not a component of this reaction, Chem::ReactionRole::NONE will be returned.

Parameters
molThe component for which to return the reaction role.
Returns
A flag that specifies the reaction role of the component (see namespace Chem::ReactionRole).

Implemented in CDPL::Chem::BasicReaction.

◆ getComponentIndex()

virtual std::size_t CDPL::Chem::Reaction::getComponentIndex ( const Molecule mol) const
pure virtual

Returns the index of the specified reaction component.

Parameters
molThe component for which to return the index.
Returns
The zero-based index of the specified reaction component.
Exceptions
Base::ItemNotFoundif the specified molecule is not a component of this reaction.

Implemented in CDPL::Chem::BasicReaction.

◆ containsComponent()

virtual bool CDPL::Chem::Reaction::containsComponent ( const Molecule mol) const
pure virtual

Tells whether the specified molecule is a component of this reaction.

Parameters
molThe molecule to look for.
Returns
true if the specified molecule is a component of this reaction, and false otherwise.

Implemented in CDPL::Chem::BasicReaction.

◆ getComponentsBegin() [1/4]

ConstComponentIterator CDPL::Chem::Reaction::getComponentsBegin ( ) const

Returns a constant iterator pointing to the beginning of the reaction components.

Returns
A constant iterator pointing to the beginning of the reaction components.

◆ getComponentsBegin() [2/4]

ComponentIterator CDPL::Chem::Reaction::getComponentsBegin ( )

Returns a mutable iterator pointing to the beginning of the reaction components.

Returns
A mutable iterator pointing to the beginning of the reaction components.

◆ getComponentsEnd() [1/4]

ConstComponentIterator CDPL::Chem::Reaction::getComponentsEnd ( ) const

Returns a constant iterator pointing to the end of the reaction components.

Returns
A constant iterator pointing to the end of the reaction components.

◆ getComponentsEnd() [2/4]

ComponentIterator CDPL::Chem::Reaction::getComponentsEnd ( )

Returns a mutable iterator pointing to the end of the reaction components.

Returns
A mutable iterator pointing to the end of the reaction components.

◆ begin() [1/2]

ConstComponentIterator CDPL::Chem::Reaction::begin ( ) const

Returns a constant iterator pointing to the beginning of the reaction components.

Returns
A constant iterator pointing to the beginning of the reaction components.

◆ begin() [2/2]

ComponentIterator CDPL::Chem::Reaction::begin ( )

Returns a mutable iterator pointing to the beginning of the reaction components.

Returns
A mutable iterator pointing to the beginning of the reaction components.

◆ end() [1/2]

ConstComponentIterator CDPL::Chem::Reaction::end ( ) const

Returns a constant iterator pointing to the end of the reaction components.

Returns
A constant iterator pointing to the end of the reaction components.

◆ end() [2/2]

ComponentIterator CDPL::Chem::Reaction::end ( )

Returns a mutable iterator pointing to the end of the reaction components.

Returns
A mutable iterator pointing to the end of the reaction components.

◆ getComponentsBegin() [3/4]

ConstComponentIterator CDPL::Chem::Reaction::getComponentsBegin ( unsigned int  role) const

Returns a constant iterator pointing to the beginning of the reaction components with the specified role.

Parameters
roleA flag that specifies the reaction role (see namespace Chem::ReactionRole).
Returns
A constant iterator pointing to the beginning of the reaction components with the specified role.
Exceptions
Base::ValueErrorif the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

◆ getComponentsBegin() [4/4]

ComponentIterator CDPL::Chem::Reaction::getComponentsBegin ( unsigned int  role)

Returns a mutable iterator pointing to the beginning of the reaction components with the specified role.

Parameters
roleA flag that specifies the reaction role (see namespace Chem::ReactionRole).
Returns
A mutable iterator pointing to the beginning of the reaction components with the specified role.
Exceptions
Base::ValueErrorif the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

◆ getComponentsEnd() [3/4]

ConstComponentIterator CDPL::Chem::Reaction::getComponentsEnd ( unsigned int  role) const

Returns a constant iterator pointing to the end of the reaction components with the specified role.

Parameters
roleA flag that specifies the reaction role (see namespace Chem::ReactionRole).
Returns
A constant iterator pointing to the end of the reaction components with the specified role.
Exceptions
Base::ValueErrorif the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

◆ getComponentsEnd() [4/4]

ComponentIterator CDPL::Chem::Reaction::getComponentsEnd ( unsigned int  role)

Returns a mutable iterator pointing to the end of the reaction components with the specified role.

Parameters
roleA flag that specifies the reaction role (see namespace Chem::ReactionRole).
Returns
A mutable iterator pointing to the end of the reaction components with the specified role.
Exceptions
Base::ValueErrorif the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

◆ getComponent() [1/4]

virtual const Molecule& CDPL::Chem::Reaction::getComponent ( std::size_t  idx) const
pure virtual

Returns a const reference to the reaction component at index idx.

Parameters
idxThe zero-based index of the reaction component to return.
Returns
A const reference to the reaction component at the specified index.
Exceptions
Base::IndexErrorif the number of components is zero or idx is not in the range [0, getNumComponents() - 1].

Implemented in CDPL::Chem::BasicReaction.

◆ getComponent() [2/4]

virtual Molecule& CDPL::Chem::Reaction::getComponent ( std::size_t  idx)
pure virtual

Returns a non-const reference to the reaction component at index idx.

Parameters
idxThe zero-based index of the reaction component to return.
Returns
A non-const reference to the reaction component at the specified index.
Exceptions
Base::IndexErrorif the number of components is zero or idx is not in the range [0, getNumComponents() - 1].

Implemented in CDPL::Chem::BasicReaction.

◆ getComponent() [3/4]

virtual const Molecule& CDPL::Chem::Reaction::getComponent ( std::size_t  idx,
unsigned int  role 
) const
pure virtual

Returns a const reference to the reaction component at index idx in the list of components with the specified role.

Parameters
idxThe zero-based index of the reaction component to return.
roleA flag indicating the reaction role of the component (see namespace Chem::ReactionRole).
Returns
A const reference to the reaction component with the specified role and index.
Exceptions
Base::IndexErrorif the number of components with the specified role is zero or idx is not in the range [0, getNumComponents(role) - 1]. Base::ValueError if the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ getComponent() [4/4]

virtual Molecule& CDPL::Chem::Reaction::getComponent ( std::size_t  idx,
unsigned int  role 
)
pure virtual

Returns a non-const reference to the reaction component at index idx in the list of components with the specified role.

Parameters
idxThe zero-based index of the reaction component to return.
roleA flag indicating the reaction role of the component (see namespace Chem::ReactionRole).
Returns
A non-const reference to the reaction component with the specified role and index.
Exceptions
Base::IndexErrorif the number of components with the specified role is zero or idx is not in the range [0, getNumComponents(role) - 1]. Base::ValueError if the value of role is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ addComponent()

virtual Molecule& CDPL::Chem::Reaction::addComponent ( unsigned int  role)
pure virtual

Creates a new reaction component with the specified role.

Parameters
roleA flag specifying the reaction role of the new component (see namespace Chem::ReactionRole).
Returns
A reference to the newly created component molecule.
Exceptions
Base::ValueErrorif the value of role is not Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ swapComponentRoles()

virtual void CDPL::Chem::Reaction::swapComponentRoles ( unsigned int  role1,
unsigned int  role2 
)
pure virtual

Swaps the reaction roles of the component sets specified by role1 and role2.

If role1 is equal to role2, the method has no effect.

Parameters
role1A flag specifying the reaction role of the first component set (see namespace Chem::ReactionRole).
role2A flag specifying the reaction role of the second component set (see namespace Chem::ReactionRole).
Exceptions
Base::ValueErrorif the value of role1 and/or role2 is not equal to Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ removeComponent() [1/3]

virtual void CDPL::Chem::Reaction::removeComponent ( std::size_t  idx)
pure virtual

Removes the reaction component at the specified index.

Parameters
idxThe zero-based index of the component to remove.
Exceptions
Base::IndexErrorif the number of components is zero or idx is not in the range [0, getNumComponents() - 1].

Implemented in CDPL::Chem::BasicReaction.

◆ removeComponent() [2/3]

virtual void CDPL::Chem::Reaction::removeComponent ( std::size_t  idx,
unsigned int  role 
)
pure virtual

Removes the reaction component at index idx in the list of components with the specified role.

Parameters
idxThe zero-based index of the component to remove.
roleThe reaction role of the components
Exceptions
Base::IndexErrorif the number of components with the specified role is zero or idx is not in the range [0, getNumComponents(role) - 1]. Base::ValueError if the value of role is not Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ removeComponent() [3/3]

ComponentIterator CDPL::Chem::Reaction::removeComponent ( const ComponentIterator it)

Removes the reaction component specified by the iterator it.

Parameters
itA mutable iterator that specifies the component to remove.
Returns
A mutable iterator pointing to the next reaction component in the list.
Exceptions
Base::RangeErrorif the number of reaction components is zero or it is not in the range [getComponentsBegin(), getComponentsEnd() - 1].

◆ removeComponents()

virtual void CDPL::Chem::Reaction::removeComponents ( unsigned int  role)
pure virtual

Removes all components with the specified role.

Parameters
roleA flag specifying the reaction role of the components to remove (see namespace Chem::ReactionRole).
Exceptions
Base::ValueErrorif the value of role is not Chem::ReactionRole::REACTANT, Chem::ReactionRole::AGENT or Chem::ReactionRole::PRODUCT.

Implemented in CDPL::Chem::BasicReaction.

◆ clone()

virtual SharedPointer CDPL::Chem::Reaction::clone ( ) const
pure virtual

Creates a copy of the current reaction state.

Returns
A smart pointer to the copy of the reaction.

Implemented in CDPL::Chem::BasicReaction.

◆ copy()

virtual void CDPL::Chem::Reaction::copy ( const Reaction rxn)
pure virtual

Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn.

Parameters
rxnThe reaction to copy.

Implemented in CDPL::Chem::BasicReaction.

◆ operator=()

Reaction& CDPL::Chem::Reaction::operator= ( const Reaction rxn)

Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn.

Internally calls copy() to perform the actual work.

Parameters
rxnThe reaction to copy.
Returns
A reference to itself.

◆ registerCopyPostprocessingFunction()

static void CDPL::Chem::Reaction::registerCopyPostprocessingFunction ( const CopyPostprocessingFunction func)
static

◆ invokeCopyPostprocessingFunctions()

void CDPL::Chem::Reaction::invokeCopyPostprocessingFunctions ( const Reaction src_rxn)
protected

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