Skip to content
Snippets Groups Projects
Commit e341dc88 authored by florian's avatar florian
Browse files

ENH: Re-implement set_value and set_datatype

parent 9bae96e0
Branches
Tags
1 merge request!24API: Introduce value and datatype structs to Extern C
...@@ -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;
......
...@@ -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
...@@ -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)); }
......
...@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment