LCOV - code coverage report
Current view: top level - lunchbox - dso.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 3 3 100.0 %
Date: 2014-08-05 Functions: 14 14 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 <lunchbox/api.h>
      23             : #include <boost/noncopyable.hpp>
      24             : #include <string>
      25             : 
      26             : namespace lunchbox
      27             : {
      28             : namespace detail { class DSO; }
      29             : 
      30             : /**
      31             :  * Helper to access dynamic shared objects (DSO)
      32             :  *
      33             :  * Example: @include tests/dso.cpp
      34             :  */
      35             : class DSO : public boost::noncopyable
      36             : {
      37             : public:
      38             :     /** Construct a new dynamic shared object. @version 1.0 */
      39             :     LUNCHBOX_API DSO();
      40             : 
      41             :     /** Construct and initialize a dynamic shared object. @version 1.7.1 */
      42             :     LUNCHBOX_API explicit DSO( const std::string& name );
      43             : 
      44             :     /** Destruct this DSO handle. @version 1.0 */
      45             :     LUNCHBOX_API ~DSO();
      46             : 
      47             :     /**
      48             :      * Open a dynamic shared object.
      49             :      *
      50             :      * @param fileName The file name of the DSO.
      51             :      * @return true if the DSO was opened, false upon error.
      52             :      * @version 1.0
      53             :      */
      54             :     LUNCHBOX_API bool open( const std::string& fileName );
      55             : 
      56             :     /**
      57             :      * Close the DSO, invalidates retrieved function pointers.
      58             :      * @version 1.0
      59             :      */
      60             :     LUNCHBOX_API void close();
      61             : 
      62             :     /**
      63             :      * @return a function pointer in the DSO, or 0 if the function is not
      64             :      *         exported by the DSO.
      65             :      * @version 1.0
      66             :      */
      67             :     LUNCHBOX_API
      68             :     void* getFunctionPointer( const std::string& functionName ) const;
      69             : 
      70             :     /**
      71             :      * @return a typed function pointer in the DSO, or 0 if the function is
      72             :      *         not exported by the DSO.
      73             :      * @version 1.7.1
      74             :      */
      75          15 :     template< class F > F getFunctionPointer( const std::string& func ) const
      76          15 :         { return (F)(getFunctionPointer( func )); }
      77             : 
      78             :     /** @return true if the DSO is loaded. @version 1.0 */
      79             :     LUNCHBOX_API bool isOpen() const;
      80             : 
      81             :     /**
      82             :      * @return true if both instances manage the same shared object.
      83             :      * @version 1.9.1
      84             :      */
      85             :     LUNCHBOX_API bool operator == ( const DSO& rhs ) const;
      86             : 
      87             :     /**
      88             :      * @return true if both instances manage different shared objects.
      89             :      * @version 1.9.1
      90             :      */
      91           5 :     bool operator != ( const DSO& rhs ) const { return !( *this == rhs ); }
      92             : 
      93             : private:
      94             :     detail::DSO* const _impl;
      95             : };
      96             : 
      97             : }
      98             : 
      99             : #endif //LUNCHBOX_DSO_H

Generated by: LCOV version 1.10