rymut/mexcppclass

MEX function for wrapping, managing and using C++ resources within MATLAB.
23 Downloads
Updated 10 Aug 2017

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

Compile cppmexclass mex function.
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).
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.

Cite As

Boguslaw Rymut (2024). rymut/mexcppclass (https://github.com/rymut/mexcppclass), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Call C++ from MATLAB in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
1.0.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.