.. oe:namespace:: OESystem



.. meta::
   :keywords: OEHasRole, HasRole


.. _OESystem_OEHasRole:

.. oe:class:: OEHasRole

   .. oe:api::

      class OEHasRole : public OESystem::OEUnaryPredicate<OERoleSet>

   This class represents `OEHasRole`, a functor for objects
   inherited from :ref:`OERoleSet <OESystem_OERoleSet>`
   that identifies those containing a specified role (:ref:`OERole <OESystem_OERole>`).

   .. oe:source:: RoleSet.py
      :language: python
      :noindent:
      :frag:     SNIPPET-HAS-ROLE-PRED

   .. oe:source:: RoleSet.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-HAS-ROLE-PRED

   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>`                                                            
   ============================================================ ============================================================ ===========================================================

   .. oe:method:: Constructors

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

         .. oe:api::

            OEHasRole(const OERole& role)

      .. oe:language:: python

         .. oe:api:: python

            OEHasRole(role: OERole) -> OEHasRole

      Copy constructor.

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

         .. oe:api::

            OEHasRole(const std::string& name)

      .. oe:language:: python

         .. oe:api:: python

            OEHasRole(name: str) -> OEHasRole

      Convenience constructor allowing the predicate to be
      constructed from a `role name` string.

   .. oe:method:: operator()

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

         .. oe:api::

            bool operator()(const OERoleSet& myObject) const

      .. oe:language:: python

         .. oe:api:: python

            __call__(someObject: OERoleSet) -> bool

      Returns ``true`` if the :oe:cls:`OERoleSet<OESystem::OERoleSet>` contains
      an :oe:cls:`OERole<OESystem::OERole>` that
      matches the value used in the :oe:meth:`OESystem::OEHasRole::Constructors`.

   .. oe:method:: CreateCopy

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEHasRole

      Deep copy constructor that returns a copy of the object.
      The memory for the returned `OEHasRole` 
      object is dynamically allocated and owned by the caller.

      .. oe:language:: c++ 

         The returned copy should be managed to ensure
         it is deallocated using C++
         ``delete`` operator in order to prevent a memory leak. 
