.. oe:namespace:: OEChem



.. meta::
   :keywords: oemolthreadbase, molthreadbase


.. _OEChem_oemolthreadbase:

.. oe:class:: oemolthreadbase

   .. seealso::

      The :ref:`section_inputandoutputthreads` section. 

   .. warning::

      The interface provided here is for advanced users. Most users
      should be able to accomplish their goals through the high-level
      :oe:func:`OEChem::OEReadMolecule` and
      :oe:func:`OEChem::OEWriteMolecule` functions.

   .. oe:api::

      class oemolthreadbase : public oemolstreambase


   The following methods are publicly inherited from :ref:`oemolstreambase <OEChem_oemolstreambase>`:

   ========================================================================== ========================================================================= =========================================================================
   :oe:meth:`ClearCSVHeader<OEChem::oemolstreambase::ClearCSVHeader>`         :oe:meth:`GetFlavor<OEChem::oemolstreambase::GetFlavor>`                  :oe:meth:`SetFormat<OEChem::oemolstreambase::SetFormat>`                 
   :oe:meth:`GetBinaryIOHandler<OEChem::oemolstreambase::GetBinaryIOHandler>` :oe:meth:`GetFormat<OEChem::oemolstreambase::GetFormat>`                  :oe:meth:`close<OEChem::oemolstreambase::close>`                         
   :oe:meth:`GetCSVHeader<OEChem::oemolstreambase::GetCSVHeader>`             :oe:meth:`Getgz<OEChem::oemolstreambase::Getgz>`                          :oe:meth:`open<OEChem::oemolstreambase::open>`                           
   :oe:meth:`GetFileName<OEChem::oemolstreambase::GetFileName>`               :oe:meth:`SetFlavor<OEChem::oemolstreambase::SetFlavor>`                                                                                           
   ========================================================================== ========================================================================= =========================================================================

   The following classes derive from this class:
    * :ref:`oemolithread <OEChem_oemolithread>`
    * :ref:`oemolothread <OEChem_oemolothread>`
   

   .. oe:method:: operator bool

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

         .. oe:api::

            operator bool() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

   .. oe:method:: GetMol

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

         .. oe:api::

            const std::string* GetMol()

      .. oe:language:: python

         .. oe:api:: python

            GetMol() -> bytes

      Retrieve the next molecule in the stream as a ``std::string``
      blocking if there are no molecules currently available. The
      method will return a zero-pointer (``NULL``) if there are no
      more molecules left to retrieve.

      The user is expected to call ``delete`` on the ``std::string``
      pointer returned from this method.

      .. note:: 

         This method was specifically designed to be thread safe so
         multiple threads can call this method on the same
         :ref:`oemolthreadbase <OEChem_oemolthreadbase>` object simultaneously.

   .. oe:method:: PeekMol

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

         .. oe:api::

            const std::string* PeekMol()

      .. oe:language:: python

         .. oe:api:: python

            PeekMol() -> bytes


      Return the next molecule ``std::string`` pointer that will be
      returned by :oe:meth:`OEChem::oemolthreadbase::GetMol` method. 

      .. note::
         
         If multiple threads are calling
         :oe:meth:`OEChem::oemolthreadbase::GetMol` and
         :oe:meth:`OEChem::oemolthreadbase::PeekMol` then it can not be
         guaranteed that the thread that called
         :oe:meth:`OEChem::oemolthreadbase::PeekMol` will get the same
         pointer when it later calls
         :oe:meth:`OEChem::oemolthreadbase::GetMol`.
      
   .. oe:method:: PutMol

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

         .. oe:api::

            bool PutMol(const std::string* data)

      .. oe:language:: python

         .. oe:api:: python

            PutMol(data: bytes) -> bool

      Place a molecule as a ``std::string`` into the stream blocking
      if the in-memory buffer is full.

      In the case of the :ref:`oemolothread <OEChem_oemolothread>` object the
      output thread will call ``delete`` on the pointer to free the
      memory. Passing a zero-pointer (``NULL``) will instruct the
      :ref:`oemolothread <OEChem_oemolothread>` output thread to shut down.

      .. note:: 

         This method was specifically designed to be thread safe so
         multiple threads can call this method on the same
         :ref:`oemolthreadbase <OEChem_oemolthreadbase>` object simultaneously.
