-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spatial conclusion #63
Changes from 66 commits
ca78e62
cbbe37b
d9b28f6
aa1d520
a624097
968dd6e
4a25848
c9306ee
2b4fcc5
646620b
5f837b5
ce85470
183aeed
7ed1837
593402e
796867f
17b7f3b
a6b2f98
9619bd6
eba14d7
d27e690
5a42d2c
747838b
6c34475
dfb98c9
3b170a5
5d6a513
a50f627
565de92
c56fe03
d62c201
7ce6435
273ccd2
74f66ea
6b2e5bd
5539897
600f577
e3122d8
272d61b
db9256a
3797604
f9c1e60
743f31c
073e335
e5cf03e
c26e1c0
0d4c7b5
e8363c8
4b873f5
b60d0b3
cc7bc18
af716a0
432cfe1
5b191e1
28e89b3
f0c0dc5
ff818ef
9444e99
8dc12fb
a2c79f6
ff42d68
fb4328d
fd09057
0ccb17d
b5e47bc
6be6b22
617adf4
cf1bee1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef SEMPR_ENTITY_GEOMETRICOBJECT_H_ | ||
#define SEMPR_ENTITY_GEOMETRICOBJECT_H_ | ||
|
||
#include <sempr/entity/Entity.hpp> | ||
#include <sempr/entity/spatial/Geometry.hpp> | ||
#include <sempr/entity/SemanticEntity.hpp> | ||
#include <sempr/core/RDF.hpp> | ||
#include <odb/core.hxx> | ||
|
||
#include <string> | ||
|
||
namespace sempr { namespace entity { | ||
|
||
|
||
#pragma db object | ||
class GeometricObject : public SemanticEntity { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some comments would be nice. What is the purpose of this class? |
||
SEMPR_ENTITY | ||
public: | ||
using Ptr = std::shared_ptr<GeometricObject>; | ||
|
||
GeometricObject(); | ||
GeometricObject(bool temporary); | ||
GeometricObject(const core::IDGenBase*, bool temporary = false); | ||
|
||
const Geometry::Ptr geometry() const { return geometry_; } | ||
void geometry(const Geometry::Ptr geometry); | ||
|
||
const std::string type() const { return type_; } | ||
void type(const std::string& type); | ||
|
||
void registerProperty(const std::string& predicate, const std::string& object); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A method of the same name (but templated) already exists in template <class T> void registerProperty(const std::string& predicate, T& property) { /* ... */ }
// ... and derivations ... These methods are used to register member variables and make them visible in the rdf. |
||
|
||
// Gives all related object by a known predicate. (could be empty for all related objects) | ||
std::set<std::string> related(const std::string& predicate = ""); | ||
|
||
private: | ||
friend class odb::access; | ||
|
||
Geometry::Ptr geometry_; | ||
|
||
std::string type_; | ||
}; | ||
|
||
}} | ||
|
||
|
||
#endif /* end of include guard: SEMPR_ENTITY_GEOMETRICOBJECT_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,8 @@ | |
#define SEMPR_ENTITY_RDFVECTOR_H_ | ||
|
||
#include <odb/core.hxx> | ||
#include <sempr/core/RDF.hpp> | ||
#include <sempr/entity/Entity.hpp> | ||
#include <sempr/entity/Triple.hpp> | ||
#include <sempr/entity/RDFEntity.hpp> | ||
|
||
#include <sempr/core/EntityEvent.hpp> | ||
#include <sempr/entity/RDFEntity.hpp> | ||
|
||
#include <vector> | ||
|
||
|
@@ -26,20 +22,19 @@ class RDFVectorIterator : public TripleIterator { | |
bool operator == (const TripleIterator& other) const override; | ||
}; | ||
|
||
|
||
|
||
#pragma db object | ||
class RDFVector : public RDFEntity { | ||
SEMPR_ENTITY | ||
public: | ||
using Ptr = std::shared_ptr<RDFVector>; | ||
RDFVector(); | ||
RDFVector(const core::IDGenBase*); | ||
RDFVector(bool temporary); | ||
RDFVector(const core::IDGenBase*, bool temporary = false); | ||
virtual ~RDFVector(){} | ||
|
||
void getTriples(std::vector<Triple>& triples) const; | ||
const Triple& getTripleAt(const size_t index); | ||
bool addTriple(const Triple& triple); | ||
bool addTriple(const Triple& triple, bool replace = false); // if replace than an equal triple will be removed before, otherwise there a multiple entries possible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the meaning of "replacing" an equivalent Triple? If there's a way to see a difference they were not equal. So tl;dr: I'd suggest renaming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, maybe the default should be to not allow duplicates? I don't see any use case for adding the same fact multiple times. |
||
bool removeTriple(const Triple& triple); | ||
void removeTripleAt(const size_t index); | ||
void clear(); | ||
|
@@ -48,11 +43,15 @@ class RDFVector : public RDFEntity { | |
TripleIteratorWrapper begin() const override; | ||
TripleIteratorWrapper end() const override; | ||
|
||
bool validity(const Triple& triple) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this check? Does it depend on the RDFVector, or should this be moved to the Triple-class? |
||
|
||
protected: | ||
friend class odb::access; | ||
std::vector<Triple> triples_; | ||
}; | ||
|
||
|
||
|
||
}} | ||
|
||
#endif /* end of include guard: SEMPR_ENTITY_RDFVECTOR_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,8 @@ class RegisteredPropertyBase { | |
std::string predicate() const; | ||
virtual std::string object() const = 0; | ||
virtual bool isValid() const = 0; | ||
|
||
bool operator==(const RegisteredPropertyBase& other) const; | ||
}; | ||
|
||
/** | ||
|
@@ -234,7 +236,7 @@ class RegisteredProperty : public RegisteredPropertyBase { | |
|
||
public: | ||
MyEntity() { | ||
registerPropetry("<http://some.ontology/somePredicate>", myInt_); | ||
registerProperty("<http://some.ontology/somePredicate>", myInt_); | ||
registerProperty("<http://some.ontology/someSubject>", "<http://some.ontology/somePredicate>", myFloat_); | ||
} | ||
}; | ||
|
@@ -250,9 +252,13 @@ class SemanticEntity : public RDFEntity { | |
#pragma db transient | ||
std::vector<RegisteredPropertyBase*> properties_; | ||
|
||
std::vector<RegisteredPropertyBase*>::iterator findProperty(const RegisteredPropertyBase& prop); | ||
|
||
protected: | ||
SemanticEntity(const core::IDGenBase*); | ||
SemanticEntity(); | ||
SemanticEntity(bool temporary); | ||
SemanticEntity(const core::IDGenBase*, bool temporary = false); | ||
|
||
|
||
/** | ||
Registers the property at this semantic entity. This will provide the RDF-Triple: | ||
|
@@ -268,6 +274,13 @@ class SemanticEntity : public RDFEntity { | |
properties_.push_back(rprop); | ||
} | ||
|
||
template <class T> | ||
void removeProperty(const std::string& predicate, T& property) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't |
||
{ | ||
auto prop = findProperty(RegisteredProperty<T>(predicate, property)); | ||
properties_.erase(prop); | ||
} | ||
|
||
template <class T> | ||
void registerPropertyPlain(const std::string& predicate, T& property) | ||
{ | ||
|
@@ -276,20 +289,33 @@ class SemanticEntity : public RDFEntity { | |
properties_.push_back(rprop); | ||
} | ||
|
||
template <class T> | ||
void removePropertyPlain(const std::string& predicate, T& property) | ||
{ | ||
auto prop = findProperty(RegisteredProperty<T, sempr::rdf::traits::plain_string>(predicate, property)); | ||
properties_.erase(prop); | ||
} | ||
|
||
/** | ||
Registers the property at this semantic entity. This allows setting both subject and | ||
predicate of the resulting triple. | ||
|
||
Assumes the given property is a member of this SemanticEntity. | ||
*/ | ||
template <class T> | ||
void registerProperty(const std::string& subject, const std::string& predicate, | ||
T& property) | ||
void registerProperty(const std::string& subject, const std::string& predicate, T& property) | ||
{ | ||
RegisteredPropertyBase* rprop = new RegisteredProperty<T>(subject, predicate, property); | ||
properties_.push_back(rprop); | ||
} | ||
|
||
template <class T> | ||
void removeProperty(const std::string& subject, const std::string& predicate, T& property) | ||
{ | ||
auto prop = findProperty(RegisteredProperty<T>(subject, predicate, property)); | ||
properties_.erase(prop); | ||
} | ||
|
||
template <class T> | ||
void registerPropertyPlain(const std::string& subject, const std::string& predicate, T& property) | ||
{ | ||
|
@@ -298,6 +324,13 @@ class SemanticEntity : public RDFEntity { | |
properties_.push_back(rprop); | ||
} | ||
|
||
template <class T> | ||
void removePropertyPlain(const std::string& subject, const std::string& predicate, T& property) | ||
{ | ||
auto prop = findProperty(RegisteredProperty<T, sempr::rdf::traits::plain_string>(subject, predicate, property)); | ||
properties_.erase(prop); | ||
} | ||
|
||
public: | ||
~SemanticEntity(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this line?
const std::string& baseURI();
is already declared through the macro below:Same goes for owl.