{"id":19129893,"url":"https://github.com/mathworks/libmexclass","last_synced_at":"2025-05-06T00:37:45.624Z","repository":{"id":45427934,"uuid":"513606004","full_name":"mathworks/libmexclass","owner":"mathworks","description":"libmexclass is a MATLAB framework which enables users to implement the functionality of MATLAB classes in terms of equivalent C++ classes using MEX.","archived":false,"fork":false,"pushed_at":"2025-04-04T15:50:27.000Z","size":198,"stargazers_count":7,"open_issues_count":8,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-19T12:42:54.429Z","etag":null,"topics":["cpp","matlab","mex"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-13T17:06:21.000Z","updated_at":"2025-04-06T02:26:57.000Z","dependencies_parsed_at":"2025-04-19T06:38:34.790Z","dependency_job_id":"7da2f331-5c05-480c-8784-103361dbafb3","html_url":"https://github.com/mathworks/libmexclass","commit_stats":{"total_commits":41,"total_committers":9,"mean_commits":4.555555555555555,"dds":0.5609756097560976,"last_synced_commit":"bf16a65f003069917de8217693d78050ee12c49e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Flibmexclass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Flibmexclass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Flibmexclass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Flibmexclass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/libmexclass/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252600653,"owners_count":21774626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","matlab","mex"],"created_at":"2024-11-09T06:08:51.352Z","updated_at":"2025-05-06T00:37:45.604Z","avatar_url":"https://github.com/mathworks.png","language":"C++","readme":"# libmexclass\n\n## DISCLAIMERS\n\n1. **NOTE**: The [MATLAB\u0026reg; Interface to C++](https://www.mathworks.com/help/matlab/build-matlab-interface-to-c-library.html) is the recommended way to interface with C++ classes in MATLAB.\n\n2. **NOTE**: `libmexclass` is **UNDER ACTIVE DEVELOPMENT**. It is **NOT** recommended for production use.\n\n## Overview\n\n`libmexclass` is a MATLAB framework which enables users to implement the functionality of MATLAB classes in terms of equivalent C++ classes using [MEX](https://www.mathworks.com/help/matlab/call-mex-files-1.html).\n\nFor MATLAB\u0026reg; projects that are already using [MEX](https://www.mathworks.com/help/matlab/call-mex-files-1.html), `libmexclass` aims to provide an alternative for interfacing with C++ classes.\n\nIt is recommended to use `libmexclass` with CMake.\n\n## Usage\n\n### Technical Background\n\n`libmexclass` enables client code to:\n\n1. Implement MATLAB class methods in terms of equivalent C++ class methods using a MEX based proxying mechanism\n2. Bound the lifetime of C++ objects to equivalent MATLAB objects\n\n`libmexclass` is heavily inspired by the [Proxy Design Pattern](https://en.wikipedia.org/wiki/Proxy_pattern). Using `libmexclass` involves connecting `mexclass.Proxy` subclasses in MATLAB with corresponding `mexclass::Proxy` subclasses in C++.\n\n### Getting Started\n\nTo use `libmexclass` in a MATLAB project, several steps are required, which are enumerated below.\n\n#### 1. Subclass `mexclass::ProxyFactory` in C++\n\nCreate a subclass of `mexclass::ProxyFactory` in C++ with the name `CustomProxyFactory`.\n\n`mexclass::ProxyFactory` is a [\"simple factory\"](https://en.wikipedia.org/wiki/Factory_(object-oriented_programming)#Terminology). `CustomProxyFactory` is responsible for returning subclasses of `mexclass::Proxy` which wrap \"raw\" C++ objects and control access to their state.\n\n##### Notes\n\n1. Your subclass *MUST* be named `CustomProxyFactory`.\n2. Your filenames *MUST* be named `CustomProxyFactory.hpp` and `CustomProxyFactory.cpp`.\n2. `CustomProxyFactory.hpp` and `CustomProxyFactory.cpp` *MUST* be in the same directory.\n\n##### Examples\n\n1. `example/CustomProxyFactory.hpp` and `example/CustomProxyFactory.cpp` provide an example of how to implement `CustomProxyFactory`.\n\n#### 2. Subclass `mexclass.Proxy` in MATLAB\n\nCreate a subclass of `mexclass.Proxy` in MATLAB whose class name is **identical** to the string used in the `switch` statement inside of your `CustomProxyFactory` implementation.\n\n##### Notes\n\n1. If the names of your corresponding MATLAB and C++ `Proxy` subclasses don't match exactly, then `libmexclass` won't be able to connect them.\n\n##### Examples\n\n1. If you created a custom `mexclass::Proxy` subclass in C++ named `CustomProxy` and used the string `CustomProxy` in the `switch` statement inside of your `CustomProxyFactory` implementation, then the name of your `mexclass.Proxy` subclass in MATLAB *MUST* also be `CustomProxy`.\n\n#### 3. Build and Install using CMake\n\nTo use `libmexclass` in a MATLAB project, use the [`ExternalProject_Add()`](https://cmake.org/cmake/help/latest/module/ExternalProject.html) CMake function.\n\n```cmake\nExternalProject_Add(libmexclass\n                    GIT_REPOSITORY https://github.com/mathworks/libmexclass\n                    CMAKE_ARGS -D CUSTOM_PROXY_FACTORY_DIR=\u003ccustom-proxy-factory-dir\u003e)\n```\n\nIn the CMake code snippet above, replace `\u003ccustom-proxy-factory-dir\u003e` with the location of your implementation of `CustomProxyFactory` relative to the `CMakeLists.txt` file for your project.\n\n## MATLAB Version Compatibility\n\n`libmexclass` is compatible with [MATLAB R2022a](https://www.mathworks.com/products/new_products/latest_features.html) or newer.\n\n## Contributing\n\nWe welcome external contributions! Feel free to open a pull request!\n\nFor more information, see [CONTRIBUTING.md](CONTRIBUTING.md).\n\nCopyright \u0026copy; 2022, The MathWorks, Inc.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Flibmexclass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Flibmexclass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Flibmexclass/lists"}