Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Octave library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Octave library
Commits
ffa5335d
Commit
ffa5335d
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Complete info output.
parent
2c7bc130
Branches
Branches containing commit
Tags
caosdb-server-v0.12.1
Tags containing commit
1 merge request
!1
Initial functionality
Pipeline
#10883
failed
3 years ago
Stage: setup
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caosdbClass.m
+3
-3
3 additions, 3 deletions
src/caosdbClass.m
src/private/_info.cpp
+22
-22
22 additions, 22 deletions
src/private/_info.cpp
src/private/maoxdbUtils.hpp
+29
-0
29 additions, 0 deletions
src/private/maoxdbUtils.hpp
with
54 additions
and
25 deletions
src/caosdbClass.m
+
3
−
3
View file @
ffa5335d
...
...
@@ -9,15 +9,15 @@ classdef caosdbClass < handle
methods
function
obj
=
caosdbClass
(
connection
=
""
)
obj
.
connection
=
connection
;
disp
([
"created: >"
,
connection
,
"<"
]);
endfunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% info %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function
res
=
info
(
obj
)
info_result
=
_
info
(
obj
.
connection
)
res
=
info_result
disp
([
"connection: >"
,
obj
.
connection
,
"<"
]);
info_result
=
_
info
(
obj
.
connection
);
res
=
info_result
;
endfunction
endmethods
endclassdef
This diff is collapsed.
Click to expand it.
src/private/_info.cpp
+
22
−
22
View file @
ffa5335d
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/constants.h"
// for LIBCAOSDB_VERSION_MAJOR, LIBCAOSDB_VE...
#include
"caosdb/info.h"
// for VersionInfo
#include
"maoxdbUtils.hpp"
// caosDB utils for mex files
#include
"mex.h"
// for mxArray, mexFunction
#include
"mexproto.h"
// for mexPrintf, mxCreateString, mxGetChars
#include
<cstring>
// for strcmp
...
...
@@ -8,42 +9,40 @@
#include
<string>
// for allocator, char_traits, operator+
using
std
::
string
;
using
caosdb
::
connection
::
Connection
;
using
caosdb
::
connection
::
ConnectionManager
;
mxArray
*
info
(
const
string
&
connection_name
);
// auto print_version() -> const char * {
// mexPrintf("Octave caosdb client %s\n\n", FULL_VERSION.c_str());
// mexPrintf("We don't miss the H of caos.\n");
// return FULL_VERSION.c_str();
// };
/**
* The implementation of the info retrieval.
*/
mxArray
*
info
(
string
const
&
connection_name
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
std
::
shared_ptr
<
Connection
>
connection
=
NULL
;
if
(
connection_name
==
""
)
{
connection
=
ConnectionManager
::
GetDefaultConnection
();
}
else
{
connection
=
ConnectionManager
::
GetConnection
(
connection_name
);
}
const
auto
&
version_info
=
connection
->
GetVersionInfo
();
mexPrintf
(
"Server Version: v%d.%d.%d-%s-%s
\n
"
,
version_info
->
GetMajor
(),
version_info
->
GetMinor
(),
version_info
->
GetPatch
(),
version_info
->
GetPreRelease
().
c_str
(),
version_info
->
GetBuild
().
c_str
());
const
char
*
keys
[]
=
{
"major"
,
"minor"
,
"patch"
,
"pre_release"
,
"build"
};
mwSize
dims
[
2
]
=
{
1
,
1
};
mxArray
*
info_struct
=
mxCreateStructArray
(
2
,
dims
,
5
,
keys
);
auto
*
major
=
mxCreateNumericMatrix
(
1
,
1
,
mxUINT64_CLASS
,
mxREAL
);
UINT64_T
*
major_data
=
(
UINT64_T
*
)
mxGetData
(
major
);
major_data
[
0
]
=
version_info
->
GetMajor
();
mxSetData
(
major
,
major_data
);
auto
*
major
=
mxSCALAR
(
UINT64
,
major
,
version_info
->
GetMajor
());
auto
*
minor
=
mxSCALAR
(
UINT64
,
minor
,
version_info
->
GetMinor
());
auto
*
patch
=
mxSCALAR
(
UINT64
,
patch
,
version_info
->
GetPatch
());
mxSetField
(
info_struct
,
0
,
"major"
,
major
);
mxSetField
(
info_struct
,
0
,
"minor"
,
minor
);
mxSetField
(
info_struct
,
0
,
"patch"
,
patch
);
mxSetField
(
info_struct
,
0
,
"pre_release"
,
mxCreateString
(
version_info
->
GetPreRelease
().
c_str
()));
mxSetField
(
info_struct
,
0
,
"build"
,
mxCreateString
(
"foobuild"
));
mxCreateString
(
version_info
->
GetBuild
().
c_str
()
));
return
info_struct
;
}
/**
*
*/
/**
* @brief Get info about the server
*
...
...
@@ -57,10 +56,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs,
const
mxArray
*
prhs
[])
{
string
conn_name
(
""
);
if
(
nrhs
>=
1
)
{
if
(
nrhs
>=
1
&&
mxGetNumberOfElements
(
prhs
[
0
])
>
0
)
{
conn_name
=
mxGetChars
(
prhs
[
0
]);
}
mexPrintf
(
"Connection: >%s<
\t
%d
\n
"
,
conn_name
.
c_str
(),
nrhs
);
auto
info_struct
=
info
(
conn_name
);
plhs
[
0
]
=
info_struct
;
// plhs[0] = mxCreateString("foostring");
}
This diff is collapsed.
Click to expand it.
src/private/maoxdbUtils.hpp
0 → 100644
+
29
−
0
View file @
ffa5335d
#ifndef MAOXDBUTILS_H
#define MAOXDBUTILS_H
#include
"mex.h"
#include
"mexproto.h"
/**
* mxSCALAR(type, name, value): Create a 1x1 mxArray of type TYPE and value VALUE. The NAME must be
* unique within each scope.
*
* Use it like so (note that the assignment to NAME is necessary):
*
* auto* scalar = mxSCALAR(UINT64, scalar, value);
*
* This will exand to:
*
* mxCreateNumericMatrix(1, 1, mxUINT64_CLASS, mxREAL);
* UINT64_T* scalar_data = (UINT64_T*) mxGetData(scalar);
* scalar_data[0] = value;
* mxSetData(scalar, scalar_data);
*
*/
#define mxSCALAR(type, name, value) \
mxCreateNumericMatrix(1, 1, mx ## type ## _CLASS, mxREAL); \
auto * __ ## name ##_data = (type ## _T*) mxGetData(name); \
__ ## name ## _data[0] = value; \
mxSetData(name, __ ## name ## _data)
#endif
/* MAOXDBUTILS_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment