From e365f6e6426f041438b72c0f62248791ce31ded0 Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Fri, 17 Sep 2021 16:43:12 +0200
Subject: [PATCH] DRAFT: Introduce datatype and value structs

---
 src/Entity.jl | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/src/Entity.jl b/src/Entity.jl
index 9c23a8e..5b04ac2 100644
--- a/src/Entity.jl
+++ b/src/Entity.jl
@@ -195,6 +195,66 @@ mutable struct _Message
     end
 end
 
+"""
+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
+    wrapped_datatype::Ptr{Cvoid}
+    _deletable::Bool
+
+    function _DatatType(managed_by_julia::Bool = false)
+
+        datatype = new()
+        datatype._deletable = false
+
+        if managed_by_julia
+            function f(t)
+                ccall(
+                    (:caosdb_entity_delete_datatype, CaosDB.library_name),
+                    Cint,
+                    (Ref{_DatatType},),
+                    Ref{_DataType}(t),
+                )
+            end
+            finalizer(f, datatype)
+        end
+
+        return datatype
+    end
+end
+
+"""
+Struct containing a pointer to the wrapped cpp AbstractValue object. Meant for
+internal use only; use `CaosDB.Entity.create_value` to create a _Value object or
+use the `set/get_value` functions`.
+"""
+mutable struct _Value
+    wrapped_value::Ptr{Cvoid}
+    _deletable::Bool
+
+    function _Value(managed_by_julia::Bool = false)
+
+        value = new()
+        value._deletable = false
+
+        if managed_by_julia
+            function f(t)
+                ccall(
+                    (:caosdb_entity_delete_value, CaosDB.library_name),
+                    Cint,
+                    (Ref{_Value},),
+                    Ref{_Value}(t),
+                )
+            end
+            finalizer(f, value)
+        end
+
+        return value
+    end
+end
+
 """
     function create_entity(name::AbstractString = "")
 
-- 
GitLab