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

ENH: ADD enums for datatype, importance, role, and collection

parent 223e231c
No related branches found
No related tags found
1 merge request!13ENH: Use new value and datatype structs
......@@ -29,7 +29,7 @@ export evaluate_return_code,
CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage
# Exports from module Constants
export MIN_CCAOSDB_VERSION
export COLLECTION, DATATYPE, IMPORTANCE, MIN_CCAOSDB_VERSION, ROLE
# Exports from module Utility
export get_ccaosdb_version, get_env_fallback
......
......@@ -23,7 +23,7 @@
module Constants
export MIN_CCAOSDB_VERSION
export COLLECTION, DATATYPE, IMPORTANCE, MIN_CCAOSDB_VERSION, ROLE
"""
The minimum version of CaosDB's cpplib and C interface that is
......@@ -31,4 +31,44 @@ supported by this version of CaosDB.jl.
"""
const MIN_CCAOSDB_VERSION = v"0.0.17"
# enums have to be encapsulated in modules to prevent namespce conflicts, see
# https://bleepcoder.com/julia/413856244/feature-request-getproperty-on-enum-type-to-access-instances
module DATATYPE
@enum _DATATYPE begin
UNSPECIFIED
BOOLEAN
INTEGER
DOUBLE
DATETIME
TEXT
end
end
module COLLECTION
@enum _COLLECTION begin
SCALAR
LIST
end
end
module ROLE
@enum _ROLE begin
UNSPECIFIED
RECORD
RECORD_TYPE
PROPERTY
FILE
end
end
module IMPORTANCE
@enum _IMPORTANCE begin
UNSPECIFIED
OBLIGATORY
RECOMMENDED
SUGGESTED
FIX
end
end
end
......@@ -200,7 +200,7 @@ Struct containing a pointer to the wrapped cpp DataType object. Meant for
internal use only; use `CaosDB.Entity.create_<type>_datatype` to create a
valid _DataType object or use the `set/get_datatype` functions.
"""
mutable struct _DatatType
mutable struct _DataType
wrapped_datatype::Ptr{Cvoid}
_deletable::Bool
......@@ -214,7 +214,7 @@ mutable struct _DatatType
ccall(
(:caosdb_entity_delete_datatype, CaosDB.library_name),
Cint,
(Ref{_DatatType},),
(Ref{_DataType},),
Ref{_DataType}(t),
)
end
......@@ -568,7 +568,7 @@ function create_list_of_reference_datatype(name::AbstractString)
end
function create_value(
value::Union{AbstractString,Number,Bool,Vactor{T}},
value::Union{AbstractString,Number,Bool,Vector{T}},
) where {T<:Union{AbstractString,Number,Bool}}
in_type = typeof(value)
......@@ -643,8 +643,10 @@ function create_value(
)
else
# Should never enter here but treat it just in case
@throw ArgumentError(
"The argument of type $in_type couldn't be converted into a valid CaosDB value object.",
throw(
ArgumentError(
"The argument of type $in_type couldn't be converted into a valid CaosDB value object.",
),
)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment