.. oe:namespace:: OEChem



.. meta::
   :keywords: OEMatchFunc, MatchFunc


.. _OEChem_OEMatchFunc:

.. oe:class:: OEMatchFunc

   .. oe:api::


      template<class Arg>
      class OEMatchFunc : public OESystem::OEUnaryPredicate<Arg>

   This class represents :ref:`OEMatchFunc <OEChem_OEMatchFunc>` template functor that
   identifies objects (:ref:`OEAtomBase <OEChem_OEAtomBase>`, :ref:`OEBondBase <OEChem_OEBondBase>`)
   that match a query substructure specified in construction.

   .. seealso::

      * :ref:`section_predicates_match` section 

   The following methods are publicly inherited from :ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`:

   ============================================================================== ============================================================================== ===============================================================================
   :oe:meth:`operator()<OESystem::OEUnaryPredicate::operator()>`                  :oe:meth:`CreateCopy<OESystem::OEUnaryPredicate::CreateCopy>`                  :oe:meth:`CreatePredicateCopy<OESystem::OEUnaryPredicate::CreatePredicateCopy>`
   ============================================================================== ============================================================================== ===============================================================================

   The following methods are publicly inherited from :ref:`OEUnaryFunction <OESystem_OEUnaryFunction>`:

   ============================================================ ============================================================ ===========================================================
   :oe:meth:`operator()<OESystem::OEUnaryFunction::operator()>` :oe:meth:`CreateCopy<OESystem::OEUnaryFunction::CreateCopy>`                                                            
   ============================================================ ============================================================ ===========================================================


   The following specializations exist for this template:
   
   .. oe:language:: c++

      ==================== ====================================================================
      Specialized Functor  Definition                                                          
      ==================== ====================================================================
      OEMatchAtomBase      :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEAtomBase <OEChem_OEAtomBase>`>
      OEMatchGraphMol      :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEGraphMol <OEChem_OEGraphMol>`>
      OEMatchMolBase       :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEMolBase <OEChem_OEMolBase>`>
      ==================== ====================================================================

      .. index::    
         single: OEMatchAtomBase
         single: OEMatchGraphMol
         single: OEMatchMolBase

   .. oe:language:: python java csharp


      ==================== ====================================================================
      Specialized Functor  Definition                                                          
      ==================== ====================================================================
      OEMatchAtom          :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEAtomBase <OEChem_OEAtomBase>`>
      OEMatchGraphMol      :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEGraphMol <OEChem_OEGraphMol>`>
      OEMatchMolBase       :ref:`OEMatchFunc <OEChem_OEMatchFunc>` <:ref:`OEMolBase <OEChem_OEMolBase>`>
      ==================== ====================================================================

       .. index::    
          single: OEMatchAtom
          single: OEMatchGraphMol
          single: OEMatchMolBase

   .. oe:method:: Constructors

      .. oe:api::

         OEMatchFunc(const char* smarts)

      Constructs the functor with the internal substructure search
      specified by the 'smarts' (:term:`SMARTS`) pattern.

      .. oe:api::

         OEMatchFunc(const OEQMolBase& qmol)

      Constructs the functor with the internal substructure search
      specified by the 'qmol' query molecule.

      .. oe:api::

         OEMatchFunc(const OEMolBase& mol, unsigned int aexpr,
                     unsigned int bexpr)

      Constructs the functor with the internal substructure search
      that is created from 'mol' using the specified expression options.
      The atom and bond expression options passed as the second and
      third arguments to the method are defined
      in the :oe:constns:`OEChem::OEExprOpts` namespace. The expression
      options are used to convert the atom and bond data into
      expression trees which are used during the subgraph search.

   .. oe:method:: operator()

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool operator()(const Arg& arg) const

      .. oe:language:: python

         .. oe:api:: python

            __call__(arg: Arg) -> bool

      Returns ``true`` if the 'arg' object matched by the query molecule
      defined in construction.

   .. oe:method:: operator bool

      .. oe:language:: c++ java csharp

         .. oe:api::

            operator bool()

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Returns ``true``, if the substructure search object was initialized
      correctly.

   .. oe:method:: CreateCopy

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEUnaryFunction<Arg, bool>* CreateCopy() const

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEMatchFunc

      Deep copy constructor that returns a copy of the object.
      The memory for the returned :ref:`OEMatchFunc <OEChem_OEMatchFunc>`
      object is dynamically allocated  and owned by the caller.

      .. oe:language:: c++ 

         The returned copy should be deallocated using C++
         delete operator in order to prevent a memory leak. 

