Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class shared_library

boost::extensions::shared_library — A wrapper around OS-specific shared library functions.

Synopsis

class shared_library {
public:
  // construct/copy/destruct
  shared_library(const std::string &, bool = false);
  ~shared_library();

  // public member functions
  bool is_open() const;
  bool open() ;
  bool close() ;
  template<typename TypeInfo> bool call(basic_type_map< TypeInfo > &) ;
  template<typename RetValue, typename Params...> 
    FunctionPtr< ReturnValue(Params...)> get(const std::string &) const;
};

Description

shared_library public construct/copy/destruct

  1. shared_library(const std::string & location, bool auto_close = false);

    shared_library constructor

    Parameters:
    auto_close

    An optional parameter which defaults to false. If set to true, the destructor will close this shared library if necessary.

    location

    The relative or absolute path of the shared library.

  2. ~shared_library();

    shared_library destructor If auto_close_ was set to true in the constructor, this closes the library if it is currently open.

shared_library public member functions

  1. bool is_open() const;

    Requires:

    None.

    Postconditions:

    None.

    Returns:

    true if the shared library is currently open and referenced by this object.

  2. bool open() ;

    Requires:

    None.

    Postconditions:

    If true is returned, the shared library is opened and get() can be called.

    Returns:

    true if the shared library was opened successfully.

  3. bool close() ;

    Requires:

    is_open() == true.

    Postconditions:

    is_open() == false.

    Returns:

    true if the close function was successful.

  4. template<typename TypeInfo> bool call(basic_type_map< TypeInfo > & types) ;

    There is a special function called boost_extension_exported_type_map_function which is commonly used by shared libraries. The call function attempts to find and call that function, given a type_map.

    Parameters:
    types

    A type_map that will be sent to the function.

    Requires:

    is_open() == true

    Postconditions:

    None.

    Returns:

    true on success.

  5. template<typename RetValue, typename Params...> 
      FunctionPtr< ReturnValue(Params...)> get(const std::string & name) const;

    A templated function taking as template arguments the type of the return value and parameters of a function to look up in the shared library.

    This function must have been declared with the same parameters and return type and marked as extern "C".

    Depending on platform and compiler settings, it may also be necessary to prefix the function with BOOST_EXTENSION_DECL, to make it externally visible.

    If the function signature does not match, strange errors can occur.

    Requires:

    is_open() == true.

    Postconditions:

    None.


PrevUpHomeNext