Skip to content

Commit 3e1002d

Browse files
1. Updated InhibitoryActivation class methods:
- Made getOutputLink(int bsId) const-qualified - Made getInputLinks() and getOutputLinks() const-qualified - Added proper const qualifiers to getCorrespondingInputLink and getCorrespondingOutputLink 2. Fixed Link class methods: - Made getSynapse(), getInput(), getOutput(), isCausal(), and getDocument() const-qualified - Updated followSingleRelation to be const-qualified 3. Fixed Type and Obj classes: - Made isInstanceOf, toKeyString, getFieldValue, and getFieldUpdatedValue const-qualified - Fixed getFlattenedTypeInputSide and getFlattenedTypeOutputSide to be const
1 parent a2cfdd8 commit 3e1002d

25 files changed

+168
-151
lines changed

include/fields/obj.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ class Obj : public QueueProvider {
1919
void initFields();
2020
Type* getType() const;
2121
virtual RelatedObjectIterable* followManyRelation(Relation* rel) const = 0;
22-
virtual Obj* followSingleRelation(const Relation* rel) = 0;
23-
bool isInstanceOf(Type* t);
22+
virtual Obj* followSingleRelation(const Relation* rel) const = 0;
23+
bool isInstanceOf(Type* t) const;
2424
Field* getFieldInput(FieldDefinition* fd) const;
2525
Field* getFieldOutput(FieldDefinition* fd) const;
2626
Field* getOrCreateFieldInput(FieldDefinition* fd);
2727
Obj& setFieldValue(FieldDefinition* fd, double v);
28-
double getFieldValue(FieldDefinition* fd);
29-
double getFieldUpdatedValue(FieldDefinition* fd);
30-
Field** getFields();
28+
double getFieldValue(FieldDefinition* fd) const;
29+
double getFieldUpdatedValue(FieldDefinition* fd) const;
30+
Field** getFields() const;
3131

32-
std::string toKeyString();
32+
std::string toKeyString() const;
3333
std::string toString() const;
3434
std::string getFieldAsString(FieldDefinition* fd) const;
3535
};

