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
75a171cd
Verified
Commit
75a171cd
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-update' into f-query
parents
0628b182
0d3ce44a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
ENH: Support FIND and COUNT queries
Pipeline
#11513
passed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#11525
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/caosdb/transaction.h
+5
-8
5 additions, 8 deletions
include/caosdb/transaction.h
src/caosdb/transaction.cpp
+4
-6
4 additions, 6 deletions
src/caosdb/transaction.cpp
test/test_entity.cpp
+0
-7
0 additions, 7 deletions
test/test_entity.cpp
with
9 additions
and
21 deletions
include/caosdb/transaction.h
+
5
−
8
View file @
75a171cd
...
...
@@ -31,7 +31,6 @@
#include
"caosdb/transaction_status.h"
// for TransactionStatus
#include
"caosdb/status_code.h"
// for StatusCode
#include
"google/protobuf/util/json_util.h"
// for MessageToJsonString, Jso...
#include
<cstddef>
// for size_t
#include
<iterator>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include
<memory>
// for shared_ptr, unique_ptr
...
...
@@ -180,7 +179,7 @@ class ResultSet {
public:
virtual
~
ResultSet
()
=
default
;
[[
nodiscard
]]
virtual
auto
Size
()
const
noexcept
->
size_
t
=
0
;
[[
nodiscard
]]
virtual
auto
Size
()
const
noexcept
->
in
t
=
0
;
[[
nodiscard
]]
virtual
auto
At
(
const
int
index
)
const
->
const
Entity
&
=
0
;
auto
begin
()
const
->
iterator
;
auto
end
()
const
->
iterator
;
...
...
@@ -188,14 +187,14 @@ public:
private:
class
iterator
:
public
std
::
iterator
<
std
::
output_iterator_tag
,
Entity
>
{
public:
explicit
iterator
(
const
ResultSet
*
result_set
,
size_
t
index
=
0
);
explicit
iterator
(
const
ResultSet
*
result_set
,
in
t
index
=
0
);
auto
operator
*
()
const
->
const
Entity
&
;
auto
operator
++
()
->
iterator
&
;
auto
operator
++
(
int
)
->
iterator
;
auto
operator
!=
(
const
iterator
&
rhs
)
const
->
bool
;
private:
size_
t
current_index
=
0
;
in
t
current_index
=
0
;
const
ResultSet
*
result_set
;
};
};
...
...
@@ -210,7 +209,7 @@ class MultiResultSet : public ResultSet {
public:
~
MultiResultSet
()
=
default
;
explicit
MultiResultSet
(
MultiTransactionResponse
*
response
);
[[
nodiscard
]]
inline
auto
Size
()
const
noexcept
->
size_
t
override
{
[[
nodiscard
]]
inline
auto
Size
()
const
noexcept
->
in
t
override
{
return
this
->
entities
.
size
();
}
[[
nodiscard
]]
inline
auto
At
(
const
int
index
)
const
...
...
@@ -234,9 +233,7 @@ public:
explicit
inline
UniqueResult
(
IdResponse
*
idResponse
)
:
entity
(
new
Entity
(
idResponse
)){};
[[
nodiscard
]]
auto
GetEntity
()
const
->
const
Entity
&
;
[[
nodiscard
]]
inline
auto
Size
()
const
noexcept
->
size_t
override
{
return
1
;
}
[[
nodiscard
]]
inline
auto
Size
()
const
noexcept
->
int
override
{
return
1
;
}
[[
nodiscard
]]
inline
auto
At
(
const
int
index
)
const
->
const
Entity
&
override
{
if
(
index
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/transaction.cpp
+
4
−
6
View file @
75a171cd
...
...
@@ -75,7 +75,8 @@ auto get_status_description(int code) -> const std::string & {
"The Transaction has a transaction type which does not allow the "
"attempted action."
},
{
StatusCode
::
ORIGINAL_ENTITY_MISSING_ID
,
"The attempt to update this entity failed because this entity does have "
"The attempt to update this entity failed because this entity does not "
"have "
"an id. This is the case when you did not retrieve it before applying any "
"changes and instantiated the Entity class explicitely."
},
{
StatusCode
::
UNSUPPORTED_FEATURE
,
...
...
@@ -100,14 +101,11 @@ using grpc::ClientAsyncResponseReader;
using
ProtoEntity
=
caosdb
::
entity
::
v1alpha1
::
Entity
;
using
grpc
::
CompletionQueue
;
ResultSet
::
iterator
::
iterator
(
const
ResultSet
*
result_set_param
,
size_
t
index
)
ResultSet
::
iterator
::
iterator
(
const
ResultSet
*
result_set_param
,
in
t
index
)
:
current_index
(
index
),
result_set
(
result_set_param
)
{}
auto
ResultSet
::
iterator
::
operator
*
()
const
->
const
Entity
&
{
// TODO(tf) clang warns about a bugprone conversion from unsigned
// size_t to signed int, i.e., the `index` of ResultSet::At. Should
// we make this unsigned as well?
return
this
->
result_set
->
At
(
current_index
);
// NOLINT
return
this
->
result_set
->
At
(
current_index
);
}
auto
ResultSet
::
iterator
::
operator
++
()
->
ResultSet
::
iterator
&
{
...
...
This diff is collapsed.
Click to expand it.
test/test_entity.cpp
+
0
−
7
View file @
75a171cd
...
...
@@ -30,9 +30,7 @@
#include
"gtest/gtest-message.h"
// for Message
#include
"gtest/gtest-test-part.h"
// for TestPartResult, Sui...
#include
"gtest/gtest_pred_impl.h"
// for Test, EXPECT_EQ
#include
<iostream>
// for endl, basic_ostream
#include
<memory>
// for allocator, shared_ptr
#include
<string>
// for operator<<
namespace
caosdb
::
entity
{
using
caosdb
::
entity
::
v1alpha1
::
IdResponse
;
...
...
@@ -187,7 +185,6 @@ TEST(test_entity, test_insert_with_parent) {
transaction
.
InsertEntity
(
&
entity
);
std
::
cout
<<
entity
.
ToString
()
<<
std
::
endl
;
EXPECT_EQ
(
entity
.
GetName
(),
"entity_name"
);
EXPECT_EQ
(
entity
.
GetParents
().
Size
(),
1
);
auto
inserted_parent
=
entity
.
GetParents
().
At
(
0
);
...
...
@@ -251,18 +248,14 @@ TEST(test_entity, test_from_id_response) {
info
->
set_description
(
"info_desc"
);
info
->
set_code
(
MessageCode
::
UNSPECIFIED
);
std
::
cout
<<
entity
.
ToString
()
<<
std
::
endl
;
Entity
other_ent
(
&
idr_warnings_and_infos
);
std
::
cout
<<
entity
.
ToString
()
<<
std
::
endl
;
EXPECT_EQ
(
other_ent
.
GetId
(),
"other_entity_id"
);
std
::
cout
<<
entity
.
ToString
()
<<
std
::
endl
;
EXPECT_EQ
(
other_ent
.
GetWarnings
().
Size
(),
1
);
EXPECT_TRUE
(
other_ent
.
HasWarnings
());
EXPECT_EQ
(
other_ent
.
GetWarnings
().
At
(
0
).
GetDescription
(),
"warning_desc"
);
EXPECT_EQ
(
other_ent
.
GetWarnings
().
At
(
0
).
GetCode
(),
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
std
::
cout
<<
entity
.
ToString
()
<<
std
::
endl
;
EXPECT_EQ
(
other_ent
.
GetInfos
().
Size
(),
1
);
EXPECT_EQ
(
other_ent
.
GetInfos
().
At
(
0
).
GetDescription
(),
"info_desc"
);
EXPECT_EQ
(
other_ent
.
GetInfos
().
At
(
0
).
GetCode
(),
MessageCode
::
UNSPECIFIED
);
...
...
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