From 481b031cf1cf97359b6cea14256dd7862ca1f134 Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Tue, 10 Aug 2021 12:05:53 +0200
Subject: [PATCH] DRAFT: Begin implementation of entities

---
 src/ccaosdb.cpp       | 26 ++++++++++++++++++++++++++
 test/test_ccaosdb.cpp | 10 ++++++++++
 2 files changed, 36 insertions(+)

diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp
index 023bea0..8a17869 100644
--- a/src/ccaosdb.cpp
+++ b/src/ccaosdb.cpp
@@ -375,7 +375,33 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
                         result_set->wrapped_result_set);
                     auto requested_entity = wrapped_result_set->At(index);
                     entity->wrapped_entity = (void *)(&requested_entity);
+                    // TODO(fspreck) explicit pointers to id, name, ...
+                    return 0;
+                  })
 
+ERROR_RETURN_CODE(GENERIC_ERROR,
+                  int caosdb_transaction_result_set_size(
+                    caosdb_transaction_result_set *result_set, int *out),
+                  {
+                    auto *wrapped_result_set =
+                      static_cast<caosdb::transaction::MultiResultSet *>(
+                        result_set->wrapped_result_set);
+                    int size(wrapped_result_set->Size());
+                    *out = size;
+                    return 0;
+                  })
+
+ERROR_RETURN_CODE(GENERIC_ERROR,
+                  int caosdb_entity_create_entity(caosdb_entity_entity *out), {
+                    auto entity = caosdb::entity::Entity();
+                    out->wrapped_entity = (void *)(&entity);
+                    return 0;
+                  })
+
+ERROR_RETURN_CODE(GENERIC_ERROR,
+                  int caosdb_entity_delete_entity(caosdb_entity_entity *out), {
+                    delete static_cast<caosdb::entity::Entity *>(
+                      out->wrapped_entity);
                     return 0;
                   })
 }
diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp
index 70ee14d..1493525 100644
--- a/test/test_ccaosdb.cpp
+++ b/test/test_ccaosdb.cpp
@@ -133,3 +133,13 @@ TEST_F(test_ccaosdb, test_query) {
   return_code = caosdb_transaction_delete_transaction(&transaction);
   EXPECT_EQ(return_code, 0);
 }
+
+TEST_F(test_ccaosdb, test_entity) {
+  caosdb_entity_entity entity;
+
+  int return_code(caosdb_entity_create_entity(&entity));
+  EXPECT_EQ(return_code, 0);
+
+  return_code = caosdb_entity_delete_entity(&entity);
+  EXPECT_EQ(return_code, 0);
+}
-- 
GitLab