include/fields/test_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestObject : public Obj {
1616
explicit TestObject(TestType* type);
1717

1818
// Follow a single relation
19-
Obj* followSingleRelation(const Relation* rel) override;
19+
Obj* followSingleRelation(const Relation* rel) const override;
2020

2121
// Get related test object
2222
TestObject* getRelatedTestObject() const;

include/fields/type.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class Type {
4949
std::set<Type*> collectTypes();
5050
void collectTypesRecursiveStep(std::set<Type*>& sortedTypes);
5151
int getDepth() const;
52-
bool isInstanceOf(Obj* obj);
53-
bool isInstanceOf(Type* type);
52+
bool isInstanceOf(Obj* obj) const;
53+
bool isInstanceOf(Type* type) const;
5454
std::string getName() const;
55-
TypeRegistry* getTypeRegistry();
56-
FlattenedType* getFlattenedTypeInputSide();
57-
FlattenedType* getFlattenedTypeOutputSide();
55+
TypeRegistry* getTypeRegistry() const;
56+
FlattenedType* getFlattenedTypeInputSide() const;
57+
FlattenedType* getFlattenedTypeOutputSide() const;
5858
void setFieldDefinition(FieldDefinition* fieldDef);
5959
std::set<FieldDefinition*> getFieldDefinitions() const;
6060
Type& addParent(Type* p);

include/network/activation.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,48 @@ class Activation : public Obj, public Element, public ModelProvider {
2828

2929
// Implementation of Obj virtual methods
3030
RelatedObjectIterable* followManyRelation(Relation* rel) const override;
31-
Obj* followSingleRelation(const Relation* rel) override;
31+
Obj* followSingleRelation(const Relation* rel) const override;
3232

33-
ActivationKey getKey();
34-
Activation* getParent();
33+
ActivationKey getKey() const;
34+
Activation* getParent() const;
3535
void addOutputLink(Link* l);
3636
virtual void addInputLink(Link* l) = 0;
37-
BindingSignal* getBindingSignal(BSType s);
38-
std::map<BSType, BindingSignal*> getBindingSignals();
39-
bool hasConflictingBindingSignals(std::map<BSType, BindingSignal*> targetBindingSignals);
40-
bool isConflictingBindingSignal(BSType s, BindingSignal* targetBS);
41-
bool hasNewBindingSignals(std::map<BSType, BindingSignal*> targetBindingSignals);
37+
BindingSignal* getBindingSignal(BSType s) const;
38+
std::map<BSType, BindingSignal*> getBindingSignals() const;
39+
bool hasConflictingBindingSignals(std::map<BSType, BindingSignal*> targetBindingSignals) const;
40+
bool isConflictingBindingSignal(BSType s, BindingSignal* targetBS) const;
41+
bool hasNewBindingSignals(std::map<BSType, BindingSignal*> targetBindingSignals) const;
4242
Activation* branch(std::map<BSType, BindingSignal*> bindingSignals);
4343
void linkOutgoing();
4444
void linkOutgoing(Synapse* targetSyn);
4545
void propagate(Synapse* targetSyn);
4646
virtual void linkIncoming(Activation* excludedInputAct) = 0;
4747
std::set<Activation*> collectLinkingTargets(Neuron* n);
48-
int getId();
48+
int getId() const;
4949
long getCreated() const override;
5050
void setCreated(long ts);
5151
long getFired() const override;
5252
void setFired();
5353
void setFired(long f);
5454
void updateFiredStep(Field* net);
5555
Queue* getQueue() const override;
56-
Neuron* getNeuron();
57-
Document* getDocument();
58-
Model* getModel() override;
59-
Config* getConfig() override;
60-
Link* getCorrespondingInputLink(Link* l);
61-
Link* getCorrespondingOutputLink(Link* l);
62-
std::vector<Link*> getInputLinks(LinkDefinition* linkDefinition);
63-
virtual std::vector<Link*> getInputLinks() = 0;
64-
std::vector<Link*> getOutputLinks(LinkDefinition* linkDefinition);
65-
std::vector<Link*> getOutputLinks();
66-
Link* getOutputLink(Neuron* n);
67-
std::vector<Link*> getOutputLinks(Synapse* s);
68-
int compareTo(Activation* act);
69-
bool equals(Activation* o);
70-
int hashCode();
71-
std::string toString();
72-
std::string toKeyString();
56+
Neuron* getNeuron() const;
57+
Document* getDocument() const;
58+
Model* getModel() const override;
59+
Config* getConfig() const override;
60+
Link* getCorrespondingInputLink(const Link* l) const;
61+
Link* getCorrespondingOutputLink(const Link* l) const;
62+
std::vector<Link*> getInputLinks(LinkDefinition* linkDefinition) const;
63+
virtual std::vector<Link*> getInputLinks() const = 0;
64+
std::vector<Link*> getOutputLinks(LinkDefinition* linkDefinition) const;
65+
std::vector<Link*> getOutputLinks() const;
66+
Link* getOutputLink(Neuron* n) const;
67+
std::vector<Link*> getOutputLinks(Synapse* s) const;
68+
int compareTo(Activation* act) const;
69+
bool equals(Activation* o) const;
70+
int hashCode() const;
71+
std::string toString() const override;
72+
std::string toKeyString() const override;
7373

7474
protected:
7575
int id;

include/network/conjunctive_activation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ConjunctiveActivation : public Activation {
1313

1414
void linkIncoming(Activation* excludedInputAct) override;
1515
void addInputLink(Link* l) override;
16-
std::vector<Link*> getInputLinks() override;
16+
std::vector<Link*> getInputLinks() const override;
1717

1818
private:
1919
std::map<int, Link*> inputLinks;

include/network/disjunctive_activation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DisjunctiveActivation : public Activation {
1313

1414
void linkIncoming(Activation* excludedInputAct) override;
1515
void addInputLink(Link* l) override;
16-
std::vector<Link*> getInputLinks() override;
16+
std::vector<Link*> getInputLinks() const override;
1717

1818
private:
1919
std::map<int, Link*> inputLinks;

include/network/document.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Document : public Queue, public ModelProvider, public QueueProvider {
2020
long getId() const;
2121
long getTimeout() const override;
2222
void process(std::function<bool(Step*)> filter);
23-
Model* getModel() override;
24-
Config* getConfig() override;
23+
Model* getModel() const override;
24+
Config* getConfig() const override;
2525
Step* getCurrentStep();
2626
void addActivation(Activation* act);
2727
std::set<Activation*> getActivations();

include/network/element.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
class Element : public QueueProvider {
77
public:
88
virtual ~Element() = default;
9-
virtual long getCreated() = 0;
10-
virtual long getFired() = 0;
9+
virtual long getCreated() const = 0;
10+
virtual long getFired() const = 0;
1111
// inherited from QueueProvider
1212
virtual Queue* getQueue() const = 0;
1313
};

include/network/inhibitory_activation.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class InhibitoryActivation : public Activation {
1313
RelatedObjectIterable* followManyRelation(Relation* rel) const override;
1414

1515
void addInputLink(Link* l) override;
16-
Link* getInputLink(int bsId);
17-
int getInputKey(Link* l);
16+
Link* getInputLink(int bsId) const;
17+
int getInputKey(Link* l) const;
1818
void addOutputLink(Link* l) override;
19-
Link* getOutputLink(int bsId);
20-
int getOutputKey(Link* l);
19+
Link* getOutputLink(int bsId) const;
20+
int getOutputKey(Link* l) const;
2121
void linkIncoming(Activation* excludedInputAct) override;
22-
std::vector<Link*> getInputLinks() override;
23-
std::vector<Link*> getOutputLinks() override;
24-
Link* getCorrespondingInputLink(Link* l) override;
25-
Link* getCorrespondingOutputLink(Link* l) override;
22+
std::vector<Link*> getInputLinks() const override;
23+
std::vector<Link*> getOutputLinks() const override;
24+
Link* getCorrespondingInputLink(const Link* l) const override;
25+
Link* getCorrespondingOutputLink(const Link* l) const override;
2626

2727
private:
2828
std::map<int, Link*> inputLinks;

include/network/link.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ class Link : public Obj, public Element, public ModelProvider {
2121
Link(LinkDefinition* type, Synapse* s, Activation* input, Activation* output);
2222

2323
RelatedObjectIterable* followManyRelation(Relation* rel) const override;
24-
Obj* followSingleRelation(const Relation* rel) override;
24+
Obj* followSingleRelation(const Relation* rel) const override;
2525
long getFired() const override;
2626
long getCreated() const override;
27-
Synapse* getSynapse();
27+
Synapse* getSynapse() const;
2828
void setSynapse(Synapse* synapse);
29-
Activation* getInput();
30-
Activation* getOutput();
31-
bool isCausal();
29+
Activation* getInput() const;
30+
Activation* getOutput() const;
31+
bool isCausal() const;
3232
static bool isCausal(Activation* iAct, Activation* oAct);
33-
Document* getDocument();
33+
Document* getDocument() const;
3434
Queue* getQueue() const override;
35-
Model* getModel() override;
36-
Config* getConfig() override;
37-
std::string getInputKeyString();
38-
std::string getOutputKeyString();
39-
std::string toString();
40-
std::string toKeyString();
35+
Model* getModel() const override;
36+
Config* getConfig() const override;
37+
std::string getInputKeyString() const;
38+
std::string getOutputKeyString() const;
39+
std::string toString() const;
40+
std::string toKeyString() const;
4141

4242
private:
4343
Synapse* synapse;

0 commit comments

Comments
 (0)