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
eaabf17a
Commit
eaabf17a
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
FIX: Packing values for C++ interaction is much more robust now.
parent
f81f7d0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Full functionality of libcaosdb
Pipeline
#12840
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/Entity.m
+5
-3
5 additions, 3 deletions
src/Entity.m
src/Property.m
+5
-3
5 additions, 3 deletions
src/Property.m
src/private/maox_pack_value.m
+41
-0
41 additions, 0 deletions
src/private/maox_pack_value.m
with
51 additions
and
6 deletions
src/Entity.m
+
5
−
3
View file @
eaabf17a
...
@@ -162,9 +162,11 @@ classdef Entity < handle
...
@@ -162,9 +162,11 @@ classdef Entity < handle
res
.
datatype
=
obj
.
datatype_
;
res
.
datatype
=
obj
.
datatype_
;
res
.
unit
=
obj
.
unit
;
res
.
unit
=
obj
.
unit
;
if
(
isempty
(
obj
.
datatype_
))
if
(
isempty
(
obj
.
datatype_
))
warning
([
"Trying to transmit an Entity with value but without Datatype. List-iness is"
,
...
if
~
isempty
(
obj
.
value
)
" unknown, so the value will be omitted."
])
warning
([
"Trying to transmit an Entity with value but without Datatype. List-iness"
,
...
res
.
datatype
=
struct
(
"dtypeName"
,
"UNSPECIFIED"
,
"isList"
,
false
,
"isReference"
,
false
)
" is unknown, so the value will be omitted."
])
end
% res.datatype = struct("dtypeName", "UNSPECIFIED", "isList", false, "isReference", false);
res
.
value
=
sparse
([]);
res
.
value
=
sparse
([]);
else
else
res
.
value
=
maox_pack_value
(
obj
.
value
,
obj
.
datatype_
.
isList
);
res
.
value
=
maox_pack_value
(
obj
.
value
,
obj
.
datatype_
.
isList
);
...
...
This diff is collapsed.
Click to expand it.
src/Property.m
+
5
−
3
View file @
eaabf17a
...
@@ -62,9 +62,11 @@ classdef Property < handle
...
@@ -62,9 +62,11 @@ classdef Property < handle
res
.
datatype
=
obj
.
datatype_
;
res
.
datatype
=
obj
.
datatype_
;
res
.
unit
=
obj
.
unit
;
res
.
unit
=
obj
.
unit
;
if
(
isempty
(
obj
.
datatype_
))
if
(
isempty
(
obj
.
datatype_
))
warning
([
"Trying to transmit an Entity with value but without Datatype. List-iness is"
,
...
if
~
isempty
(
obj
.
value
)
" unknown, so the value will be omitted."
])
warning
([
"Trying to transmit an Entity with value but without Datatype. List-iness"
,
...
res
.
datatype
=
struct
(
"dtypeName"
,
"UNSPECIFIED"
,
"isList"
,
false
,
"isReference"
,
false
)
" is unknown, so the value will be omitted."
])
end
% res.datatype = struct("dtypeName", "UNSPECIFIED", "isList", false, "isReference", false);
res
.
value
=
sparse
([]);
res
.
value
=
sparse
([]);
else
else
res
.
value
=
maox_pack_value
(
obj
.
value
,
obj
.
datatype_
.
isList
);
res
.
value
=
maox_pack_value
(
obj
.
value
,
obj
.
datatype_
.
isList
);
...
...
This diff is collapsed.
Click to expand it.
src/private/maox_pack_value.m
0 → 100644
+
41
−
0
View file @
eaabf17a
% This file is a part of the CaosDB Project.
%
% Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
% Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Affero General Public License as
% published by the Free Software Foundation, either version 3 of the
% License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Affero General Public License for more details.
%
% You should have received a copy of the GNU Affero General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%% Pack the value for handling by maoxdb
%
% This means that the value will be packed into a cell array if it is considered a list.
function
result
=
maox_pack_value
(
value
,
isList
)
% Pack list values into a 1x1 cell array
if
isList
if
(
isempty
(
value
)
&&
~
ischar
(
value
))
% empty list
result
=
{};
else
result
=
{
value
};
end
else
% test if value looks scalar
if
iscellstr
(
value
)
||
(
isnumeric
(
value
)
&&
numel
(
value
)
>
1
)
error
(
"caosdb:valueError"
,
"Value looks list-like, but it must be scalar."
);
end
% handle empty scalar value
if
(
isempty
(
value
)
&&
~
ischar
(
value
))
result
=
sparse
([]);
else
result
=
value
;
end
end
end
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