-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: create lsl reader and config parser #30
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
Merged
+1,619
−74
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a3e2273
feat: create LSLReader and ConfigParser
MichalSzandar 061fde1
tests: add LSLReader tests and ConfigParser tests
MichalSzandar 550486e
fix: format code
MichalSzandar d812779
fix: format code
MichalSzandar a4cbee1
docs: update readme
MichalSzandar 03a8dd6
feat: address code review feedback
MichalSzandar 7b48043
feat: add json config validation
MichalSzandar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| #ifndef CHANNELCONFIG_HPP | ||
| #define CHANNELCONFIG_HPP | ||
|
|
||
| #include <string> | ||
|
|
||
| // Description of a single EEG channel as declared in the device config file. | ||
| struct ChannelConfig { | ||
| int index = 0; | ||
| std::string label; | ||
| bool enabled = true; | ||
| std::string unit; | ||
|
|
||
| // Throws std::invalid_argument if this channel breaks its own invariants. | ||
| // Rules that need the stream shape (index within range, uniqueness) belong | ||
| // to DeviceConfig::validate. | ||
| void validate() const; | ||
| }; | ||
|
|
||
| #endif // CHANNELCONFIG_HPP |
This file contains hidden or 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,20 @@ | ||
| #ifndef CONFIGPARSER_HPP | ||
| #define CONFIGPARSER_HPP | ||
|
|
||
| #include <config/DeviceConfig.hpp> | ||
| #include <istream> | ||
| #include <string> | ||
|
|
||
| class ConfigParser { | ||
| public: | ||
| // Schema major version this runtime understands. Configs declaring another | ||
| // major are rejected; any minor of this major is accepted (see README §5). | ||
| static constexpr int kSupportedConfigMajor = 1; | ||
|
|
||
| ConfigParser() = default; | ||
|
|
||
| static DeviceConfig parse(const std::string& filePath); | ||
| static DeviceConfig parseStream(std::istream& stream); | ||
| }; | ||
|
|
||
| #endif // CONFIGPARSER_HPP | ||
This file contains hidden or 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,25 @@ | ||
| #ifndef CONFIGVERSION_HPP | ||
| #define CONFIGVERSION_HPP | ||
|
|
||
| #include <string> | ||
|
|
||
| // Schema version of a device config file, written as "MAJOR.MINOR". | ||
| // MAJOR changes are breaking (fields moved, renamed or removed) and are rejected | ||
| // by a runtime built for another major; MINOR changes are additive and | ||
| // backward-compatible, so any minor of a supported major is accepted. | ||
| struct ConfigVersion { | ||
| int major = 0; | ||
| int minor = 0; | ||
|
|
||
| bool operator==(const ConfigVersion&) const = default; | ||
|
|
||
| // Throws std::invalid_argument on a version that cannot be compared. | ||
| // Whether a valid version is *supported* is ConfigParser's decision. | ||
| void validate() const; | ||
|
|
||
| [[nodiscard]] std::string toString() const { | ||
| return std::to_string(major) + "." + std::to_string(minor); | ||
| } | ||
| }; | ||
|
|
||
| #endif // CONFIGVERSION_HPP |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.