Skip to content

Commit a2cfdd8

Browse files
1. We fixed the const qualifiers for methods in:
- Element, Activation, Neuron, Link, Document classes for getQueue method - Activation, Neuron, Link classes for getCreated and getFired methods - Updated all classes to properly override methods from their base classes 2. We added implementations of getConfig method to: - Activation, Neuron, Link classes 3. We made several other minor adjustments to ensure proper inheritance relationships and method overriding across the codebase.
1 parent 2c66785 commit a2cfdd8

File tree

11 files changed

+40
-22
lines changed

11 files changed

+40
-22
lines changed

include/fields/queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Queue {
2222
void checkTimeout(long startTime);
2323

2424
public:
25-
long getTimeout();
25+
virtual long getTimeout() const;
2626
long getTimestampOnProcess();
2727
long getCurrentTimestamp();
2828
long getNextTimestamp();

include/network/activation.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ class Activation : public Obj, public Element, public ModelProvider {
4646
virtual void linkIncoming(Activation* excludedInputAct) = 0;
4747
std::set<Activation*> collectLinkingTargets(Neuron* n);
4848
int getId();
49-
long getCreated() override;
49+
long getCreated() const override;
5050
void setCreated(long ts);
51-
long getFired() override;
51+
long getFired() const override;
5252
void setFired();
5353
void setFired(long f);
5454
void updateFiredStep(Field* net);
55-
Queue* getQueue();
55+
Queue* getQueue() const override;
5656
Neuron* getNeuron();
5757
Document* getDocument();
58-
Model* getModel();
58+
Model* getModel() override;
59+
Config* getConfig() override;
5960
Link* getCorrespondingInputLink(Link* l);
6061
Link* getCorrespondingOutputLink(Link* l);
6162
std::vector<Link*> getInputLinks(LinkDefinition* linkDefinition);

include/network/conjunctive_synapse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class ConjunctiveSynapse : public Synapse {
1010

1111
RelatedObjectIterable* followManyRelation(Relation* rel) const override;
1212
Obj* followSingleRelation(const Relation* rel) override;
13-
13+
/*
1414
void write(DataOutput* out) override;
1515
void readFields(DataInput* in, TypeRegistry* tr) override;
16-
16+
*/
1717
private:
1818
bool propagable;
1919
};

include/network/document.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Document : public Queue, public ModelProvider, public QueueProvider {
2828
Activation* getActivationByNeuron(Neuron* outputNeuron);
2929
int createActivationId();
3030
void disconnect();
31-
Queue* getQueue() override;
31+
Queue* getQueue() const override;
3232
Activation* addToken(Neuron* n, BSType* bsType, int tokenId);
3333
BindingSignal* getOrCreateBindingSignal(int tokenId);
3434
BindingSignal* getBindingSignal(int tokenId);

include/network/element.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Element : public QueueProvider {
88
virtual ~Element() = default;
99
virtual long getCreated() = 0;
1010
virtual long getFired() = 0;
11+
// inherited from QueueProvider
12+
virtual Queue* getQueue() const = 0;
1113
};
1214

1315
#endif // NETWORK_ELEMENT_H

include/network/link.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class Link : public Obj, public Element, public ModelProvider {
2222

2323
RelatedObjectIterable* followManyRelation(Relation* rel) const override;
2424
Obj* followSingleRelation(const Relation* rel) override;
25-
long getFired() override;
26-
long getCreated() override;
25+
long getFired() const override;
26+
long getCreated() const override;
2727
Synapse* getSynapse();
2828
void setSynapse(Synapse* synapse);
2929
Activation* getInput();
@@ -33,6 +33,7 @@ class Link : public Obj, public Element, public ModelProvider {
3333
Document* getDocument();
3434
Queue* getQueue() const override;
3535
Model* getModel() override;
36+
Config* getConfig() override;
3637
std::string getInputKeyString();
3738
std::string getOutputKeyString();
3839
std::string toString();

include/network/model_provider.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
class ModelProvider {
88
public:
9-
virtual Model* getModel();
10-
virtual Config* getConfig();
9+
virtual ~ModelProvider() = default;
10+
virtual Model* getModel() = 0;
11+
virtual Config* getConfig() = 0;
1112

1213
protected:
1314
Model* model;

include/network/neuron.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Neuron : public Obj, public Element, public ModelProvider {
2929
Activation* createActivation(Activation* parent, Document* doc, std::map<BSType*, BindingSignal*> bindingSignals);
3030
void deleteNeuron();
3131
Model* getModel() override;
32+
Config* getConfig() override;
3233
void setModified();
3334
void resetModified();
3435
bool isModified() const;
@@ -48,9 +49,9 @@ class Neuron : public Obj, public Element, public ModelProvider {
4849
Synapse* getOutputSynapseByType(Type* synapseType) const;
4950
std::vector<Synapse*> getOutputSynapsesByType(Type* synapseType) const;
5051
Synapse* selectInputSynapse(std::function<bool(Synapse*)> predicate) const;
51-
long getCreated() override;
52-
long getFired() override;
53-
Queue* getQueue() override;
52+
long getCreated() const override;
53+
long getFired() const override;
54+
Queue* getQueue() const override;
5455
void increaseRefCount(RefType rt);
5556
void decreaseRefCount(RefType rt);
5657
int getRefCount() const;

src/network/activation.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ int Activation::getId() {
147147
return id;
148148
}
149149

150-
long Activation::getCreated() {
150+
long Activation::getCreated() const {
151151
return created;
152152
}
153153

154154
void Activation::setCreated(long ts) {
155155
created = ts;
156156
}
157157

158-
long Activation::getFired() {
158+
long Activation::getFired() const {
159159
return fired;
160160
}
161161

@@ -180,7 +180,7 @@ void Activation::updateFiredStep(Field* net) {
180180
doc->addStep(firedStep);
181181
}
182182

183-
Queue* Activation::getQueue() {
183+
Queue* Activation::getQueue() const {
184184
return doc;
185185
}
186186

@@ -196,6 +196,10 @@ Model* Activation::getModel() {
196196
return neuron->getModel();
197197
}
198198

199+
Config* Activation::getConfig() {
200+
return neuron->getModel()->getConfig();
201+
}
202+
199203
Link* Activation::getCorrespondingInputLink(Link* l) {
200204
return nullptr;
201205
}

src/network/link.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ Obj* Link::followSingleRelation(const Relation* rel) {
3131
throw std::runtime_error("Invalid Relation: " + rel->getRelationName());
3232
}
3333

34-
Timestamp Link::getFired() {
34+
long Link::getFired() const {
3535
return input && isCausal() ? input->getFired() : output->getFired();
3636
}
3737

38-
Timestamp Link::getCreated() {
38+
long Link::getCreated() const {
3939
return input && isCausal() ? input->getCreated() : output->getCreated();
4040
}
4141

@@ -67,14 +67,18 @@ Document* Link::getDocument() {
6767
return output->getDocument();
6868
}
6969

70-
Queue* Link::getQueue() {
70+
Queue* Link::getQueue() const {
7171
return output->getDocument();
7272
}
7373

7474
Model* Link::getModel() {
7575
return output->getModel();
7676
}
7777

78+
Config* Link::getConfig() {
79+
return output->getModel()->getConfig();
80+
}
81+
7882
std::string Link::getInputKeyString() {
7983
return input ? input->toKeyString() : "id:X n:[" + synapse->getInput() + "]";
8084
}

0 commit comments

Comments
 (0)