Skip to content

MEX function and a library for wrapping, managing and using C++ resources objects, function and classes within MATLAB.

License

Notifications You must be signed in to change notification settings

rymut/mexcppclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mexcppclass

MEX function and a library for wrapping, managing and using C++ resources objects, function and classes within MATLAB.

Usage

  1. Compile cppmexclass mex function.
  2. Create resource wrapper and export create/destory functions.
    Wrapper and functions can reside inside mexcppclass mex function or can
    reside inside a shared library:
    • wrapper for C++ resource which implements mexcppclass::ModuleInterface,
    • write and export functions for creating wrapper instance
      void Destroy<ClassName>ModuleInterface(mexcppclass::ModuleInterface *obj)
      and destroying wrapper instance
      void Destroy<ClassName>ModuleInterface(mexcppclass::ModuleInterface *obj).
  3. Put created .(dll|so) library and mexcppclass mex
    in the same directory. Object can be accessed by Matlab by use of commands:
% Create wrapper handle
handle = mexcppclass('create', 'ClassName=LibraryName.so')
% Create object constructor
mexcppclass('call', handle, 'create');
% Call simple methods
mexcppclass('call', handle, 'setvalue', 10);
v = mexcppclass('call', handle, 'getvalue');
% destroy object and wrapper
mexcppclass('destroy', handle);

Example

See test/unit/testmodule.hpp and test/unit/testmodule.cpp for as a reference
point.

Alternative solutions/projects/examples

About

MEX function and a library for wrapping, managing and using C++ resources objects, function and classes within MATLAB.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published