.. oe:namespace:: OESystem



.. meta::
   :keywords: OERoleSet, RoleSet


.. _OESystem_OERoleSet:

.. oe:class:: OERoleSet

   .. oe:api::

      class OERoleSet

   This class represents `OERoleSet`, a parent class for objects that
   need to store :ref:`OERole <OESystem_OERole>` objects.

   An :oe:cls:`OERole<OESystem::OERole>` is an object that helps
   define a classification (naming) scheme
   to represent a category or functional role.

   .. oe:source:: RoleSet.py
      :language: python
      :noindent:
      :frag:     SNIPPET-CREATE-ROLE-OBJECT

   .. oe:source:: RoleSet.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-CREATE-ROLE-OBJECT

   Objects derived from :ref:`OERoleSet <OESystem_OERoleSet>` can
   have :oe:cls:`OERole<OESystem::OERole>` objects added
   to them as a way of marking them for particular uses.

   .. oe:source:: RoleSet.py
      :language: python
      :noindent:
      :frag:     SNIPPET-ADD-ROLE-OBJECT

   .. oe:source:: RoleSet.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-ADD-ROLE-OBJECT

   The following classes derive from this class:
    * :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>`
    * :ref:`OEMatch <OEChem_OEMatch>`
    * :ref:`OEMatchBase <OEChem_OEMatchBase>`
   
   It is possible to test if an :oe:cls:`OERole<OESystem::OERole>`
   has been added using the :oe:meth:`HasRole<OESystem::OERoleSet::HasRole>`
   method, or with the :ref:`OEHasRole <OESystem_OEHasRole>` predicate.

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

      .. oe:api::

         OERoleSet & operator=(const OERoleSet & rhs)

      Assignment operator.


   .. oe:method:: AddRole

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

         .. oe:api::

            bool AddRole(const OERole& role)

      .. oe:language:: python

         .. oe:api:: python

            AddRole(role: OERole) -> bool

      Add the specified :oe:cls:`OERole<OESystem::OERole>` to
      this :oe:cls:`OERoleSet<OESystem::OERoleSet>`.
      Returns ``true`` if successful.

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

         .. oe:api::

            bool AddRole(const std::string& name)

      .. oe:language:: python

         .. oe:api:: python

            AddRole(name: str) -> bool

      Convenience method for adding a
      :oe:cls:`OERole<OESystem::OERole>` by name.

      .. oe:source:: RoleSet.py
         :language: python
         :noindent:
         :frag:     SNIPPET-ADD-ROLE-STRING

      .. oe:source:: RoleSet.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-ADD-ROLE-STRING

   .. oe:method:: ClearRoles

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

         .. oe:api::

            void ClearRoles()

      .. oe:language:: python

         .. oe:api:: python

            ClearRoles() -> None

      Delete all the :oe:cls:`OERole<OESystem::OERole>` objects from
      this :oe:cls:`OERoleSet<OESystem::OERoleSet>`.

   .. oe:method:: DeleteRole

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

         .. oe:api::

            bool DeleteRole(const OERole& role)
            bool DeleteRole(const std::string& name)

      .. oe:language:: python

         .. oe:api:: python

            DeleteRole(role: OERole) -> bool
            DeleteRole(name: str) -> bool

      Delete the specified :oe:cls:`OERole<OESystem::OERole>` from
      this :oe:cls:`OERoleSet<OESystem::OERoleSet>`.
      Returns ``true`` if successful.

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

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

   .. oe:method:: GetRoles

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

         .. oe:api::

            OEIterBase<const OERole>* GetRoles() const

      .. oe:language:: python

         .. oe:api:: python

            GetRoles() -> Iterable[OERole]

      Returns an iterator of every :oe:cls:`OERole<OESystem::OERole>` object
      in this :oe:cls:`OERoleSet<OESystem::OERoleSet>`.

      .. oe:source:: RoleSet.py
         :language: python
         :noindent:
         :frag:     SNIPPET-GET-ALL-ROLES

      .. oe:source:: RoleSet.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-GET-ALL-ROLES

   .. oe:method:: HasRole

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

         .. oe:api::

            bool HasRole(const OERole& role) const

      .. oe:language:: python

         .. oe:api:: python

            HasRole(role: OERole) -> bool

      Returns ``true`` if the :oe:cls:`OERoleSet<OESystem::OERoleSet>` contains
      the specified role.

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

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

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

         .. oe:api::

            bool HasRole(const std::string& name) const

      .. oe:language:: python

         .. oe:api:: python

            HasRole(name: str) -> bool

      Convenience method for testing membership with a string.

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

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

   .. oe:method:: NumRoles

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

         .. oe:api::

            unsigned int NumRoles() const

      .. oe:language:: python

         .. oe:api:: python

            NumRoles() -> int

      Returns the current number of :oe:cls:`OERole<OESystem::OERole>` objects
      in this :oe:cls:`OERoleSet<OESystem::OERoleSet>`.
