Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VAMatlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VAMatlab
Commits
3614834f
Commit
3614834f
authored
Apr 25, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning and renaming function maps
parent
74620282
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
173 additions
and
0 deletions
+173
-0
src/VAMatlabFunctionMapping.h
src/VAMatlabFunctionMapping.h
+173
-0
No files found.
src/
FunctionMappings
.h
→
src/
VAMatlabFunctionMapping
.h
View file @
3614834f
/*
/*
* --------------------------------------------------------------------------------------------
*
*
* VVV VVV A
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Virtual Acoustics
(VA)
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut
fr Technische Akustik (ITA)
* VVVVVV AAA (c) Copyright Institut
e of Technical Acoustics (ITA), 2015-2017
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
* VVVV AAA RWTH Aachen
University
(http://www.akustik.rwth-aachen.de)
*
*
* ---------------------------------------------------------------------------------
* --------------------------------------------------------------------------------------------
*
* File: FunctionMappings.h
*
* Purpose: Reflexion mechanisms for the Matlab extension functions
*
* Authors: Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*/
*/
// $Id: $
#ifndef
__FUNCTIONMAPPINGS_H__
#ifndef
IW_FUNCTION_MAPPINGS
#define
__FUNCTIONMAPPINGS_H__
#define
IW_FUNCTION_MAPPINGS
#include <assert.h>
#include <assert.h>
#include <algorithm>
#include <algorithm>
...
@@ -31,19 +22,20 @@
...
@@ -31,19 +22,20 @@
#include <mex.h>
#include <mex.h>
typedef
void
(
CommandFunction
)(
int
,
mxArray
**
,
int
,
const
mxArray
**
);
typedef
void
(
CommandFunction
)(
int
,
mxArray
**
,
int
,
const
mxArray
**
);
class
FunctionMapping
;
class
FunctionMapping
;
void
AddFunctionMapping
(
FunctionMapping
*
pFuncMapping
);
void
AddFunctionMapping
(
FunctionMapping
*
pFuncMapping
);
class
FunctionInputArgument
;
class
FunctionInputArgument
;
void
AddFunctionInputArgument
(
const
std
::
string
&
sFuncName
,
FunctionInputArgument
*
pArg
);
void
AddFunctionInputArgument
(
const
std
::
string
&
sFuncName
,
FunctionInputArgument
*
pArg
);
class
FunctionOutputArgument
;
class
FunctionOutputArgument
;
void
AddFunctionOutputArgument
(
const
std
::
string
&
sFuncName
,
FunctionOutputArgument
*
pArg
);
void
AddFunctionOutputArgument
(
const
std
::
string
&
sFuncName
,
FunctionOutputArgument
*
pArg
);
class
FunctionInputArgument
{
class
FunctionInputArgument
{
public:
public:
std
::
string
sName
;
std
::
string
sName
;
std
::
string
sType
;
std
::
string
sType
;
...
@@ -51,94 +43,87 @@ public:
...
@@ -51,94 +43,87 @@ public:
bool
bOptional
;
bool
bOptional
;
std
::
string
sDefaultValue
;
// Default value expression in Matlab
std
::
string
sDefaultValue
;
// Default value expression in Matlab
FunctionInputArgument
(
const
std
::
string
&
sFunctionName
,
inline
FunctionInputArgument
(
const
std
::
string
&
sFunctionName
,
const
std
::
string
&
sArgName
,
const
std
::
string
&
sArgType
,
const
std
::
string
&
sArgDesc
,
bool
bArgOptional
,
const
std
::
string
&
sArgDefaultValue
)
const
std
::
string
&
sArgName
,
:
sName
(
sArgName
)
const
std
::
string
&
sArgType
,
,
sType
(
sArgType
)
const
std
::
string
&
sArgDesc
,
,
sDesc
(
sArgDesc
)
bool
bArgOptional
,
,
bOptional
(
bArgOptional
)
const
std
::
string
&
sArgDefaultValue
)
,
sDefaultValue
(
sArgDefaultValue
)
:
sName
(
sArgName
),
sType
(
sArgType
),
sDesc
(
sArgDesc
),
bOptional
(
bArgOptional
),
sDefaultValue
(
sArgDefaultValue
)
{
{
// Self register the argument globally
// Self register the argument globally
AddFunctionInputArgument
(
sFunctionName
,
this
);
AddFunctionInputArgument
(
sFunctionName
,
this
);
}
}
;
};
};
class
FunctionOutputArgument
{
class
FunctionOutputArgument
{
public:
public:
std
::
string
sName
;
std
::
string
sName
;
std
::
string
sType
;
std
::
string
sType
;
std
::
string
sDesc
;
std
::
string
sDesc
;
FunctionOutputArgument
(
const
std
::
string
&
sFunctionName
,
inline
FunctionOutputArgument
(
const
std
::
string
&
sFunctionName
,
const
std
::
string
&
sArgName
,
const
std
::
string
&
sArgType
,
const
std
::
string
&
sArgDesc
)
const
std
::
string
&
sArgName
,
:
sName
(
sArgName
)
const
std
::
string
&
sArgType
,
,
sType
(
sArgType
)
const
std
::
string
&
sArgDesc
)
,
sDesc
(
sArgDesc
)
:
sName
(
sArgName
),
sType
(
sArgType
),
sDesc
(
sArgDesc
)
{
{
// Self register the argument globally
// Self register the argument globally
AddFunctionOutputArgument
(
sFunctionName
,
this
);
AddFunctionOutputArgument
(
sFunctionName
,
this
);
}
}
;
};
};
class
FunctionMapping
{
class
FunctionMapping
{
public:
public:
std
::
string
sName
;
std
::
string
sName
;
CommandFunction
*
pAddr
;
CommandFunction
*
pAddr
;
bool
bPublic
;
bool
bPublic
;
std
::
string
sDesc
;
std
::
string
sDesc
;
std
::
string
sDoc
;
std
::
string
sDoc
;
std
::
vector
<
FunctionInputArgument
>
vInputArgs
;
std
::
vector
<
FunctionInputArgument
>
vInputArgs
;
std
::
vector
<
FunctionOutputArgument
>
vOutputArgs
;
std
::
vector
<
FunctionOutputArgument
>
vOutputArgs
;
FunctionMapping
(
const
std
::
string
&
sFunctionName
,
FunctionMapping
(
const
std
::
string
&
sFunctionName
,
CommandFunction
*
pFunctionAddr
,
bool
bPublicFunc
,
const
std
::
string
&
sFunctionDesc
,
const
std
::
string
&
sFunctionDoc
)
CommandFunction
*
pFunctionAddr
,
:
sName
(
sFunctionName
)
bool
bPublicFunc
,
,
pAddr
(
pFunctionAddr
)
const
std
::
string
&
sFunctionDesc
,
,
bPublic
(
bPublicFunc
)
const
std
::
string
&
sFunctionDoc
)
,
sDesc
(
sFunctionDesc
)
:
sName
(
sFunctionName
),
pAddr
(
pFunctionAddr
),
bPublic
(
bPublicFunc
),
sDesc
(
sFunctionDesc
)
{
{
// Self register the function globally
// Self register the function globally
AddFunctionMapping
(
this
);
AddFunctionMapping
(
this
);
}
}
;
};
};
// Function list (map used for O(log N) lookups via function name)
// Function list (map used for O(log N) lookups via function name)
typedef
std
::
map
<
std
::
string
,
FunctionMapping
>::
iterator
FunctionMapIterator
;
typedef
std
::
map
<
std
::
string
,
FunctionMapping
>::
iterator
FunctionMapIterator
;
std
::
map
<
std
::
string
,
FunctionMapping
>
g_mFunctionMap
;
std
::
map
<
std
::
string
,
FunctionMapping
>
g_mFunctionMap
;
void
AddFunctionMapping
(
FunctionMapping
*
pFuncMapping
)
{
void
AddFunctionMapping
(
FunctionMapping
*
pFuncMapping
)
std
::
string
sUpperName
(
pFuncMapping
->
sName
);
{
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
std
::
string
sUpperName
(
pFuncMapping
->
sName
);
g_mFunctionMap
.
insert
(
std
::
pair
<
std
::
string
,
FunctionMapping
>
(
sUpperName
,
*
pFuncMapping
));
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
}
g_mFunctionMap
.
insert
(
std
::
pair
<
std
::
string
,
FunctionMapping
>
(
sUpperName
,
*
pFuncMapping
)
);
};
void
AddFunctionInputArgument
(
const
std
::
string
&
sFuncName
,
FunctionInputArgument
*
pArg
)
{
void
AddFunctionInputArgument
(
const
std
::
string
&
sFuncName
,
FunctionInputArgument
*
pArg
)
std
::
string
sUpperName
(
sFuncName
);
{
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
std
::
string
sUpperName
(
sFuncName
);
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
FunctionMapIterator
it
=
g_mFunctionMap
.
find
(
sUpperName
);
FunctionMapIterator
it
=
g_mFunctionMap
.
find
(
sUpperName
);
assert
(
it
!=
g_mFunctionMap
.
end
()
);
assert
(
it
!=
g_mFunctionMap
.
end
()
);
it
->
second
.
vInputArgs
.
push_back
(
*
pArg
);
it
->
second
.
vInputArgs
.
push_back
(
*
pArg
);
}
}
;
void
AddFunctionOutputArgument
(
const
std
::
string
&
sFuncName
,
FunctionOutputArgument
*
pArg
)
{
inline
void
AddFunctionOutputArgument
(
const
std
::
string
&
sFuncName
,
FunctionOutputArgument
*
pArg
)
std
::
string
sUpperName
(
sFuncName
);
{
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
std
::
string
sUpperName
(
sFuncName
);
std
::
transform
(
sUpperName
.
begin
(),
sUpperName
.
end
(),
sUpperName
.
begin
(),
toupper
);
FunctionMapIterator
it
=
g_mFunctionMap
.
find
(
sUpperName
);
FunctionMapIterator
it
=
g_mFunctionMap
.
find
(
sUpperName
);
assert
(
it
!=
g_mFunctionMap
.
end
()
);
assert
(
it
!=
g_mFunctionMap
.
end
()
);
it
->
second
.
vOutputArgs
.
push_back
(
*
pArg
);
it
->
second
.
vOutputArgs
.
push_back
(
*
pArg
);
}
}
;
// INFO: Forward declare the function first. Allows to put documentation above the function body...
// INFO: Forward declare the function first. Allows to put documentation above the function body...
#define REGISTER_PUBLIC_FUNCTION(NAME, DESC, DOC) void NAME(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);\
#define REGISTER_PUBLIC_FUNCTION(NAME, DESC, DOC) void NAME(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);\
...
@@ -153,34 +138,36 @@ FunctionMapping g_oFuncMapping_##NAME(#NAME, &NAME, false, "", "")
...
@@ -153,34 +138,36 @@ FunctionMapping g_oFuncMapping_##NAME(#NAME, &NAME, false, "", "")
#define DECLARE_FUNCTION_OUTARG(FUNCNAME, ARGNAME, ARGTYPE, ARGDESC) FunctionOutputArgument g_oFuncOutArg_##FUNCNAME##_##ARGNAME##(#FUNCNAME, #ARGNAME, ARGTYPE, ARGDESC)
#define DECLARE_FUNCTION_OUTARG(FUNCNAME, ARGNAME, ARGTYPE, ARGDESC) FunctionOutputArgument g_oFuncOutArg_##FUNCNAME##_##ARGNAME##(#FUNCNAME, #ARGNAME, ARGTYPE, ARGDESC)
mxArray
*
CreateFunctionInputArgumentStruct
(
std
::
vector
<
FunctionInputArgument
>&
vInputArgs
)
{
inline
mxArray
*
CreateFunctionInputArgumentStruct
(
std
::
vector
<
FunctionInputArgument
>&
vInputArgs
)
{
const
mwSize
nFields
=
5
;
const
mwSize
nFields
=
5
;
const
char
*
ppszFieldNames
[]
=
{
"name"
,
"type"
,
"desc"
,
"optional"
,
"default"
};
const
char
*
ppszFieldNames
[]
=
{
"name"
,
"type"
,
"desc"
,
"optional"
,
"default"
};
mxArray
*
pStruct
=
mxCreateStructMatrix
(
1
,
int
(
vInputArgs
.
size
()
),
nFields
,
ppszFieldNames
);
mxArray
*
pStruct
=
mxCreateStructMatrix
(
1
,
int
(
vInputArgs
.
size
()
),
nFields
,
ppszFieldNames
);
for
(
size_t
i
=
0
;
i
<
vInputArgs
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
vInputArgs
.
size
();
i
++
)
{
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
0
],
mxCreateString
(
vInputArgs
[
i
].
sName
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
0
],
mxCreateString
(
vInputArgs
[
i
].
sName
.
c_str
()
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
1
],
mxCreateString
(
vInputArgs
[
i
].
sType
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
1
],
mxCreateString
(
vInputArgs
[
i
].
sType
.
c_str
()
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
2
],
mxCreateString
(
vInputArgs
[
i
].
sDesc
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
2
],
mxCreateString
(
vInputArgs
[
i
].
sDesc
.
c_str
()
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
3
],
mxCreateLogicalScalar
(
vInputArgs
[
i
].
bOptional
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
3
],
mxCreateLogicalScalar
(
vInputArgs
[
i
].
bOptional
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
4
],
mxCreateString
(
vInputArgs
[
i
].
sDefaultValue
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
4
],
mxCreateString
(
vInputArgs
[
i
].
sDefaultValue
.
c_str
()
)
);
}
}
return
pStruct
;
return
pStruct
;
}
}
;
mxArray
*
CreateFunctionOutputArgumentStruct
(
std
::
vector
<
FunctionOutputArgument
>&
vOutputArgs
)
{
inline
mxArray
*
CreateFunctionOutputArgumentStruct
(
std
::
vector
<
FunctionOutputArgument
>&
vOutputArgs
)
{
const
mwSize
nFields
=
3
;
const
mwSize
nFields
=
3
;
const
char
*
ppszFieldNames
[]
=
{
"name"
,
"type"
,
"desc"
};
const
char
*
ppszFieldNames
[]
=
{
"name"
,
"type"
,
"desc"
};
mxArray
*
pStruct
=
mxCreateStructMatrix
(
1
,
int
(
vOutputArgs
.
size
()
),
nFields
,
ppszFieldNames
);
mxArray
*
pStruct
=
mxCreateStructMatrix
(
1
,
int
(
vOutputArgs
.
size
()
),
nFields
,
ppszFieldNames
);
for
(
size_t
i
=
0
;
i
<
vOutputArgs
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
vOutputArgs
.
size
();
i
++
)
{
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
0
],
mxCreateString
(
vOutputArgs
[
i
].
sName
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
0
],
mxCreateString
(
vOutputArgs
[
i
].
sName
.
c_str
()
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
1
],
mxCreateString
(
vOutputArgs
[
i
].
sType
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
1
],
mxCreateString
(
vOutputArgs
[
i
].
sType
.
c_str
()
)
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
2
],
mxCreateString
(
vOutputArgs
[
i
].
sDesc
.
c_str
())
);
mxSetField
(
pStruct
,
(
mwIndex
)
i
,
ppszFieldNames
[
2
],
mxCreateString
(
vOutputArgs
[
i
].
sDesc
.
c_str
()
)
);
}
}
return
pStruct
;
return
pStruct
;
}
}
;
#endif
__FUNCTIONMAPPINGS_H__
#endif
IW_FUNCTION_MAPPINGS
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment