-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Abstracting algorithm construct into object * Fixing virtual function override problem * Fixing return types of some functions
- Loading branch information
Showing
9 changed files
with
133 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#ifndef ALGO_BREADCRUMBS_HPP | ||
#define ALGO_BREADCRUMBS_HPP | ||
|
||
#include "Algorithm.hpp" | ||
|
||
class AlgoBreadcrumbs : public Algorithm | ||
{ | ||
public: | ||
using Algorithm::Algorithm; | ||
|
||
VOID loop(); | ||
BOOLEAN loopCondition(); | ||
private: | ||
INT iterations = 1; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#ifndef ALGORITHM_HPP | ||
#define ALGORITHM_HPP | ||
|
||
#include "IOProcessor.hpp" | ||
|
||
class Algorithm | ||
{ | ||
public: | ||
explicit Algorithm(IOProcessor* ins, SIZE_T num_inputs, IOProcessor* outs, SIZE_T num_outputs); | ||
|
||
virtual VOID loop() = 0; | ||
virtual BOOLEAN loopCondition() { return FALSE; }; | ||
|
||
VOID startIOProcessors(); | ||
VOID waitForIOProcessors(); | ||
VOID stopIOProcessors(); | ||
|
||
// Updates Algorithm key/value store with IO key/value stores | ||
VOID pollInputs(); | ||
// Updates IO key/value stores with Algorithm key/value store | ||
VOID pollOutputs(); | ||
private: | ||
SIZE_T numInputs, numOutputs; | ||
IOProcessor* inputs, *outputs; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#include "AlgoBreadcrumbs.hpp" | ||
|
||
|
||
VOID AlgoBreadcrumbs::loop() | ||
{ | ||
printf("Breadcrumbs algorithm loop!\n"); | ||
} | ||
|
||
BOOLEAN AlgoBreadcrumbs::loopCondition() | ||
{ | ||
return --iterations >= 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
#include "Algorithm.hpp" | ||
|
||
Algorithm::Algorithm(IOProcessor* ins, SIZE_T numIns, IOProcessor* outs, SIZE_T numOuts) | ||
{ | ||
numInputs = numIns; numOutputs = numOuts; | ||
inputs = ins; outputs = outs; | ||
} | ||
|
||
VOID Algorithm::startIOProcessors() | ||
{ | ||
int i; | ||
for (i = 0; i < numInputs; i++) | ||
(inputs + i)->startThread(); | ||
for (i = 0; i < numOutputs; i++) | ||
(outputs + i)->startThread(); | ||
} | ||
|
||
VOID Algorithm::waitForIOProcessors() | ||
{ | ||
int i; | ||
for (i = 0; i < numInputs; i++) | ||
(inputs + i)->waitForThread(); | ||
for (i = 0; i < numOutputs; i++) | ||
(outputs + i)->waitForThread(); | ||
} | ||
|
||
VOID Algorithm::stopIOProcessors() | ||
{ | ||
waitForIOProcessors(); | ||
} | ||
|
||
VOID Algorithm::pollInputs() | ||
{ | ||
|
||
} | ||
|
||
VOID Algorithm::pollOutputs() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters