Skip to content

Commit 6ef46f2

Browse files
Compile fixes
1 parent 2a62b2d commit 6ef46f2

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

include/fields/relation.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Relation {
1818

1919
int getRelationId() const;
2020
void setReversed(Relation* reversed);
21-
Relation* getReverse();
21+
virtual Relation* getReverse();
2222
virtual RelatedObjectIterable* followMany(Obj* fromObj) = 0;
2323
virtual bool testRelation(Obj* fromObj, Obj* toObj) const = 0;
2424
virtual std::string getRelationLabel() const = 0;
@@ -41,10 +41,20 @@ class RelationOne : public Relation {
4141
public:
4242
RelationOne(int relationId, const std::string& relationName);
4343

44-
Obj* followOne(Obj* fromObj) const;
44+
virtual Obj* followOne(Obj* fromObj) const;
4545
RelatedObjectIterable* followMany(Obj* fromObj) override;
4646
bool testRelation(Obj* fromObj, Obj* toObj) const override;
4747
std::string getRelationLabel() const override;
4848
};
4949

50-
#endif // RELATION_H
50+
class RelationSelf : public RelationOne {
51+
public:
52+
RelationSelf(int relationId, const std::string& relationName);
53+
54+
Obj* followOne(Obj* fromObj) const override;
55+
RelatedObjectIterable* followMany(Obj* fromObj) override;
56+
bool testRelation(Obj* fromObj, Obj* toObj) const override;
57+
std::string getRelationLabel() const override;
58+
};
59+
60+
#endif // RELATION_H

include/network/neuron_definition.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#ifndef NETWORK_NEURON_DEFINITION_H
22
#define NETWORK_NEURON_DEFINITION_H
33

4+
#include "fields/relation.h"
5+
#include "fields/type.h"
6+
#include "fields/type_registry.h"
47
#include "network/activation.h"
58
#include "network/model.h"
69
#include "network/neuron.h"
7-
#include "network/relation.h"
8-
#include "network/relation_many.h"
9-
#include "network/relation_self.h"
10-
#include "network/type.h"
11-
#include "network/type_registry.h"
1210

1311
#include <string>
1412
#include <vector>

include/network/node_definition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef NETWORK_NODE_DEFINITION_H
22
#define NETWORK_NODE_DEFINITION_H
33

4+
#include "fields/type_registry.h"
45
#include "network/activation_definition.h"
56
#include "network/neuron_definition.h"
6-
#include "network/type_registry.h"
77

88
class NodeDefinition {
99
public:

src/fields/python_bindings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ PYBIND11_MODULE(aika, m)
3939
py::class_<RelationMany, Relation>(m, "RelationMany")
4040
.def(py::init<int, const std::string&>());
4141

42+
py::class_<RelationSelf, RelationOne>(m, "RelationSelf")
43+
.def(py::init<int, const std::string&>());
44+
4245
py::class_<FieldUpdate>(m, "FieldUpdate")
4346
.def(py::init<ProcessingPhase&, QueueInterceptor*>());
4447

src/fields/relation.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
#include "fields/relation.h"
2+
#include <stdexcept>
33

44

55
Relation::Relation(int relationId, const std::string& relationName)
@@ -51,3 +51,23 @@ bool RelationOne::testRelation(Obj* fromObj, Obj* toObj) const {
5151
std::string RelationOne::getRelationLabel() const {
5252
return relationName + " (One)"; // Append " (One)" to the relation name
5353
}
54+
55+
// RelationSelf implementation
56+
RelationSelf::RelationSelf(int relationId, const std::string& relationName)
57+
: RelationOne(relationId, relationName) {}
58+
59+
Obj* RelationSelf::followOne(Obj* fromObj) const {
60+
return fromObj; // Return the same object
61+
}
62+
63+
RelatedObjectIterable* RelationSelf::followMany(Obj* fromObj) {
64+
return new SingleObjectIterable(fromObj); // Return a singleton iterable with the same object
65+
}
66+
67+
bool RelationSelf::testRelation(Obj* fromObj, Obj* toObj) const {
68+
return fromObj == toObj; // Test if both objects are the same
69+
}
70+
71+
std::string RelationSelf::getRelationLabel() const {
72+
return relationName + " (Self)"; // Append " (Self)" to the relation name
73+
}

0 commit comments

Comments
 (0)