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
5edbfac4
Commit
5edbfac4
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DRAFT: Add set_value to entity
parent
de871349
No related branches found
No related tags found
1 merge request
!13
ENH: Add datatypes and value classes to Extern C interface
Pipeline
#12223
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/caosdb/value.h
+2
-0
2 additions, 0 deletions
include/caosdb/value.h
include/ccaosdb.h
+12
-12
12 additions, 12 deletions
include/ccaosdb.h
src/ccaosdb.cpp
+224
-6
224 additions, 6 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+37
-11
37 additions, 11 deletions
test/test_ccaosdb.cpp
with
275 additions
and
29 deletions
include/caosdb/value.h
+
2
−
0
View file @
5edbfac4
...
...
@@ -132,6 +132,8 @@ public:
}
LIST_VALUE_CONSTRUCTOR
(
int64_t
,
set_integer_value
)
LIST_VALUE_CONSTRUCTOR
(
double
,
set_double_value
)
LIST_VALUE_CONSTRUCTOR
(
bool
,
set_boolean_value
)
[[
nodiscard
]]
inline
auto
IsNull
()
->
bool
{
return
this
->
wrapped
->
value_case
()
==
ValueCase
::
VALUE_NOT_SET
;
...
...
This diff is collapsed.
Click to expand it.
include/ccaosdb.h
+
12
−
12
View file @
5edbfac4
...
...
@@ -439,21 +439,21 @@ int caosdb_entity_entity_set_unit(caosdb_entity_entity *entity,
const
char
*
unit
);
// TODO(fspreck) replace by more specific setters
int
caosdb_entity_entity_set_int_value
(
caosdb_entity_entity
*
entity
,
const
long
*
value
);
const
long
value
);
int
caosdb_entity_entity_set_double_value
(
caosdb_entity_entity
*
entity
,
const
double
*
value
);
const
double
value
);
int
caosdb_entity_entity_set_boolean_value
(
caosdb_entity_entity
*
entity
,
const
bool
*
value
);
const
bool
value
);
int
caosdb_entity_entity_set_string_value
(
caosdb_entity_entity
*
entity
,
const
char
*
value
);
int
caosdb_entity_entity_set_int_list_value
(
caosdb_entity_entity
*
entity
,
const
long
*
*
value
,
const
long
*
value
,
const
int
length
);
int
caosdb_entity_entity_set_double_list_value
(
caosdb_entity_entity
*
entity
,
const
double
*
*
value
,
const
double
*
value
,
const
int
length
);
int
caosdb_entity_entity_set_boolean_list_value
(
caosdb_entity_entity
*
entity
,
const
bool
*
*
value
,
const
bool
*
value
,
const
int
length
);
int
caosdb_entity_entity_set_string_list_value
(
caosdb_entity_entity
*
entity
,
const
char
**
value
,
...
...
@@ -479,20 +479,20 @@ int caosdb_entity_property_set_unit(caosdb_entity_property *property,
const
char
*
unit
);
int
caosdb_entity_property_set_int_value
(
caosdb_entity_property
*
property
,
const
long
*
value
);
const
long
value
);
int
caosdb_entity_property_set_double_value
(
caosdb_entity_property
*
property
,
const
double
*
value
);
const
double
value
);
int
caosdb_entity_property_set_boolean_value
(
caosdb_entity_property
*
property
,
const
bool
*
value
);
const
bool
value
);
int
caosdb_entity_property_set_string_value
(
caosdb_entity_property
*
property
,
const
char
*
value
);
int
caosdb_entity_property_set_int_list_value
(
caosdb_entity_property
*
property
,
const
long
*
*
value
,
const
long
*
value
,
const
int
length
);
int
caosdb_entity_property_set_double_list_value
(
caosdb_entity_property
*
property
,
const
double
*
*
value
,
const
int
length
);
caosdb_entity_property
*
property
,
const
double
*
value
,
const
int
length
);
int
caosdb_entity_property_set_boolean_list_value
(
caosdb_entity_property
*
property
,
const
bool
*
*
value
,
const
int
length
);
caosdb_entity_property
*
property
,
const
bool
*
value
,
const
int
length
);
int
caosdb_entity_property_set_string_list_value
(
caosdb_entity_property
*
property
,
const
char
**
value
,
const
int
length
);
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
224
−
6
View file @
5edbfac4
...
...
@@ -783,9 +783,118 @@ CAOSDB_ENTITY_SET(description, description,
// CAOSDB_ENTITY_SET(datatype, datatype,
// wrapped_entity->SetDataType(std::string(datatype));)
CAOSDB_ENTITY_SET
(
unit
,
unit
,
wrapped_entity
->
SetUnit
(
std
::
string
(
unit
));)
// TODO(fspreck)
// CAOSDB_ENTITY_SET(value, value,
// wrapped_entity->SetValue(std::string(value));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_int_value
(
caosdb_entity_entity
*
entity
,
const
long
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_double_value
(
caosdb_entity_entity
*
entity
,
const
double
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_boolean_value
(
caosdb_entity_entity
*
entity
,
const
bool
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_string_value
(
caosdb_entity_entity
*
entity
,
const
char
*
value
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
wrapped_entity
->
SetValue
(
std
::
string
(
value
));
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_int_list_value
(
caosdb_entity_entity
*
entity
,
const
long
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
long
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_entity
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_double_list_value
(
caosdb_entity_entity
*
entity
,
const
double
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
double
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_entity
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_boolean_list_value
(
caosdb_entity_entity
*
entity
,
const
bool
*
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
bool
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_entity
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_string_list_value
(
caosdb_entity_entity
*
entity
,
const
char
**
value
,
const
int
length
),
{
auto
*
wrapped_entity
=
static_cast
<
caosdb
::
entity
::
Entity
*>
(
entity
->
wrapped_entity
);
std
::
vector
<
std
::
string
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
std
::
string
(
value
[
i
]));
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_entity
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
...
...
@@ -846,7 +955,116 @@ CAOSDB_PROPERTY_SET(id, id, wrapped_property->SetId(std::string(id));)
// CAOSDB_PROPERTY_SET(importance, importance,
// wrapped_property->SetImportance(std::string(importance));)
CAOSDB_PROPERTY_SET
(
unit
,
unit
,
wrapped_property
->
SetUnit
(
std
::
string
(
unit
));)
// TODO(fspreck)
// CAOSDB_PROPERTY_SET(value, value,
// wrapped_property->SetValue(std::string(value));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_int_value
(
caosdb_entity_property
*
property
,
const
long
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_double_value
(
caosdb_entity_property
*
property
,
const
double
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_boolean_value
(
caosdb_entity_property
*
property
,
const
bool
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
value
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_string_value
(
caosdb_entity_property
*
property
,
const
char
*
value
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
wrapped_property
->
SetValue
(
std
::
string
(
value
));
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_int_list_value
(
caosdb_entity_property
*
property
,
const
long
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
long
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_property
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_double_list_value
(
caosdb_entity_property
*
property
,
const
double
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
double
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_property
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_boolean_list_value
(
caosdb_entity_property
*
property
,
const
bool
*
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
bool
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
value
[
i
]);
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_property
->
SetValue
(
to_be_set
);
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_string_list_value
(
caosdb_entity_property
*
property
,
const
char
**
value
,
const
int
length
),
{
auto
*
wrapped_property
=
static_cast
<
caosdb
::
entity
::
Property
*>
(
property
->
wrapped_property
);
std
::
vector
<
std
::
string
>
value_list
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
value_list
.
push_back
(
std
::
string
(
value
[
i
]));
}
caosdb
::
entity
::
Value
to_be_set
(
value_list
);
wrapped_property
->
SetValue
(
to_be_set
);
return
0
;
})
}
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
37
−
11
View file @
5edbfac4
...
...
@@ -189,7 +189,7 @@ TEST_F(test_ccaosdb, test_entity) {
EXPECT_EQ
(
strcmp
(
out
,
"m"
),
0
);
// TODO(fspreck)
//
caosdb_entity_entity_set_value(&entity,
"
5.0
"
);
caosdb_entity_entity_set_
double_
value
(
&
entity
,
5.0
);
// caosdb_entity_entity_get_value(&entity, out);
// EXPECT_EQ(strcmp(out, "5.0"), 0);
...
...
@@ -226,12 +226,11 @@ TEST_F(test_ccaosdb, test_property) {
caosdb_entity_property_set_id
(
&
property
,
"some_id"
);
caosdb_entity_property_set_name
(
&
property
,
"some_name"
);
// TODO(fspreck)
// caosdb_entity_property_set_datatype(&property, "
some_datatype
");
// caosdb_entity_property_set_datatype(&property, "
TEXT
");
// TODO(fspreck)
// caosdb_entity_property_set_importance(&property, "
some_importance
");
// caosdb_entity_property_set_importance(&property, "
FIX
");
caosdb_entity_property_set_unit
(
&
property
,
"some_unit"
);
// TODO(fspreck)
// caosdb_entity_property_set_value(&property, "some_value");
caosdb_entity_property_set_string_value
(
&
property
,
"some_value"
);
char
out
[
255
]
=
{
"a"
};
// NOLINT
caosdb_entity_property_get_id
(
&
property
,
out
);
...
...
@@ -242,23 +241,51 @@ TEST_F(test_ccaosdb, test_property) {
// TODO(fspreck)
// caosdb_entity_property_get_datatype(&property, out);
// EXPECT_EQ(strcmp(out, "
some_datatype
"), 0);
// EXPECT_EQ(strcmp(out, "
TEXT
"), 0);
// TODO(fspreck)
// caosdb_entity_property_get_importance(&property, out);
// EXPECT_EQ(strcmp(out, "
some_importance
"), 0);
// EXPECT_EQ(strcmp(out, "
FIX
"), 0);
caosdb_entity_property_get_unit
(
&
property
,
out
);
EXPECT_EQ
(
strcmp
(
out
,
"some_unit"
),
0
);
// TODO(fspreck)
// caosdb_entity_property_get_value(&property, out);
// caosdb_entity_property_get_
string_
value(&property, out);
// EXPECT_EQ(strcmp(out, "some_value"), 0);
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
}
// TODO(fspreck) Test a property with datatype LIST<Something> and a
// list value.
TEST_F
(
test_ccaosdb
,
test_list_property
)
{
caosdb_entity_property
property
;
int
return_code
(
caosdb_entity_create_property
(
&
property
));
EXPECT_EQ
(
return_code
,
0
);
// TODO(fspreck)
// return_code = caosdb_entity_property_set_datatype(&property, "LIST<TEXT>");
// EXPECT_EQ(return_code, 0);
const
*
char
[]
value_list
=
{
"val0"
,
"val1"
,
"val2"
};
// NOLINT
return_code
=
caosdb_entity_property_set_string_list_value
(
&
property
,
value_list
,
3
);
EXPECT_EQ
(
return_code
,
0
);
// TODO(fspreck)
// char out_type[255] = {"abc"}; // NOLINT
// return_code = caosdb_entity_property_get_datatype(&property, out_type);
// EXPECT_EQ(return_code, 0);
// EXPECT_EQ(strcmp(out_type, "LIST<TEXT>"));
// TODO(fspreck) get and compare values in list
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
}
TEST_F
(
test_ccaosdb
,
test_entity_with_parent_and_property
)
{
std
::
cout
<<
"Creating objects ... "
<<
std
::
endl
;
caosdb_entity_parent
input_parent
;
...
...
@@ -275,9 +302,8 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
caosdb_entity_property_set_id
(
&
input_property
,
"property_id"
);
caosdb_entity_property_set_name
(
&
input_property
,
"property_name"
);
// TODO(fspreck)
// caosdb_entity_property_set_datatype(&input_property, "property_datatype");
// TODO(fspreck)
// caosdb_entity_property_set_value(&input_property, "property_value");
// caosdb_entity_property_set_datatype(&input_property, "TEXT");
caosdb_entity_property_set_string_value
(
&
input_property
,
"property_value"
);
caosdb_entity_entity
entity
;
return_code
=
caosdb_entity_create_entity
(
&
entity
);
...
...
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