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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
ffb23674
Commit
ffb23674
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DRAFT: Begin setters and getters for entities
parent
63da43ad
No related branches found
No related tags found
3 merge requests
!12
F consolidation
,
!9
Draft: API: remove UniqueResult, lower-case at, size for ResultSet
,
!8
ENH: Add retrieval and queries to Extern C interface
Pipeline
#11671
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ccaosdb.cpp
+35
-3
35 additions, 3 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+14
-1
14 additions, 1 deletion
test/test_ccaosdb.cpp
with
49 additions
and
4 deletions
src/ccaosdb.cpp
+
35
−
3
View file @
ffb23674
...
...
@@ -50,6 +50,34 @@ extern "C" {
} \
}
/**
* Macro for entity getters
*/
#define CAOSDB_ENTITY_GET(element, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, \
char *out), \
{ \
auto *wrapped_entity = \
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); \
body_part return 0; \
})
/**
* Macro for entity setters
*/
#define CAOSDB_ENTITY_SET(element, value, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_entity_set_##element(caosdb_entity_entity *entity, \
const char *value), \
{ \
auto *wrapped_entity = \
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); \
body_part return 0; \
})
int
caosdb_constants_LIBCAOSDB_VERSION_MAJOR
()
{
return
caosdb
::
LIBCAOSDB_VERSION_MAJOR
;
}
...
...
@@ -334,7 +362,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
static_cast
<
caosdb
::
transaction
::
Transaction
*>
(
transaction
->
wrapped_transaction
);
wrapped_transaction
->
ExecuteAsynchronously
();
auto
status
=
wrapped_transaction
->
WaitForIt
();
auto
status
=
wrapped_transaction
->
WaitForIt
();
return
status
.
GetCode
();
})
...
...
@@ -394,8 +422,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_create_entity
(
caosdb_entity_entity
*
out
),
{
auto
entity
=
caosdb
::
entity
::
Entity
();
out
->
wrapped_entity
=
(
void
*
)(
&
entity
);
out
->
wrapped_entity
=
new
caosdb
::
entity
::
Entity
();
return
0
;
})
...
...
@@ -405,4 +432,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
out
->
wrapped_entity
);
return
0
;
})
CAOSDB_ENTITY_GET
(
id
,
strcpy
(
out
,
wrapped_entity
->
GetId
().
c_str
());)
CAOSDB_ENTITY_GET
(
name
,
strcpy
(
out
,
wrapped_entity
->
GetName
().
c_str
());)
CAOSDB_ENTITY_SET
(
name
,
name
,
wrapped_entity
->
SetName
(
std
::
string
(
name
));)
}
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
14
−
1
View file @
ffb23674
...
...
@@ -24,10 +24,12 @@
#include
"caosdb/status_code.h"
// for StatusCode
#include
"caosdb_test_utility.h"
// for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
#include
"ccaosdb.h"
// for caosdb_utility_get_env_var
#include
<cstring>
// for strcmp
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestFactoryImpl
#include
<gtest/gtest_pred_impl.h>
// for Test, TestInfo, EXPECT_EQ, TEST
#include
<string>
// for allocator
#include
<iostream>
#include
<string>
// for allocator
class
test_ccaosdb
:
public
::
testing
::
Test
{
protected:
...
...
@@ -99,10 +101,12 @@ TEST_F(test_ccaosdb, test_execute_transaction) {
}
TEST_F
(
test_ccaosdb
,
test_multi_retrieve
)
{
std
::
cout
<<
"Entering test_multi_retrieve ..."
<<
std
::
endl
;
caosdb_connection_connection
connection
;
caosdb_connection_connection_manager_get_connection
(
&
connection
,
"local-caosdb-admin"
);
std
::
cout
<<
"Creating transaction"
<<
std
::
endl
;
caosdb_transaction_transaction
multi_transaction
;
caosdb_connection_connection_create_transaction
(
&
connection
,
&
multi_transaction
);
...
...
@@ -110,10 +114,12 @@ TEST_F(test_ccaosdb, test_multi_retrieve) {
// We explicitely want to define a C-style array here, so we disable
// linting
const
char
*
ids
[]
=
{
"id1"
,
"id2"
,
"id3"
};
// NOLINT
std
::
cout
<<
"Adding mutli retrieval ..."
<<
std
::
endl
;
int
return_code
(
caosdb_transaction_transaction_retrieve_by_ids
(
&
multi_transaction
,
ids
));
EXPECT_EQ
(
return_code
,
caosdb
::
StatusCode
::
GO_ON
);
std
::
cout
<<
"Deleting transaction ..."
<<
std
::
endl
;
return_code
=
caosdb_transaction_delete_transaction
(
&
multi_transaction
);
EXPECT_EQ
(
return_code
,
0
);
}
...
...
@@ -140,6 +146,13 @@ TEST_F(test_ccaosdb, test_entity) {
int
return_code
(
caosdb_entity_create_entity
(
&
entity
));
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_entity_set_name
(
&
entity
,
"some_name"
);
EXPECT_EQ
(
return_code
,
0
);
char
out
[
255
]
=
{
"a"
};
// NOLINT
return_code
=
caosdb_entity_entity_get_name
(
&
entity
,
out
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
out
,
"some_name"
),
0
);
return_code
=
caosdb_entity_delete_entity
(
&
entity
);
EXPECT_EQ
(
return_code
,
0
);
}
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