Develop Biology
The language of life
|
#include <Reaction.h>
Public Member Functions | |
BIO_DISAMBIGUATE_ALL_CLASS_METHODS (chemical, Reaction) BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(chemical | |
filter::Chemical () | |
virtual Products | operator() (Reactants *reactants) const |
virtual Products | Process (Reactants *reactants) const |
virtual bool | ReactantsMeetRequirements (const Reactants *toCheck) const |
& | ReactionPerspective::Instance () |
template<typename T > | |
void | Require () |
template<typename T > | |
void | Require (const T *substance) |
template<typename T > | |
void | Require (const typename UnorderedMotif< Property >::Contents *properties, const typename UnorderedMotif< State >::Contents *states) |
void | Require (Name typeName, const Substance *substance) |
void | Require (Name typeName, const typename UnorderedMotif< Property >::Contents *properties, const typename UnorderedMotif< State >::Contents *states) |
virtual void | Require (Reactant *reactant) |
symmetry_type::Operation ()) explicit Reaction(Name name | |
Public Member Functions inherited from bio::chemical::Class< Reaction > | |
BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Reaction) Class(Reaction *object | |
Public Member Functions inherited from bio::physical::Class< T > | |
Class (T *object, Symmetry *symmetry=NULL) | |
virtual | ~Class () |
virtual Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Wave * | Clone () 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::Atom * | AsAtom () |
virtual const chemical::Atom * | AsAtom () const |
virtual Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Code | Attenuate (const Wave *other) |
virtual Wave * | Clone () const |
virtual Wave * | Demodulate () |
virtual const Wave * | Demodulate () const |
virtual Code | Disattenuate (const Wave *other) |
virtual Properties | GetProperties () const |
virtual Wave * | Modulate (Wave *signal) |
virtual Wave * | operator* () |
virtual const Wave * | operator* () const |
virtual Wave * | operator* (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 Symmetry * | Spin () 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 Perspective * | GetPerspective () 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 Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Wave * | Clone () 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 |
Engine * | GetLogEngine () |
const Engine * | GetLogEngine () 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 Symmetry * | Spin () const |
Public Member Functions inherited from bio::physical::Class< Filterable > | |
Class (Filterable *object, Symmetry *symmetry=NULL) | |
virtual | ~Class () |
virtual Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Wave * | Clone () const |
Filterable * | Convert (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 Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Wave * | Clone () 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 > | |
T | As () |
template<typename T > | |
const T | As () const |
template<typename T > | |
T | AsBonded () |
template<typename T > | |
const T | AsBonded () const |
template<typename T > | |
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()) |
Bonds * | GetAllBonds () |
const Bonds * | GetAllBonds () const |
Wave * | GetBonded (Valence position) |
const Wave * | GetBonded (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::Symmetry * | Spin () const |
Public Member Functions inherited from bio::physical::Class< Atom > | |
Class (Atom *object, Symmetry *symmetry=NULL) | |
virtual | ~Class () |
virtual Wave * | AsWave () |
virtual const Wave * | AsWave () const |
virtual Wave * | Clone () const |
Atom * | Convert (Wave *wave) |
virtual | operator Atom * () |
virtual | operator Wave * () |
Public Member Functions inherited from bio::chemical::Structure | |
Structure () | |
virtual | ~Structure () |
Public Member Functions inherited from bio::chemical::UnorderedStructureInterface | |
UnorderedStructureInterface () | |
virtual | ~UnorderedStructureInterface () |
template<typename T > | |
T | Add (const T t) |
template<typename T > | |
void | Clear () |
template<typename T > | |
Container * | GetAll () |
template<typename T > | |
const Container * | GetAll () const |
template<typename T > | |
std::vector< T > | GetAllAsVector () |
template<typename T > | |
const std::vector< T > | GetAllAsVector () const |
template<typename T > | |
unsigned long | GetCount () const |
template<typename T > | |
unsigned int | GetNumMatching (const Container *other) const |
template<typename T > | |
std::string | GetStringFrom (std::string separator=", ") |
template<typename T > | |
bool | Has (T content) const |
template<typename T > | |
bool | HasAll (const Container *contents) const |
template<typename T > | |
void | Import (const std::vector< T > &other) |
template<typename T > | |
void | Import (const UnorderedMotif< T > *other) |
Code | ImportAll (const physical::Wave *other) |
template<typename T > | |
T | Remove (const T t) |
Public Member Functions inherited from bio::ThreadSafe | |
ThreadSafe () | |
ThreadSafe (const ThreadSafe &toCopy) | |
virtual | ~ThreadSafe () |
void | LockThread () const |
void | UnlockThread () const |
Public Member Functions inherited from bio::chemical::LinearStructureInterface | |
LinearStructureInterface () | |
virtual | ~LinearStructureInterface () |
template<typename T > | |
Emission | ForEach (ExcitationBase *excitation) |
template<typename T > | |
T | GetById (StandardDimension id) |
template<typename T > | |
const T | GetById (StandardDimension id) const |
template<typename T > | |
T | GetByName (Name name) |
template<typename T > | |
const T | GetByName (Name name) const |
template<typename T > | |
T | GetOrCreateById (StandardDimension id) |
template<typename T > | |
T | GetOrCreateByName (Name name) |
template<typename T > | |
Code | Insert (T toAdd, const Position position=BOTTOM, const StandardDimension optionalPositionArg=0, const bool transferSubContents=false) |
Static Public Member Functions | |
template<typename T > | |
static Products | Attempt (Reactants *reactants) |
template<typename T > | |
static Products | Attempt (Substance *reactant1, Substance *reactant2=NULL, Substance *reactant3=NULL) |
template<typename T > | |
static Products | Attempt (Substances &substances) |
template<typename T > | |
static const T * | Initiate () |
static const Reaction * | Initiate (StandardDimension id) |
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) |
Public Attributes | |
Reaction | |
const Reactants * | reactants |
Public Attributes inherited from bio::chemical::Class< Reaction > | |
physical::Perspective< StandardDimension > Filter | filter |
physical::Perspective< StandardDimension > * | perspective |
Public Attributes inherited from bio::physical::Identifiable< StandardDimension > | |
Id | m_id |
Protected Attributes | |
Reactants | m_requiredReactants |
Protected Attributes inherited from bio::physical::Class< T > | |
T * | m_object |
Protected Attributes inherited from bio::physical::Wave | |
Wave * | m_signal |
Symmetry * | m_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 > | |
Filterable * | m_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 |
Additional Inherited Members | |
Public Types inherited from bio::physical::Identifiable< StandardDimension > | |
typedef StandardDimension | Id |
typedef std::vector< Id > | Ids |
Public Types inherited from bio::physical::Observer< Perspective< StandardDimension > > | |
typedef Perspective< StandardDimension > | Perspective |
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) |
A chemical::Reaction takes in Reactants and produces Products, performing some work in between. For more info, see Reactants.h, Reactant.h (singular), Products.h, and Substance.h This is basically a fancy functor that takes advantage of Atom::Bonds and Substance Properties and States to do argument validation.
Reactions, like those in real life, will often deal with the changing of chemical Bonds and Properties. Reactions are for turning iron into gold. All lesser magicks can be performed with Excitation! In a more real sense, Excitations should not make or break Bonds (except in rare circumstances) whereas Reactions, when fully Processed, should change the Reactants in some significant way, hence their return as Products. Another difference between Reactants and Excitations is that Excitations act ON a Wave (i.e. wave->someMethod()) while Reactions act WITH Substances. Additionally, Excitations store their arguments as members, requiring each kind of Excitation function call to be a new object (e.g. to call firstObject->method(firstArg) and secondObject->method(firstArg) is 1 Excitation while firstObject->method(secondArg) would require a new Excitation). Reactions, on the other hand, are more traditional functors and do not (by default) maintain any state between calls, meaning the same Reaction object can be used for all invokations. Both Excitation and Reaction are functors but the behavior and minimum requirements for using each are different.
A real life corollary: Imagine a sound wave hitting a wall. This could be modeled as an Excitation: the energy from the air molecules excite those in the wall, passing energy between them. We might write this as soundEnergyTransferExcitation = EnergyTransferExcitation(sound); soundEnergyTransferExcitation(wall)
, which could produce code like wall->ExchangeEnergy(sound)
and could be used on anything the sound wave hit (e.g. soundEnergyTransferExcitation(floor)
). A similar, but inappropriate Reaction could be EnergyTransferReaction(wall, sound)
which might produce code like wall->ExchangeEnergy(sound); return {wall, sound}
, saying that a sound wave hitting a wall creates a new wall and sound wave. The same Reaction would have to be called again for each object the sound wave impacted. A more appropriate Reaction would be something like Burn(fuel, air)
, which might return {flame, ash, smoke, air}
, where you could then check the flame->GetColor(), smoke->GetSmell(), reactantAir->GetQuantity("Oxygen") - productAir->GetQuantity("Oxygen"), and so on. The inappropriate Excitation analog, airBurnExcitation = BurnExcitation(air); airBurnExcitation(fuel)
, would call fuel->burn(air)
, which could work but would require that anything capable of being burned implement the burn method.
While the semantic difference between the implementations of Excitation and Reaction is subtle and possibly pedantic, the use case of calling a class method vs calling a function with a class should be clear cut. In reality, you'll probably want to use Excitations in your Reactions and vice-versa. For instance, hitting a wall with a nuclear blast would be far more complex than modeling a sound wave. See Excitation.h for more info.
To make a Reaction, you must overload Process (virtual chemical::Products Process(chemical::Substances& reactants) = 0;) Then, preferably in your ctor, state the Require()ments. Each Require()d Reactant* will be checked against the reactants (Substances&) provided to *this. ORDER MATTERS! The reactants must follow the same order as the Required Reactants!
To invoke a Reaction, use the operator(), providing reactants. For example: MyReaction r; r(MyReactants); Doing so will do all necessary input checking and then call Process(), if all is good. Otherwise no Products are returned and you will get a code::FailedReaction().
Other ways to invoke a reaction include: Reaction::Attempt<MyReaction>(myReactants); myReaction = Reaction::Initiate<MyReaction>(); myReaction(myReactants);
Definition at line 74 of file Reaction.h.
|
inlinestatic |
Invokes a reaction of the given id using the provided reactants.
T | a reaction type |
reactants | the reactants to provide to T. |
Definition at line 250 of file Reaction.h.
References BIO_SANITIZE_WITH_CACHE, bio::code::NotImplemented(), and reactants.
|
inlinestatic |
Ease of use helper for invoking Reactions without creating a vector (Mostly useful for C++98)
T |
reactant1 | |
reactant2 | |
reactant3 |
Definition at line 282 of file Reaction.h.
References reactants.
|
inlinestatic |
Definition at line 261 of file Reaction.h.
References BIO_SANITIZE_WITH_CACHE, bio::code::NotImplemented(), and reactants.
bio::chemical::Reaction::BIO_DISAMBIGUATE_ALL_CLASS_METHODS | ( | chemical | , |
Reaction | |||
) |
Ensure virtual methods point to Class implementations. Standard ctors.
bio::chemical::Reaction::filter::Chemical | ( | ) |
|
inlinestatic |
Get a Reaction! This should be used to avoid unnecessary new and deletes. This only works for Reactions that have a name matching their type (i.e. were constructed with name=PeriodicTable::Instance().GetNameFromType(*this)), which is true for all Reactions in the core Biology framework.
T |
Definition at line 235 of file Reaction.h.
References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and ReactionPerspective::Instance().
|
static |
Get a Reaction! This should be used to avoid unnecessary new and deletes. Use when the TypeName does not match the Name or when you have the id of the Reaction you want.
id |
Definition at line 82 of file Reaction.cpp.
References BIO_SANITIZE_WITH_CACHE.
A Reaction takes in some Reactants and checks if they match the Reactants for *this. If the inputs check out, the Reaction occurs and the products are returned.
reactants |
Definition at line 89 of file Reaction.cpp.
References BIO_SANITIZE_AT_SAFETY_LEVEL_2, and bio::code::FailedReaction().
User defined reaction process. The actual work of *this.
reactants |
Definition at line 193 of file Reaction.h.
References bio::code::NotImplemented().
|
virtual |
Checks if the given Substances match the Reactants in *this. ORDER MATTERS! NOTE: toCheck may have MORE substances than just the reactants needed for this->Process but must have AT LEAST the required Reactants.
toCheck |
Reimplemented in bio::molecular::Pathway.
Definition at line 77 of file Reaction.cpp.
References bio::chemical::UnorderedStructureInterface::HasAll().
& bio::chemical::Reaction::ReactionPerspective::Instance | ( | ) |
Referenced by Initiate().
|
inline |
Wrapper around Require(Reactant*). Constructs Reactant from args, adding the Enabled() State as a requirement. NOTE: T should not have pointer type (unless you're using **).
T | the T* which will be used in the Reaction (without the *) |
Definition at line 142 of file Reaction.h.
References bio::state::Enabled(), bio::Properties, and Require().
Referenced by Require().
|
inline |
Wrapper around Require(Reactant*). Constructs Reactant from args
T | of the T* which will be used in the Reaction (without the *) |
substance | the T* to use (with the *). |
Definition at line 161 of file Reaction.h.
References Require().
|
inline |
Wrapper around Require(Reactant*). Constructs Reactant from args
T | the T* which will be used in the Reaction (without the *) |
Definition at line 175 of file Reaction.h.
References Require().
Wrapper around Require(Reactant*). Constructs Reactant from args
typeName | |
substance |
Definition at line 50 of file Reaction.cpp.
void bio::chemical::Reaction::Require | ( | Name | typeName, |
const typename UnorderedMotif< Property >::Contents * | properties, | ||
const typename UnorderedMotif< State >::Contents * | states | ||
) |
Wrapper around Require(Reactant*). Constructs Reactant from args
typeName | |
properties | |
states |
|
virtual |
Add a required Reactant to *this. NOTE: ORDER MATTERS! The order of requirements MUST be the order of arguments provided to operator().
reactant |
Definition at line 45 of file Reaction.cpp.
bio::chemical::Reaction::symmetry_type::Operation | ( | ) |
name | |
reactants |
bio::chemical::Reaction::Reaction |
Definition at line 89 of file Reaction.h.
Referenced by bio::molecular::Pathway::Process().
|
protected |
Definition at line 297 of file Reaction.h.
const Reactants* bio::chemical::Reaction::reactants |
Definition at line 100 of file Reaction.h.
Referenced by Attempt(), and bio::molecular::Pathway::Process().