LCOV - code coverage report
Current view: top level - lunchbox - dso.h (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 1 1 100.0 %
Date: 2018-10-03 05:33:11 Functions: 1 1 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009, Cedric Stalder <cedric.stalder@gmail.com>
       3             :  *               2009-2014, Stefan Eilemann <eile@equalizergraphics.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef LUNCHBOX_DSO_H
      20             : #define LUNCHBOX_DSO_H
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <lunchbox/api.h>
      24             : #include <string>
      25             : 
      26             : namespace lunchbox
      27             : {
      28             : namespace detail
      29             : {
      30             : class DSO;
      31             : }
      32             : 
      33             : /**
      34             :  * Helper to access dynamic shared objects (DSO)
      35             :  *
      36             :  * Example: @include tests/dso.cpp
      37             :  */
      38             : class DSO : public boost::noncopyable
      39             : {
      40             : public:
      41             :     /** Construct a new dynamic shared object. @version 1.0 */
      42             :     LUNCHBOX_API DSO();
      43             : 
      44             :     /** Construct and initialize a dynamic shared object. @version 1.7.1 */
      45             :     LUNCHBOX_API explicit DSO(const std::string& name);
      46             : 
      47             :     /** Destruct this DSO handle. @version 1.0 */
      48             :     LUNCHBOX_API ~DSO();
      49             : 
      50             :     /**
      51             :      * Open a dynamic shared object.
      52             :      *
      53             :      * @param fileName The file name of the DSO.
      54             :      * @return true if the DSO was opened, false upon error.
      55             :      * @version 1.0
      56             :      */
      57             :     LUNCHBOX_API bool open(const std::string& fileName);
      58             : 
      59             :     /**
      60             :      * Close the DSO, invalidates retrieved function pointers.
      61             :      * @version 1.0
      62             :      */
      63             :     LUNCHBOX_API void close();
      64             : 
      65             :     /**
      66             :      * @return a function pointer in the DSO, or 0 if the function is not
      67             :      *         exported by the DSO.
      68             :      * @version 1.0
      69             :      */
      70             :     LUNCHBOX_API
      71             :     void* getFunctionPointer(const std::string& functionName) const;
      72             : 
      73             :     /**
      74             :      * @return a typed function pointer in the DSO, or 0 if the function is
      75             :      *         not exported by the DSO.
      76             :      * @version 1.7.1
      77             :      */
      78             :     template <class F>
      79             :     F getFunctionPointer(const std::string& func) const
      80             :     {
      81             :         return (F)(getFunctionPointer(func));
      82             :     }
      83             : 
      84             :     /** @return true if the DSO is loaded. @version 1.0 */
      85             :     LUNCHBOX_API bool isOpen() const;
      86             : 
      87             :     /**
      88             :      * @return true if both instances manage the same shared object.
      89             :      * @version 1.9.1
      90             :      */
      91             :     LUNCHBOX_API bool operator==(const DSO& rhs) const;
      92             : 
      93             :     /**
      94             :      * @return true if both instances manage different shared objects.
      95             :      * @version 1.9.1
      96             :      */
      97           5 :     bool operator!=(const DSO& rhs) const { return !(*this == rhs); }
      98             : private:
      99             :     detail::DSO* const _impl;
     100             : };
     101             : }
     102             : 
     103             : #endif // LUNCHBOX_DSO_H

Generated by: LCOV version 1.11