GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add project sources · rymut/mexcppclass@a6a1873

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • CMakeLists.txt
  • README.md
  • VERSION
  • cmake
    • MexcppclassConfig.cmake.in
    • copy_to_target_path.cmake
    • enviroment
      • script.cmake
    • git_revision.cmake
    • version.cmake
    • version.h.in
  • include/mexcppclass
    • core
      • main.hpp
    • exportstl.hpp
    • instanceid.hpp
    • instancemanagerinterface.hpp
    • instancepointerinterface.hpp
    • matlab
      • ans.hpp
      • arg.hpp
      • argument.hpp
      • argumentvalidatorinterface.hpp
      • argumentvalidatorinterfacememory.hpp
      • array.hpp
      • cell.hpp
      • classid.hpp
      • classidargumentvalidator.hpp
      • countargumentvalidator.hpp
      • dimensioncountargumentvalidator.hpp
      • dimensionscountargumentvalidator.hpp
      • existargumentvalidator.hpp
      • existsargumentvalidator.hpp
      • matlab.hpp
      • memory.hpp
      • message.hpp
      • messagedeque.hpp
      • msgid.hpp
      • msglevel.hpp
      • msgtext.hpp
      • numeric.hpp
      • string.hpp
    • messagedequeinterface.hpp
    • mexcppclass.hpp
    • moduleid.hpp
    • moduleinterface.hpp
    • moduleinterfacefunctionpointer.hpp
    • modulemanagerinterface.hpp
    • nonpersistentdatainterface.hpp
    • persistentdatainterface.hpp
    • pointermodule.hpp
    • unused.hpp
    • utility
      • map.hpp
      • string.hpp
      • utility.hpp
      • version.hpp
  • source
    • CMakeLists.txt
    • core
      • CMakeLists.txt
      • instancemanager.cpp
      • instancemanager.hpp
      • instancepointer.cpp
      • instancepointer.hpp
      • instancepointerinterface.cpp
      • main.cpp
      • modulemanager.cpp
      • modulemanager.hpp
      • nonpersistentdata.cpp
      • nonpersistentdata.hpp
      • persistentdata.cpp
      • persistentdata.hpp
      • program.cpp
      • program.hpp
    • matlab
      • CMakeLists.txt
      • ans.cpp
      • arg.cpp
      • array.cpp
      • classidargumentvalidator.cpp
      • countargumentvalidator.cpp
      • dimensioncountargumentvalidator.cpp
      • dimensionscountargumentvalidator.cpp
      • existargumentvalidator.cpp
      • existsargumentvalidator.cpp
      • message.cpp
      • messagedeque.cpp
      • msgtext.cpp
      • numeric.cpp
      • string.cpp
    • mexcppclass.cpp
    • mexcppclass.m
    • utility
      • CMakeLists.txt
      • string.cpp
      • version.cpp
  • test
    • CMakeLists.txt
    • test.hpp
    • unit
      • BaseUnitTest.m
      • CMakeLists.txt
      • CommandCommandsUnitTest.m
      • CommandLibpathUnitTest.m
      • CommandVersionUnitTest.m
      • GeneralUnitTest.m
      • run_unit_test.m
      • setup_unit_test_properties.m.in
      • test.cpp
      • test.hpp
      • testmodule.cpp
      • testmodule.hpp
      • testmodulemethod.hpp
      • unit.hpp

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CMakeLists.txt‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3+
set(CMAKE_DEBUG_POSTFIX d)
4+
5+
set(CMAKE_MODULE_PATH
6+
${CMAKE_MODULE_PATH}
7+
${CMAKE_CURRENT_SOURCE_DIR}/cmake
8+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
9+
)
10+
include(version)
11+
version_configure("${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VER VER_BUILD)
12+
13+
14+
project(mexcppclass VERSION ${VER})
15+
enable_testing()
16+
17+
version_make_file(${PROJECT_BINARY_DIR}/source/utility/version.h)
18+
19+
option(ENABLE_MEXCPPCLASS_CMAKE_ENV_SCRIPT_FILE
20+
"Enable cmake enviroment variable file to config enviroment"
21+
ON
22+
)
23+
24+
set(MEXCPPCLASS_CMAKE_ENV_SCRIPT_FILE
25+
"${CMAKE_SOURCE_DIR}/cmake/enviroment/script.cmake"
26+
CACHE STRING "aaa CMAKE enviroment variable file to config"
27+
)
28+
29+
# Load enviroment variables
30+
if(ENABLE_MEXCPPCLASS_CMAKE_ENV_SCRIPT_FILE)
31+
include(${MEXCPPCLASS_CMAKE_ENV_SCRIPT_FILE})
32+
endif()
33+
34+
# Find OpenGL libraries
35+
find_package(Matlab "9.1" OPTIONAL_COMPONENTS MX_LIBRARY REQUIRED)
36+
add_subdirectory(source)
37+
add_subdirectory(test "test")
Collapse file

‎README.md‎

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
11
# mexcppclass
2+
3+
MEX function and a library for wrapping, managing and using C++ resources
4+
objects, function and classes within MATLAB.
5+
6+
## Usage
7+
8+
1. Compile **cppmexclass** mex function.
9+
2. Create resource wrapper and export create/destory functions.
10+
Wrapper and functions can reside inside **mexcppclass** mex function or can
11+
reside inside a shared library:
12+
* wrapper for <ClassName> C++ resource which implements
13+
`mexcppclass::ModuleInterface`,
14+
* write and export functions for creating wrapper instance
15+
`void
16+
Destroy<ClassName>ModuleInterface(mexcppclass::ModuleInterface *obj)`
17+
and destroying wrapper instance
18+
`void
19+
Destroy<ClassName>ModuleInterface(mexcppclass::ModuleInterface *obj)`.
20+
3. Put created <LibraryName>.(dll|so) library and **mexcppclass** mex
21+
in the same directory. Object can be accessed by Matlab by use of commands:
22+
```
23+
% Create wrapper handle
24+
handle = mexcppclass('create', 'ClassName=LibraryName.so')
25+
% Create object constructor
26+
mexcppclass('call', handle, 'create');
27+
% Call simple methods
28+
mexcppclass('call', handle, 'setvalue', 10);
29+
v = mexcppclass('call', handle, 'getvalue');
30+
% destroy object and wrapper
31+
mexcppclass('destroy', handle);
32+
```
33+
34+
## Example
35+
36+
See test/unit/testmodule.hpp and test/unit/testmodule.cpp for as a reference
37+
point.
38+
39+
## Alternative solutions/projects/examples
40+
41+
* [https://github.com/chappjc/MATLAB.git](https://github.com/chappjc/MATLAB.git)
42+
* [http://www.ee.columbia.edu/~mim/meap/paMat/mexhandle/](https://github.com/chappjc/MATLAB.git)
Collapse file

‎VERSION‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MAJOR 0
2+
MINOR 1
3+
PATCH 0
4+
TWEAK 0
5+
BUILD
Collapse file

‎cmake/MexcppclassConfig.cmake.in‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
set_and_check(@target_NAME@_INCLUDE_DIRS "@PACKAGE_@target_NAME@_INCLUDE_DIRS@")
4+
5+
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Collapse file

‎cmake/copy_to_target_path.cmake‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function(COPY_TO_TARGET_PATH TARGET_NAME FILE_DIR FILE_NAME)
2+
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
3+
COMMAND "${CMAKE_COMMAND}" -E copy
4+
"${FILE_DIR}/${FILE_NAME}"
5+
"$<TARGET_FILE_DIR:${TARGET_NAME}>/${FILE_NAME}"
6+
COMMENT "Copying to ${TARGET_NAME} directory")
7+
endfunction(COPY_TO_TARGET_PATH)
Collapse file

‎cmake/enviroment/script.cmake‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SET ( libs_path $ENV{LIBRARY_PATH})
2+
get_filename_component(env_scripts_path ${CMAKE_CURRENT_LIST_FILE} DIRECTORY)
3+
file(GLOB env_scripts "${env_scripts_path}/env_*.cmake")
4+
if (env_scripts)
5+
foreach(env_script ${env_scripts})
6+
include(${env_script})
7+
foreach()
8+
endif()
9+
unset(libs_path)
10+
unset(env_script)
11+
unset(env_scripts_path)
Collapse file

‎cmake/git_revision.cmake‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
find_package(Git)
2+
3+
if(GIT_FOUND)
4+
execute_process(
5+
COMMAND ${GIT_EXECUTABLE} rev-list --max-count=1 HEAD
6+
OUTPUT_VARIABLE GIT_REVISION
7+
ERROR_QUIET
8+
)
9+
if(NOT ${GIT_REVISION} STREQUAL "")
10+
string(STRIP ${GIT_REVISION} GIT_REVISION)
11+
endif()
12+
message(STATUS "Current git revision is ${GIT_REVISION}")
13+
else()
14+
set(GIT_REVISION "unknown")
15+
endif()
Collapse file

‎cmake/version.cmake‎

Copy file name to clipboard
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
set(FILE_VERSION_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR})
2+
3+
function(version_configure FILE_PATH VERSION_RESULT BUILD_RESULT)
4+
if(EXISTS "${FILE_PATH}")
5+
file(STRINGS ${FILE_PATH} FILE_STRINGS)
6+
endif()
7+
set(VERSION_MAJOR 0)
8+
set(VERSION_MINOR 0)
9+
set(VERSION_PATCH 0)
10+
set(VERSION_TWEAK 0)
11+
foreach(FILE_STRING ${FILE_STRINGS})
12+
string(REPLACE " " ";" STRING_LIST ${FILE_STRING})
13+
list(LENGTH STRING_LIST len)
14+
if (${len} GREATER 1)
15+
list(GET STRING_LIST 0 VAR_NAME)
16+
list(GET STRING_LIST 1 VAR_VALUE)
17+
if ((NOT VAR_VALUE MATCHES "^[0-9]+$") AND
18+
(NOT VAR_NAME STREQUAL "BUILD"))
19+
set(VAR_VALUE "0")
20+
endif()
21+
set(VERSION_${VAR_NAME} ${VAR_VALUE})
22+
endif()
23+
endforeach()
24+
25+
set(VERSION_NAME "")
26+
if (VERSION_TWEAK GREATER 0)
27+
set(VERSION_NAME ".${VERSION_TWEAK}")
28+
endif()
29+
if ((VERSION_PATCH GREATER 0) OR
30+
(VERSION_NAME))
31+
set(VERSION_NAME ".${VERSION_PATCH}${VERSION_NAME}")
32+
endif()
33+
if ((VERSION_MINOR GREATER 0) OR
34+
(VERSION_NAME))
35+
set(VERSION_NAME ".${VERSION_MINOR}${VERSION_NAME}")
36+
endif()
37+
if ((VERSION_MAJOR GREATER 0) OR
38+
(VERSION_NAME))
39+
set(VERSION_NAME "${VERSION_MAJOR}${VERSION_NAME}")
40+
endif()
41+
set(${VERSION_RESULT} ${VERSION_NAME} PARENT_SCOPE)
42+
set(${BUILD_RESULT} ${VERSION_BUILD} PARENT_SCOPE)
43+
endfunction(version_configure)
44+
45+
macro(version_make_file FILE_PATH)
46+
set(RELATIVE_PATH ${FILE_PATH})
47+
string(REPLACE "${PROJECT_BINARY_DIR}/" "" RELATIVE_PATH "${RELATIVE_PATH}")
48+
string(REGEX REPLACE "^src/" "" RELATIVE_PATH "${RELATIVE_PATH}")
49+
string(REGEX REPLACE "^srcs/" "" RELATIVE_PATH "${RELATIVE_PATH}")
50+
string(REGEX REPLACE "^source/" "" RELATIVE_PATH "${RELATIVE_PATH}")
51+
string(REGEX REPLACE "^sources/" "" RELATIVE_PATH "${RELATIVE_PATH}")
52+
string(REGEX REPLACE "^include/" "" RELATIVE_PATH "${RELATIVE_PATH}")
53+
string(REGEX REPLACE "^${PROJECT_NAME}/" "" RELATIVE_PATH "${RELATIVE_PATH}")
54+
string(TOUPPER "${RELATIVE_PATH}" RELATIVE_PATH)
55+
string(REGEX REPLACE "[^0-9a-zA-Z]" "_" RELATIVE_PATH "${RELATIVE_PATH}")
56+
string(TOUPPER "${PROJECT_NAME}" PROJECT_UPPER)
57+
configure_file(
58+
"${FILE_VERSION_CMAKE_PATH}/version.h.in"
59+
"${FILE_PATH}"
60+
)
61+
unset(PROJECT_UPPER)
62+
unset(RELATIVE_PATH)
63+
endmacro(version_make_file)
Collapse file

‎cmake/version.h.in‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef @PROJECT_UPPER@_@RELATIVE_PATH@_
2+
#define @PROJECT_UPPER@_@RELATIVE_PATH@_
3+
4+
#define VERSION_MAJOR "@PROJECT_VERSION_MAJOR@"
5+
#define VERSION_MINOR "@PROJECT_VERSION_MINOR@"
6+
#define VERSION_PATCH "@PROJECT_VERSION_PATCH@"
7+
#define VERSION_TWEAK "@PROJECT_VERSION_TWEAK@"
8+
9+
#endif // @PROJECT_UPPER@_@RELATIVE_PATH@_
Collapse file

‎include/mexcppclass/core/main.hpp‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// Copyright (C) 2017 by Boguslaw Rymut
2+
///
3+
/// This file is distributed under the Apache 2.0 License
4+
/// See LICENSE for details.
5+
6+
#ifndef MEXCPPCLASS_CORE_MAIN_HPP_
7+
#define MEXCPPCLASS_CORE_MAIN_HPP_
8+
9+
#include <mex.h>
10+
11+
namespace mexcppclass {
12+
13+
/*! \brief Mex entry point
14+
* Arguments are 'class_name', 'action', action arguments
15+
*
16+
* Return class names without any parameters - not possible
17+
* without getting proc addresses.
18+
* Return method names with single argument if class exists.
19+
* Return object or call method when two arguments are passed.
20+
*
21+
* \param nlhs - number of left hand side parameters
22+
* \param plhs - left hand side parameters
23+
* \param nrhs - number of right hand side parameters
24+
* \param mxArray - right hand size arguments
25+
*/
26+
void MexFunction(const int &nrhs, const mxArray *prhs[],
27+
const int &nlhs, mxArray *plhs[]);
28+
29+
} // namespace mexcppclass
30+
31+
#endif // MEXCPPCLASS_CORE_MAIN_HPP_

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.