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
d5367643
Commit
d5367643
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DRAFT: Fill property class
parent
705e09d0
No related branches found
No related tags found
1 merge request
!4
ENH: Allow insertion and deletion of single entities
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/caosdb/entity.h
+57
-1
57 additions, 1 deletion
include/caosdb/entity.h
src/caosdb/entity.cpp
+59
-0
59 additions, 0 deletions
src/caosdb/entity.cpp
with
116 additions
and
1 deletion
include/caosdb/entity.h
+
57
−
1
View file @
d5367643
...
...
@@ -36,6 +36,7 @@
namespace
caosdb
::
entity
{
using
caosdb
::
entity
::
v1alpha1
::
IdResponse
;
using
ProtoParent
=
caosdb
::
entity
::
v1alpha1
::
Parent
;
using
ProtoProperty
=
caosdb
::
entity
::
v1alpha1
::
Property
;
using
ProtoEntity
=
caosdb
::
entity
::
v1alpha1
::
Entity
;
/**
...
...
@@ -246,14 +247,35 @@ class Property {
public:
explicit
inline
Property
(
caosdb
::
entity
::
v1alpha1
::
Property
*
wrapped
)
:
wrapped
(
wrapped
){};
Property
();
// TODO(fspreck) All of these methods need implementations.
/**
* Return the id of this property
*/
[[
nodiscard
]]
auto
GetId
()
const
->
const
std
::
string
&
;
/**
* Return the name of this property
*/
[[
nodiscard
]]
auto
GetName
()
const
->
const
std
::
string
&
;
/**
* Return the description of this property
*/
[[
nodiscard
]]
auto
GetDescription
()
const
->
const
std
::
string
&
;
/**
* Return the importance of this property
*/
[[
nodiscard
]]
auto
GetImportance
()
const
->
const
std
::
string
&
;
/**
* Return the value of this property
*/
[[
nodiscard
]]
auto
GetValue
()
const
->
const
std
::
string
&
;
/**
* Return the unit of this property
*/
[[
nodiscard
]]
auto
GetUnit
()
const
->
const
std
::
string
&
;
/**
* Return the datatype of this property
*/
[[
nodiscard
]]
auto
GetDatatype
()
const
->
const
std
::
string
&
;
// TODO(fspreck) Implement these when we have decided how to attach
// messages to properties.
...
...
@@ -261,17 +283,51 @@ public:
// [[nodiscard]] auto GetWarnings() const -> const Messages &;
// [[nodiscard]] auto GetInfos() const -> const Messages &;
/**
* Set the id of this property.
*/
auto
SetId
(
const
std
::
string
&
id
)
->
void
;
/**
* Set the name of this property.
*/
auto
SetName
(
const
std
::
string
&
name
)
->
void
;
/**
* Set the importance of this property.
*/
auto
SetImportance
(
const
std
::
string
&
importance
)
->
void
;
/**
* Set the value of this property.
*/
auto
SetValue
(
const
std
::
string
&
value
)
->
void
;
/**
* Set the unit of this property.
*/
auto
SetUnit
(
const
std
::
string
&
unit
)
->
void
;
/**
* Set the datatype of this property.
*/
auto
SetDatatype
(
const
std
::
string
&
datatype
)
->
void
;
/**
* Return a json string representing this property.
*
* This is intended for debugging
*/
inline
auto
ToString
()
const
->
const
std
::
string
{
google
::
protobuf
::
util
::
JsonOptions
options
;
std
::
string
out
;
google
::
protobuf
::
util
::
MessageToJsonString
(
*
(
this
->
wrapped
),
&
out
,
options
);
return
out
;
}
friend
class
Entity
;
friend
class
Properties
;
private
:
static
auto
CreateProtoProperty
()
->
ProtoProperty
*
;
caosdb
::
entity
::
v1alpha1
::
Property
*
wrapped
;
};
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/entity.cpp
+
59
−
0
View file @
d5367643
...
...
@@ -25,6 +25,7 @@
namespace
caosdb
::
entity
{
using
caosdb
::
entity
::
v1alpha1
::
IdResponse
;
using
ProtoParent
=
caosdb
::
entity
::
v1alpha1
::
Parent
;
using
ProtoProperty
=
caosdb
::
entity
::
v1alpha1
::
Property
;
using
ProtoEntity
=
caosdb
::
entity
::
v1alpha1
::
Entity
;
using
caosdb
::
utility
::
get_arena
;
...
...
@@ -65,6 +66,64 @@ auto Parents::Append(const Parent &parent) -> void {
parent
.
wrapped
=
destination
;
}
Property
::
Property
()
:
wrapped
(
Property
::
CreateProtoProperty
())
{}
auto
Property
::
CreateProtoProperty
()
->
ProtoProperty
*
{
return
google
::
protobuf
::
Arena
::
CreateMessage
<
ProtoProperty
>
(
get_arena
());
}
[[
nodiscard
]]
auto
Property
::
GetId
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
id
();
}
[[
nodiscard
]]
auto
Property
::
GetName
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
name
();
}
[[
nodiscard
]]
auto
Property
::
GetDescription
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
description
();
}
[[
nodiscard
]]
auto
Property
::
GetImportance
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
importance
();
}
[[
nodiscard
]]
auto
Property
::
GetValue
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
value
();
}
[[
nodiscard
]]
auto
Property
::
GetUnit
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
unit
();
}
[[
nodiscard
]]
auto
Property
::
GetDatatype
()
const
->
const
std
::
string
&
{
return
this
->
wrapped
->
datatype
();
}
auto
Property
::
SetId
(
const
std
::
string
&
id
)
->
void
{
this
->
wrapped
->
set_id
(
id
);
}
auto
Property
::
SetName
(
const
std
::
string
&
name
)
->
void
{
this
->
wrapped
->
set_name
(
name
);
}
auto
Property
::
SetImportance
(
const
std
::
string
&
importance
)
->
void
{
this
->
wrapped
->
set_importance
(
importance
);
}
auto
Property
::
SetValue
(
const
std
::
string
&
value
)
->
void
{
this
->
wrapped
->
set_value
(
value
);
}
auto
Property
::
SetUnit
(
const
std
::
string
&
unit
)
->
void
{
this
->
wrapped
->
set_unit
(
unit
);
}
auto
Property
::
SetDatatype
(
const
std
::
string
&
datatype
)
->
void
{
this
->
wrapped
->
set_datatype
(
datatype
);
}
[[
nodiscard
]]
auto
Entity
::
GetParents
()
const
->
const
Parents
&
{
return
parents
;
}
...
...
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