Chemical Data Processing Library C++ API - Version 1.2.0
Public Types | Public Member Functions | List of all members
CDPL::Chem::MatchExpression< ObjType1, ObjType2 > Class Template Reference

A generic boolean expression interface for the implementation of query/target object equivalence tests in molecular graph matching algorithms. More...

#include <MatchExpression.hpp>

+ Inheritance diagram for CDPL::Chem::MatchExpression< ObjType1, ObjType2 >:

Public Types

typedef std::shared_ptr< MatchExpressionSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances. More...
 

Public Member Functions

virtual ~MatchExpression ()
 Virtual Destructor. More...
 
virtual bool operator() (const ObjType1 &query_obj1, const ObjType2 &query_obj2, const ObjType1 &target_obj1, const ObjType2 &target_obj2, const Base::Any &aux_data) const
 Performs an evaluation of the expression for the given query and target objects. More...
 
virtual bool operator() (const ObjType1 &query_obj1, const ObjType2 &query_obj2, const ObjType1 &target_obj1, const ObjType2 &target_obj2, const AtomBondMapping &mapping, const Base::Any &aux_data) const
 Performs an evaluation of the expression for the given query and target objects under consideration of the provided candidate atom/bond mapping. More...
 
virtual bool requiresAtomBondMapping () const
 Tells whether the expression must be reevaluated after a query to target atom/bond mapping candidate has been found. More...
 

Detailed Description

template<typename ObjType1, typename ObjType2 = void>
class CDPL::Chem::MatchExpression< ObjType1, ObjType2 >

A generic boolean expression interface for the implementation of query/target object equivalence tests in molecular graph matching algorithms.

The MatchExpression interface abstracts the task of checking a set of constraints on the attributes of target objects when performing query object equivalence tests in molecular graph matching procedures. Subclasses of MatchExpression must override one (or all, if required) of the provided function call operators to implement the logic of the constraint checks. The first form of the two operators gets called in the pre-mapping stage of the graph matching algorithm where all feasible query/target object pairings are determined. In this pre-mapping stage all sorts of query constraints can be checked that are invariant with respect to the final mapping between any of the other query and target objects. The second type of operator is invoked immediately after a complete graph mapping solution has been found and can be used to re-evaluate the validity of a given query/target object pairing in the context of the provided matching result. As soon as a pairing is found to be invalid, the current mapping solution is rejected and the algorithm proceeds to find the next possible query to target graph mapping (if any). For efficiency reasons, subclasses of MatchExpression which implement the post-mapping function call operator must explicitly enable its invocation by additionally overriding the MatchExpression::requiresAtomBondMapping() method. Its implementation simply has to return true (the default implementation returns false) to request the invocation of the operator.

Template Parameters
ObjType1The type of the primary query/target objects for which the expression gets evaluated.
ObjType2The type of secondary query/target objects which provide auxiliary information for expression evaluation.

Member Typedef Documentation

◆ SharedPointer

template<typename ObjType1 , typename ObjType2 = void>
typedef std::shared_ptr<MatchExpression> CDPL::Chem::MatchExpression< ObjType1, ObjType2 >::SharedPointer

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

Constructor & Destructor Documentation

◆ ~MatchExpression()

template<typename ObjType1 , typename ObjType2 = void>
virtual CDPL::Chem::MatchExpression< ObjType1, ObjType2 >::~MatchExpression ( )
inlinevirtual

Virtual Destructor.

Member Function Documentation

◆ operator()() [1/2]

template<typename ObjType1 , typename ObjType2 >
bool CDPL::Chem::MatchExpression< ObjType1, ObjType2 >::operator() ( const ObjType1 &  query_obj1,
const ObjType2 &  query_obj2,
const ObjType1 &  target_obj1,
const ObjType2 &  target_obj2,
const Base::Any aux_data 
) const
virtual

Performs an evaluation of the expression for the given query and target objects.

Parameters
query_obj1The primary query object.
query_obj2The secondary query object.
target_obj1The primary target object.
target_obj2The secondary target object.
aux_dataProvides auxiliary information for the evaluation of the expression.
Returns
The result of the expression evaluation for the specified query and target objects.
Note
The default implementation returns true.

Reimplemented in CDPL::Chem::PropertyMatchExpression< ValueType, MatchFunc, ObjType1, ObjType2 >, CDPL::Chem::ORMatchExpressionList< ObjType1, ObjType2 >, CDPL::Chem::NOTMatchExpression< ObjType1, ObjType2 >, and CDPL::Chem::ANDMatchExpressionList< ObjType1, ObjType2 >.

◆ operator()() [2/2]

template<typename ObjType1 , typename ObjType2 >
bool CDPL::Chem::MatchExpression< ObjType1, ObjType2 >::operator() ( const ObjType1 &  query_obj1,
const ObjType2 &  query_obj2,
const ObjType1 &  target_obj1,
const ObjType2 &  target_obj2,
const AtomBondMapping mapping,
const Base::Any aux_data 
) const
virtual

Performs an evaluation of the expression for the given query and target objects under consideration of the provided candidate atom/bond mapping.

Parameters
query_obj1The primary query object.
query_obj2The secondary query object.
target_obj1The primary target object.
target_obj2The secondary target object.
mappingThe current query to target atom/bond mapping candidate to evaluate.
aux_dataProvides auxiliary information for the evaluation of the expression.
Returns
The result of the expression evaluation for the specified query and target objects.
Note
The default implementation returns the result of operator()(query_obj1, query_obj2, target_obj1, target_obj2, aux_data).

Reimplemented in CDPL::Chem::ORMatchExpressionList< ObjType1, ObjType2 >, CDPL::Chem::NOTMatchExpression< ObjType1, ObjType2 >, and CDPL::Chem::ANDMatchExpressionList< ObjType1, ObjType2 >.

◆ requiresAtomBondMapping()

template<typename ObjType1 >
bool CDPL::Chem::MatchExpression< ObjType1 >::requiresAtomBondMapping
virtual

Tells whether the expression must be reevaluated after a query to target atom/bond mapping candidate has been found.

Returns
true if the expression needs to be evaluated again after a query to target atom/bond mapping candidate has been found, and false otherwise.
Note
The default implementation returns false.

Reimplemented in CDPL::Chem::ReactionComponentGroupingMatchExpression, CDPL::Chem::ReactionAtomMappingMatchExpression, CDPL::Chem::NOTMatchExpression< ObjType1, ObjType2 >, CDPL::Chem::MolecularGraphComponentGroupingMatchExpression, CDPL::Chem::MatchExpressionList< ObjType1, ObjType2 >, CDPL::Chem::MatchExpressionList< ObjType1, void >, CDPL::Chem::BondSubstituentDirectionMatchExpression, CDPL::Chem::BondConfigurationMatchExpression, and CDPL::Chem::AtomConfigurationMatchExpression.


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