Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
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-cpplib
Commits
f4ed997d
Commit
f4ed997d
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Convenience list argument for SetDataType(..., bool list_type).
parent
67522b83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!14
ENH: New functions getEnumNameFromValue() and getEnumValueFromName()
,
!12
F consolidation
Pipeline
#12261
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/caosdb/entity.h
+4
-4
4 additions, 4 deletions
include/caosdb/entity.h
src/caosdb/entity.cpp
+8
-8
8 additions, 8 deletions
src/caosdb/entity.cpp
test/test_entity.cpp
+23
-0
23 additions, 0 deletions
test/test_entity.cpp
with
35 additions
and
12 deletions
include/caosdb/entity.h
+
4
−
4
View file @
f4ed997d
...
@@ -541,8 +541,8 @@ public:
...
@@ -541,8 +541,8 @@ public:
* Set the datatype of this property.
* Set the datatype of this property.
*/
*/
auto
SetDataType
(
const
DataType
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
DataType
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
AtomicDataType
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
AtomicDataType
new_data_type
,
bool
list_type
=
false
)
->
StatusCode
;
auto
SetDataType
(
const
std
::
string
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
std
::
string
&
new_data_type
,
bool
list_type
=
false
)
->
StatusCode
;
/**
/**
* Return a json string representing this property.
* Return a json string representing this property.
...
@@ -712,8 +712,8 @@ public:
...
@@ -712,8 +712,8 @@ public:
auto
SetUnit
(
const
std
::
string
&
unit
)
->
void
;
auto
SetUnit
(
const
std
::
string
&
unit
)
->
void
;
auto
SetDataType
(
const
DataType
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
DataType
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
AtomicDataType
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
AtomicDataType
new_data_type
,
bool
list_type
=
false
)
->
StatusCode
;
auto
SetDataType
(
const
std
::
string
&
new_data_type
)
->
StatusCode
;
auto
SetDataType
(
const
std
::
string
&
new_data_type
,
bool
list_type
=
false
)
->
StatusCode
;
auto
AppendProperty
(
const
Property
&
property
)
->
void
;
auto
AppendProperty
(
const
Property
&
property
)
->
void
;
auto
RemoveProperty
(
int
index
)
->
void
;
auto
RemoveProperty
(
int
index
)
->
void
;
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/entity.cpp
+
8
−
8
View file @
f4ed997d
...
@@ -142,12 +142,12 @@ auto Property::SetDataType(const DataType &new_data_type) -> StatusCode {
...
@@ -142,12 +142,12 @@ auto Property::SetDataType(const DataType &new_data_type) -> StatusCode {
return
this
->
data_type
.
CopyFrom
(
new_data_type
);
return
this
->
data_type
.
CopyFrom
(
new_data_type
);
}
}
auto
Property
::
SetDataType
(
const
AtomicDataType
new_data_type
)
->
StatusCode
{
auto
Property
::
SetDataType
(
const
AtomicDataType
new_data_type
,
bool
list_type
)
->
StatusCode
{
return
SetDataType
(
DataType
(
new_data_type
));
return
SetDataType
(
DataType
(
new_data_type
,
list_type
));
}
}
auto
Property
::
SetDataType
(
const
std
::
string
&
new_data_type
)
->
StatusCode
{
auto
Property
::
SetDataType
(
const
std
::
string
&
new_data_type
,
bool
list_type
)
->
StatusCode
{
return
SetDataType
(
DataType
(
new_data_type
));
return
SetDataType
(
DataType
(
new_data_type
,
list_type
));
}
}
[[
nodiscard
]]
auto
Entity
::
GetParents
()
const
->
const
Parents
&
{
[[
nodiscard
]]
auto
Entity
::
GetParents
()
const
->
const
Parents
&
{
...
@@ -238,12 +238,12 @@ auto Entity::SetDataType(const DataType &new_data_type) -> StatusCode {
...
@@ -238,12 +238,12 @@ auto Entity::SetDataType(const DataType &new_data_type) -> StatusCode {
return
this
->
data_type
.
CopyFrom
(
new_data_type
);
return
this
->
data_type
.
CopyFrom
(
new_data_type
);
}
}
auto
Entity
::
SetDataType
(
const
AtomicDataType
new_data_type
)
->
StatusCode
{
auto
Entity
::
SetDataType
(
const
AtomicDataType
new_data_type
,
bool
list_type
)
->
StatusCode
{
return
SetDataType
(
DataType
(
new_data_type
));
return
SetDataType
(
DataType
(
new_data_type
,
list_type
));
}
}
auto
Entity
::
SetDataType
(
const
std
::
string
&
new_data_type
)
->
StatusCode
{
auto
Entity
::
SetDataType
(
const
std
::
string
&
new_data_type
,
bool
list_type
)
->
StatusCode
{
return
SetDataType
(
DataType
(
new_data_type
));
return
SetDataType
(
DataType
(
new_data_type
,
list_type
));
}
}
auto
Entity
::
SetFilePath
(
const
std
::
string
&
path
)
->
void
{
auto
Entity
::
SetFilePath
(
const
std
::
string
&
path
)
->
void
{
...
...
This diff is collapsed.
Click to expand it.
test/test_entity.cpp
+
23
−
0
View file @
f4ed997d
...
@@ -85,6 +85,29 @@ TEST(test_entity, test_property_setters) {
...
@@ -85,6 +85,29 @@ TEST(test_entity, test_property_setters) {
EXPECT_EQ
(
prop
.
GetUnit
(),
"prop_unit"
);
EXPECT_EQ
(
prop
.
GetUnit
(),
"prop_unit"
);
EXPECT_TRUE
(
prop
.
GetDataType
().
IsReference
());
EXPECT_TRUE
(
prop
.
GetDataType
().
IsReference
());
EXPECT_EQ
(
prop
.
GetDataType
().
AsReference
().
GetName
(),
"prop_dtype"
);
EXPECT_EQ
(
prop
.
GetDataType
().
AsReference
().
GetName
(),
"prop_dtype"
);
EXPECT_FALSE
(
prop
.
GetDataType
().
IsList
());
prop
.
SetDataType
(
AtomicDataType
::
DATETIME
);
EXPECT_TRUE
(
prop
.
GetDataType
().
IsAtomic
());
EXPECT_EQ
(
prop
.
GetDataType
().
AsAtomic
(),
AtomicDataType
::
DATETIME
);
EXPECT_FALSE
(
prop
.
GetDataType
().
IsList
());
}
TEST
(
test_entity
,
test_list_property_setters
)
{
auto
prop
=
Property
();
prop
.
SetDataType
(
AtomicDataType
::
DATETIME
);
// Set as atomic first.
EXPECT_TRUE
(
prop
.
GetDataType
().
IsAtomic
());
EXPECT_EQ
(
prop
.
GetDataType
().
AsAtomic
(),
AtomicDataType
::
DATETIME
);
prop
.
SetDataType
(
AtomicDataType
::
DOUBLE
,
true
);
auto
const
&
dtype
=
prop
.
GetDataType
();
EXPECT_FALSE
(
dtype
.
IsAtomic
());
// Should not be true anymore.
EXPECT_FALSE
(
dtype
.
IsReference
());
EXPECT_TRUE
(
dtype
.
IsList
());
EXPECT_NE
(
dtype
.
AsAtomic
(),
AtomicDataType
::
DATETIME
);
// Should be overwritten.
EXPECT_TRUE
(
dtype
.
AsList
().
IsListOfAtomic
());
EXPECT_EQ
(
dtype
.
AsList
().
GetAtomicDataType
(),
AtomicDataType
::
DOUBLE
);
}
}
TEST
(
test_entity
,
test_append_property
)
{
TEST
(
test_entity
,
test_append_property
)
{
...
...
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