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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
e341dc88
Commit
e341dc88
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Re-implement set_value and set_datatype
parent
9bae96e0
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!24
API: Introduce value and datatype structs to Extern C
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/caosdb/entity.h
+2
-2
2 additions, 2 deletions
include/caosdb/entity.h
include/ccaosdb.h
+0
-7
0 additions, 7 deletions
include/ccaosdb.h
src/caosdb/entity.cpp
+2
-4
2 additions, 4 deletions
src/caosdb/entity.cpp
src/ccaosdb.cpp
+36
-49
36 additions, 49 deletions
src/ccaosdb.cpp
with
40 additions
and
62 deletions
include/caosdb/entity.h
+
2
−
2
View file @
e341dc88
...
@@ -515,7 +515,7 @@ public:
...
@@ -515,7 +515,7 @@ public:
* Set the value of this property.
* Set the value of this property.
*/
*/
auto
SetValue
(
const
Value
&
value
)
->
StatusCode
;
auto
SetValue
(
const
Value
&
value
)
->
StatusCode
;
//
auto SetValue(const AbstractValue &value) -> StatusCode;
auto
SetValue
(
const
AbstractValue
&
value
)
->
StatusCode
;
auto
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
;
auto
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
;
auto
SetValue
(
const
char
*
value
)
->
StatusCode
;
auto
SetValue
(
const
char
*
value
)
->
StatusCode
;
auto
SetValue
(
const
double
value
)
->
StatusCode
;
auto
SetValue
(
const
double
value
)
->
StatusCode
;
...
@@ -688,7 +688,7 @@ public:
...
@@ -688,7 +688,7 @@ public:
*/
*/
auto
SetDescription
(
const
std
::
string
&
description
)
->
void
;
auto
SetDescription
(
const
std
::
string
&
description
)
->
void
;
//
auto SetValue(const AbstractValue &value) -> StatusCode;
auto
SetValue
(
const
AbstractValue
&
value
)
->
StatusCode
;
auto
SetValue
(
const
Value
&
value
)
->
StatusCode
;
auto
SetValue
(
const
Value
&
value
)
->
StatusCode
;
auto
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
;
auto
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
;
auto
SetValue
(
const
char
*
value
)
->
StatusCode
;
auto
SetValue
(
const
char
*
value
)
->
StatusCode
;
...
...
This diff is collapsed.
Click to expand it.
include/ccaosdb.h
+
0
−
7
View file @
e341dc88
...
@@ -474,11 +474,9 @@ int caosdb_entity_entity_set_name(caosdb_entity_entity *entity, const char *name
...
@@ -474,11 +474,9 @@ int caosdb_entity_entity_set_name(caosdb_entity_entity *entity, const char *name
int
caosdb_entity_entity_set_description
(
caosdb_entity_entity
*
entity
,
const
char
*
description
);
int
caosdb_entity_entity_set_description
(
caosdb_entity_entity
*
entity
,
const
char
*
description
);
int
caosdb_entity_entity_set_local_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
int
caosdb_entity_entity_set_local_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
int
caosdb_entity_entity_set_file_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
int
caosdb_entity_entity_set_file_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
// TODO(fspreck) implementation
int
caosdb_entity_entity_set_datatype
(
caosdb_entity_entity
*
entity
,
int
caosdb_entity_entity_set_datatype
(
caosdb_entity_entity
*
entity
,
caosdb_entity_datatype
*
datatype
);
caosdb_entity_datatype
*
datatype
);
int
caosdb_entity_entity_set_unit
(
caosdb_entity_entity
*
entity
,
const
char
*
unit
);
int
caosdb_entity_entity_set_unit
(
caosdb_entity_entity
*
entity
,
const
char
*
unit
);
// TODO(fspreck) implementation
int
caosdb_entity_entity_set_value
(
caosdb_entity_entity
*
entity
,
caosdb_entity_value
*
value
);
int
caosdb_entity_entity_set_value
(
caosdb_entity_entity
*
entity
,
caosdb_entity_value
*
value
);
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
caosdb_entity_parent
*
parent
);
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
caosdb_entity_parent
*
parent
);
...
@@ -489,20 +487,15 @@ int caosdb_entity_entity_remove_property(caosdb_entity_entity *entity, int index
...
@@ -489,20 +487,15 @@ int caosdb_entity_entity_remove_property(caosdb_entity_entity *entity, int index
int
caosdb_entity_property_set_id
(
caosdb_entity_property
*
property
,
const
char
*
id
);
int
caosdb_entity_property_set_id
(
caosdb_entity_property
*
property
,
const
char
*
id
);
int
caosdb_entity_property_set_name
(
caosdb_entity_property
*
property
,
const
char
*
name
);
int
caosdb_entity_property_set_name
(
caosdb_entity_property
*
property
,
const
char
*
name
);
// TODO(fspreck) implementation
int
caosdb_entity_property_set_datatype
(
caosdb_entity_property
*
property
,
int
caosdb_entity_property_set_datatype
(
caosdb_entity_property
*
property
,
caosdb_entity_datatype
*
datatype
);
caosdb_entity_datatype
*
datatype
);
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
property
,
const
char
*
importance
);
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
property
,
const
char
*
importance
);
int
caosdb_entity_property_set_unit
(
caosdb_entity_property
*
property
,
const
char
*
unit
);
int
caosdb_entity_property_set_unit
(
caosdb_entity_property
*
property
,
const
char
*
unit
);
// TODO(fspreck) implementation
int
caosdb_entity_property_set_value
(
caosdb_entity_property
*
property
,
caosdb_entity_value
*
value
);
int
caosdb_entity_property_set_value
(
caosdb_entity_property
*
property
,
caosdb_entity_value
*
value
);
int
caosdb_entity_parent_set_id
(
caosdb_entity_parent
*
parent
,
const
char
*
id
);
int
caosdb_entity_parent_set_id
(
caosdb_entity_parent
*
parent
,
const
char
*
id
);
int
caosdb_entity_parent_set_name
(
caosdb_entity_parent
*
parent
,
const
char
*
name
);
int
caosdb_entity_parent_set_name
(
caosdb_entity_parent
*
parent
,
const
char
*
name
);
// TODO(fspreck) setters for datatype
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
This diff is collapsed.
Click to expand it.
src/caosdb/entity.cpp
+
2
−
4
View file @
e341dc88
...
@@ -109,8 +109,7 @@ auto Property::SetImportance(Importance importance) -> void {
...
@@ -109,8 +109,7 @@ auto Property::SetImportance(Importance importance) -> void {
auto
Property
::
SetValue
(
const
Value
&
value
)
->
StatusCode
{
return
this
->
value
.
CopyFrom
(
value
);
}
auto
Property
::
SetValue
(
const
Value
&
value
)
->
StatusCode
{
return
this
->
value
.
CopyFrom
(
value
);
}
// auto Property::SetValue(const AbstractValue &value) -> StatusCode { return
auto
Property
::
SetValue
(
const
AbstractValue
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
// SetValue(Value(value)); }
auto
Property
::
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
auto
Property
::
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
...
@@ -206,8 +205,7 @@ auto Entity::SetValue(const Value &value) -> StatusCode {
...
@@ -206,8 +205,7 @@ auto Entity::SetValue(const Value &value) -> StatusCode {
return
this
->
value
.
CopyFrom
(
value
);
return
this
->
value
.
CopyFrom
(
value
);
}
}
// auto Entity::SetValue(const AbstractValue &value) -> StatusCode { return SetValue(Value(value));
auto
Entity
::
SetValue
(
const
AbstractValue
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
// }
auto
Entity
::
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
auto
Entity
::
SetValue
(
const
std
::
string
&
value
)
->
StatusCode
{
return
SetValue
(
Value
(
value
));
}
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
36
−
49
View file @
e341dc88
...
@@ -1143,31 +1143,25 @@ CAOSDB_ENTITY_SET(local_path, local_path,
...
@@ -1143,31 +1143,25 @@ CAOSDB_ENTITY_SET(local_path, local_path,
CAOSDB_ENTITY_SET
(
file_path
,
file_path
,
wrapped_entity
->
SetFilePath
(
std
::
string
(
file_path
));)
CAOSDB_ENTITY_SET
(
file_path
,
file_path
,
wrapped_entity
->
SetFilePath
(
std
::
string
(
file_path
));)
CAOSDB_ENTITY_SET
(
description
,
description
,
CAOSDB_ENTITY_SET
(
description
,
description
,
wrapped_entity
->
SetDescription
(
std
::
string
(
description
));)
wrapped_entity
->
SetDescription
(
std
::
string
(
description
));)
// TODO(fspreck)
// ERROR_RETURN_CODE(GENERIC_ERROR,
// int caosdb_entity_entity_set_datatype(caosdb_entity_entity *entity,
// const char *datatype, const bool is_ref,
// const bool is_list),
// {
// auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
// if (is_ref) {
// // Refernce datatype with name of reference
// wrapped_entity->SetDataType(std::string(datatype), is_list);
// return 0;
// } else {
// // Atomic datatype so get from enum
// try {
// auto enum_value =
// ENUM_VALUE_FROM_NAME(std::string(datatype), AtomicDataType);
// wrapped_entity->SetDataType(enum_value, is_list);
// return 0;
// } catch (const std::out_of_range &exc) {
// caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what());
// return caosdb::StatusCode::ENUM_MAPPING_ERROR;
// }
// }
// })
CAOSDB_ENTITY_SET
(
unit
,
unit
,
wrapped_entity
->
SetUnit
(
std
::
string
(
unit
));)
CAOSDB_ENTITY_SET
(
unit
,
unit
,
wrapped_entity
->
SetUnit
(
std
::
string
(
unit
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_datatype
(
caosdb_entity_entity
*
entity
,
caosdb_entity_datatype
*
datatype
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
*
wrapped_datatype
=
WRAPPED_DATATYPE_CAST
(
datatype
);
return
wrapped_entity
->
SetDataType
(
*
wrapped_datatype
);
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_set_value
(
caosdb_entity_entity
*
entity
,
caosdb_entity_value
*
value
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
*
wrapped_value
=
WRAPPED_VALUE_CAST
(
value
);
return
wrapped_entity
->
SetValue
(
*
wrapped_value
);
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
int
caosdb_entity_entity_append_parent
(
caosdb_entity_entity
*
entity
,
...
@@ -1214,31 +1208,24 @@ CAOSDB_PARENT_SET(name, name, wrapped_parent->SetName(std::string(name));)
...
@@ -1214,31 +1208,24 @@ CAOSDB_PARENT_SET(name, name, wrapped_parent->SetName(std::string(name));)
CAOSDB_PROPERTY_SET
(
name
,
name
,
wrapped_property
->
SetName
(
std
::
string
(
name
));)
CAOSDB_PROPERTY_SET
(
name
,
name
,
wrapped_property
->
SetName
(
std
::
string
(
name
));)
CAOSDB_PROPERTY_SET
(
id
,
id
,
wrapped_property
->
SetId
(
std
::
string
(
id
));)
CAOSDB_PROPERTY_SET
(
id
,
id
,
wrapped_property
->
SetId
(
std
::
string
(
id
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_datatype
(
caosdb_entity_property
*
property
,
caosdb_entity_datatype
*
datatype
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
*
wrapped_datatype
=
WRAPPED_DATATYPE_CAST
(
datatype
);
// TODO(fspreck)
return
wrapped_property
->
SetDataType
(
*
wrapped_datatype
);
// ERROR_RETURN_CODE(GENERIC_ERROR,
})
// int caosdb_entity_property_set_datatype(caosdb_entity_property *property,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
// const char *datatype, const bool
int
caosdb_entity_property_set_value
(
caosdb_entity_property
*
property
,
// is_ref, const bool is_list),
caosdb_entity_value
*
value
),
// {
{
// auto *wrapped_property = WRAPPED_PROPERTY_CAST(property);
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
// if (is_ref) {
auto
*
wrapped_value
=
WRAPPED_VALUE_CAST
(
value
);
// // Refernce datatype with name of reference
// wrapped_property->SetDataType(std::string(datatype), is_list);
return
wrapped_property
->
SetValue
(
*
wrapped_value
);
// return 0;
})
// } else {
// // Atomic datatype so get from enum
// try {
// auto enum_value =
// ENUM_VALUE_FROM_NAME(std::string(datatype), AtomicDataType);
// wrapped_property->SetDataType(enum_value, is_list);
// return 0;
// } catch (const std::out_of_range &exc) {
// caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what());
// return caosdb::StatusCode::ENUM_MAPPING_ERROR;
// }
// }
// })
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
property
,
int
caosdb_entity_property_set_importance
(
caosdb_entity_property
*
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