.. oe:namespace:: OEChem



.. meta::
   :keywords: OEPartPredT, PartPredT


.. _OEChem_OEPartPredT:

.. oe:class:: OEPartPredT

   .. oe:api::


      template<class T>
      class OEPartPredT : public OESystem::OEUnaryPredicate<T>

   This class represents :ref:`OEPartPredT <OEChem_OEPartPredT>` template functor that
   holds multiple parts of a molecule and
   identifies objects (that provide ``GetIdx`` method such as
   :ref:`OEAtomBase <OEChem_OEAtomBase>`, :ref:`OEBondBase <OEChem_OEBondBase>`)
   that belong to different part of a molecule
   based on the state of the functor.

   .. seealso::

      * :ref:`section_predicates_partitioning` 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 specialization exists for this template:
   
   .. oe:language:: c++

      ==================== ====================================================================
      Specialized Functor  Definition                                                          
      ==================== ====================================================================
      OEPartPred           :ref:`OEPartPredT <OEChem_OEPartPredT>` <:ref:`OEAtomBase <OEChem_OEAtomBase>`>
      ==================== ====================================================================

      .. index::
         single: OEPartPred

   .. oe:language:: python java csharp

      ==================== ====================================================================
      Specialized Functor  Definition                                                          
      ==================== ====================================================================
      OEPartPredAtom       :ref:`OEPartPredT <OEChem_OEPartPredT>` <:ref:`OEAtomBase <OEChem_OEAtomBase>`>
      ==================== ====================================================================

      .. index::
         single: OEPartPredAtom
   

   .. oe:method:: Constructors


      .. oe:api::

         OEPartPredT(unsigned int* parts, unsigned int size)

      Constructs the functor where the parts are specified in the 
      passed integer array ('parts'), the size of the 'parts'
      array is is specified by the 'size' argument.

      If the :ref:`OEPartPredT <OEChem_OEPartPredT>` is used to identify atoms
      (:ref:`OEAtomBase <OEChem_OEAtomBase>`), then 'parts' array is assumed to
      be of length equal to the number return by the
      :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx` method, where
      parts[atom. :oe:meth:`GetIdx()<OEChem::OEAtomBase::GetIdx>` ] is
      the integer associated with the part to which atom belongs.

      .. oe:api::

         OEPartPredT(const OEPartPredT& rhs)

      Copy constructor.

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEPartPredT& operator=(const OEPartPredT& rhs)

      Assignment operator that copies the data of the 'rhs' :ref:`OEPartPredT <OEChem_OEPartPredT>` object
      into the right-hand side :ref:`OEPartPredT <OEChem_OEPartPredT>` object.

      Assignment operator.


   .. oe:method:: operator()

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

         .. oe:api::

            bool operator()(const T& t) const

      .. oe:language:: python

         .. oe:api:: python

            __call__(t: T) -> bool

      If the :ref:`OEPartPredT <OEChem_OEPartPredT>` is used to identify atoms,
      then this method returns ``true``, if
      parts[ atom. :oe:meth:`GetIdx()<OEChem::OEAtomBase::GetIdx>` ] ==
      part, where 'parts' is the array passed on construction, and
      'part' is the argument set by the
      :oe:meth:`OEChem::OEPartPredT::SelectPart` method.

   .. oe:method:: CreateCopy

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEPartPredT

      Deep copy constructor that returns a copy of the object.
      The memory for the returned :ref:`OEPartPredT <OEChem_OEPartPredT>`
      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. 

   .. oe:method:: SelectPart

      .. oe:api::

         void SelectPart(unsigned int part)

      Sets the 'part' argument that is used to select a specific part
      of a molecule.

