wip: interface::Simulator => interface::Simulator_

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/851/head
Gergely Nagy 4 years ago
parent 145d926510
commit 5d69c4f5c0
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -39,7 +39,7 @@ uint8_t toKeycode(Key key) {
} // namespace simulator } // namespace simulator
} // namespace kaleidoscope } // namespace kaleidoscope
#include "kaleidoscope/simulator/Framework.h" #include "kaleidoscope/simulator/Interface.h"
#include "kaleidoscope/simulator/executor/Executor.h" #include "kaleidoscope/simulator/executor/Executor.h"
#include "kaleidoscope/simulator/executor/AglaisInterface.h" #include "kaleidoscope/simulator/executor/AglaisInterface.h"
#include "kaleidoscope/simulator/interface/Visualization.h" #include "kaleidoscope/simulator/interface/Visualization.h"

@ -20,7 +20,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/Visualization.h" #include "kaleidoscope/simulator/interface/Visualization.h"
#include "kaleidoscope/simulator/interface/LED_Checks.h" #include "kaleidoscope/simulator/interface/LED_Checks.h"

@ -26,7 +26,7 @@
#include "kaleidoscope/simulator/LogProtocol.h" #include "kaleidoscope/simulator/LogProtocol.h"
#include "kaleidoscope/simulator/log_protocol/Consumer_.h" #include "kaleidoscope/simulator/log_protocol/Consumer_.h"
#include "kaleidoscope/simulator/interface/actions/generic_report/AssertReportEquals.h" #include "kaleidoscope/simulator/interface/actions/generic_report/AssertReportEquals.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "HID-Settings.h" #include "HID-Settings.h"
namespace kaleidoscope { namespace kaleidoscope {
@ -38,7 +38,7 @@ namespace executor {
class SimulatorConsumerAdaptor : public log_protocol::Consumer_ { class SimulatorConsumerAdaptor : public log_protocol::Consumer_ {
public: public:
SimulatorConsumerAdaptor(interface::Simulator &simulator) SimulatorConsumerAdaptor(interface::Simulator_ &simulator)
: simulator_(simulator) : simulator_(simulator)
{} {}
@ -144,11 +144,11 @@ class SimulatorConsumerAdaptor : public log_protocol::Consumer_ {
private: private:
interface::Simulator &simulator_; interface::Simulator_ &simulator_;
}; };
void processAglaisDocument(const char *code, interface::Simulator &simulator) { void processAglaisDocument(const char *code, interface::Simulator_ &simulator) {
auto rwqa_state = simulator.getErrorIfReportWithoutQueuedActions(); auto rwqa_state = simulator.getErrorIfReportWithoutQueuedActions();
log_protocol::LogProtocol a; log_protocol::LogProtocol a;

@ -23,12 +23,12 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
} // namespace interface } // namespace interface
namespace executor { namespace executor {
void processAglaisDocument(const char *code, interface::Simulator &sim); void processAglaisDocument(const char *code, interface::Simulator_ &sim);
} // namespace executor } // namespace executor
} // namespace simulator } // namespace simulator

@ -34,7 +34,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace executor { namespace executor {
Executor::Executor(std::ostream &out) : interface::Simulator{out} { Executor::Executor(std::ostream &out) : interface::Simulator_{out} {
this->setCore( this->setCore(
std::shared_ptr<SimulatorCore> { std::shared_ptr<SimulatorCore> {
new SimulatorCore{} new SimulatorCore{}

@ -20,7 +20,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
/// @namespace kaleidoscope /// @namespace kaleidoscope
/// ///
@ -34,7 +34,7 @@ namespace executor {
/// @brief A Kaleidoscope specific simulator class. /// @brief A Kaleidoscope specific simulator class.
/// ///
class Executor : public interface::Simulator { class Executor : public interface::Simulator_ {
public: public:
/// @brief Access the global simulator singleton. /// @brief Access the global simulator singleton.

@ -23,7 +23,7 @@
#include "kaleidoscope/simulator/executor/reports/KeyboardReport.h" #include "kaleidoscope/simulator/executor/reports/KeyboardReport.h"
#include "kaleidoscope/simulator/executor/reports/MouseReport.h" #include "kaleidoscope/simulator/executor/reports/MouseReport.h"
#include "kaleidoscope/simulator/executor/reports/AbsoluteMouseReport.h" #include "kaleidoscope/simulator/executor/reports/AbsoluteMouseReport.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#ifdef __unix__ /* __unix__ is usually defined by compilers targeting Unix systems */ #ifdef __unix__ /* __unix__ is usually defined by compilers targeting Unix systems */
@ -82,7 +82,7 @@ class KeyboardReportEventCheck {
public: public:
KeyboardReportEventCheck(const interface::Simulator &simulator, KeyboardReportEventCheck(const interface::Simulator_ &simulator,
Display *display, Display *display,
const KeyboardReport &previous_report, const KeyboardReport &previous_report,
const KeyboardReport &current_report) const KeyboardReport &current_report)
@ -140,7 +140,7 @@ class KeyboardReportEventCheck {
private: private:
const interface::Simulator &simulator_; const interface::Simulator_ &simulator_;
Display *display_; Display *display_;
const KeyboardReport::ReportDataType &previous_report_data_; const KeyboardReport::ReportDataType &previous_report_data_;
const KeyboardReport::ReportDataType &current_report_data_; const KeyboardReport::ReportDataType &current_report_data_;
@ -150,7 +150,7 @@ class BootKeyboardReportEventCheck {
public: public:
BootKeyboardReportEventCheck(const interface::Simulator &simulator, BootKeyboardReportEventCheck(const interface::Simulator_ &simulator,
Display *display, Display *display,
const BootKeyboardReport &previous_report, const BootKeyboardReport &previous_report,
const BootKeyboardReport &current_report) const BootKeyboardReport &current_report)
@ -231,7 +231,7 @@ class BootKeyboardReportEventCheck {
private: private:
const interface::Simulator &simulator_; const interface::Simulator_ &simulator_;
Display *display_; Display *display_;
const BootKeyboardReport::ReportDataType &previous_report_data_; const BootKeyboardReport::ReportDataType &previous_report_data_;
const BootKeyboardReport::ReportDataType &current_report_data_; const BootKeyboardReport::ReportDataType &current_report_data_;

@ -19,7 +19,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/executor/reports/AbsoluteMouseReport.h" #include "kaleidoscope/simulator/executor/reports/AbsoluteMouseReport.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
@ -104,7 +104,7 @@ bool AbsoluteMouseReport::isEmpty() const {
&& (report_data_.wheel == 0); && (report_data_.wheel == 0);
} }
void AbsoluteMouseReport::dump(const interface::Simulator &simulator, const char *add_indent) const { void AbsoluteMouseReport::dump(const interface::Simulator_ &simulator, const char *add_indent) const {
simulator.log() << add_indent << "Absolute mouse report content:"; simulator.log() << add_indent << "Absolute mouse report content:";
simulator.log() << add_indent << " left button: " << this->isLeftButtonPressed(); simulator.log() << add_indent << " left button: " << this->isLeftButtonPressed();
simulator.log() << add_indent << " middle button: " << this->isMiddleButtonPressed(); simulator.log() << add_indent << " middle button: " << this->isMiddleButtonPressed();

@ -133,7 +133,7 @@ class AbsoluteMouseReport : public interface::AbsoluteMouseReport_ {
/// to the simulator's log stream. /// to the simulator's log stream.
/// @param add_indent An additional indentation string. /// @param add_indent An additional indentation string.
/// ///
virtual void dump(const interface::Simulator &simulator, const char *add_indent = "") const override; virtual void dump(const interface::Simulator_ &simulator, const char *add_indent = "") const override;
/// @brief Associates the object with new report data. /// @brief Associates the object with new report data.
/// @param report_data The new report data struct. /// @param report_data The new report data struct.

@ -26,7 +26,7 @@
#include "kaleidoscope/simulator/executor/reports/BootKeyboardReport.h" #include "kaleidoscope/simulator/executor/reports/BootKeyboardReport.h"
#include "kaleidoscope/simulator/executor/aux/exceptions.h" #include "kaleidoscope/simulator/executor/aux/exceptions.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/SimulatorCore_.h" #include "kaleidoscope/simulator/interface/SimulatorCore_.h"
#include "MultiReport/Keyboard.h" #include "MultiReport/Keyboard.h"
@ -171,7 +171,7 @@ BootKeyboardReport
if((bitfield) & 1<<7) stream << str7; if((bitfield) & 1<<7) stream << str7;
void void
BootKeyboardReport BootKeyboardReport
::dump(const interface::Simulator &simulator, const char *add_indent) const { ::dump(const interface::Simulator_ &simulator, const char *add_indent) const {
bool anything = false; bool anything = false;
if (report_data_.modifiers) { if (report_data_.modifiers) {
anything = true; anything = true;

@ -122,7 +122,7 @@ class BootKeyboardReport : public interface::BootKeyboardReport_ {
/// to the simulator's log stream. /// to the simulator's log stream.
/// @param add_indent An additional indentation string. /// @param add_indent An additional indentation string.
/// ///
virtual void dump(const interface::Simulator &simulator, const char *add_indent = "") const override; virtual void dump(const interface::Simulator_ &simulator, const char *add_indent = "") const override;
/// @brief Associates the object with new report data. /// @brief Associates the object with new report data.
/// @param report_data The new report data struct. /// @param report_data The new report data struct.

@ -26,7 +26,7 @@
#include "kaleidoscope/simulator/executor/reports/KeyboardReport.h" #include "kaleidoscope/simulator/executor/reports/KeyboardReport.h"
#include "kaleidoscope/simulator/executor/aux/exceptions.h" #include "kaleidoscope/simulator/executor/aux/exceptions.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include <vector> #include <vector>
@ -174,7 +174,7 @@ KeyboardReport
void void
KeyboardReport KeyboardReport
::dump(const interface::Simulator &simulator, const char *add_indent) const { ::dump(const interface::Simulator_ &simulator, const char *add_indent) const {
bool anything = false; bool anything = false;
if (report_data_.modifiers) anything = true; if (report_data_.modifiers) anything = true;
else for (int i = 0; i < KEY_BYTES; i++) if (report_data_.keys[i]) { else for (int i = 0; i < KEY_BYTES; i++) if (report_data_.keys[i]) {

@ -124,7 +124,7 @@ class KeyboardReport : public interface::KeyboardReport_ {
/// to the simulator's log stream. /// to the simulator's log stream.
/// @param add_indent An additional indentation string. /// @param add_indent An additional indentation string.
/// ///
virtual void dump(const interface::Simulator &simulator, const char *add_indent = "") const override; virtual void dump(const interface::Simulator_ &simulator, const char *add_indent = "") const override;
/// @brief Associates the object with new report data. /// @brief Associates the object with new report data.
/// @param report_data The new report data struct. /// @param report_data The new report data struct.

@ -20,7 +20,7 @@
#include "kaleidoscope/simulator/executor/reports/MouseReport.h" #include "kaleidoscope/simulator/executor/reports/MouseReport.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
@ -96,7 +96,7 @@ bool MouseReport::isEmpty() const {
&& (report_data_.hWheel == 0); && (report_data_.hWheel == 0);
} }
void MouseReport::dump(const interface::Simulator &simulator, const char *add_indent) const { void MouseReport::dump(const interface::Simulator_ &simulator, const char *add_indent) const {
simulator.log() << add_indent << "Mouse report content:"; simulator.log() << add_indent << "Mouse report content:";
simulator.log() << add_indent << " left button: " << this->isLeftButtonPressed(); simulator.log() << add_indent << " left button: " << this->isLeftButtonPressed();
simulator.log() << add_indent << " middle button: " << this->isMiddleButtonPressed(); simulator.log() << add_indent << " middle button: " << this->isMiddleButtonPressed();

@ -130,7 +130,7 @@ class MouseReport : public interface::MouseReport_ {
/// to the simulator's log stream. /// to the simulator's log stream.
/// @param add_indent An additional indentation string. /// @param add_indent An additional indentation string.
/// ///
virtual void dump(const interface::Simulator &simulator, const char *add_indent = "") const override; virtual void dump(const interface::Simulator_ &simulator, const char *add_indent = "") const override;
/// @brief Associates the object with new report data. /// @brief Associates the object with new report data.
/// @param report_data The new report data struct. /// @param report_data The new report data struct.

@ -35,7 +35,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief An auxiliary class that represents a container of action objects. /// @brief An auxiliary class that represents a container of action objects.
/// ///
@ -49,7 +49,7 @@ class ActionContainer {
/// @brief Constructor. /// @brief Constructor.
/// @param simulator The associated Simulator object. /// @param simulator The associated Simulator object.
/// ///
ActionContainer(Simulator &simulator) ActionContainer(Simulator_ &simulator)
: simulator_(simulator) : simulator_(simulator)
{} {}
@ -157,7 +157,7 @@ class ActionContainer {
private: private:
Simulator &simulator_; Simulator_ &simulator_;
std::deque<std::shared_ptr<_ActionType>> container_; std::deque<std::shared_ptr<_ActionType>> container_;
}; };

@ -19,7 +19,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/LED_Checks.h" #include "kaleidoscope/simulator/interface/LED_Checks.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/SimulatorCore_.h" #include "kaleidoscope/simulator/interface/SimulatorCore_.h"
#include <iostream> #include <iostream>
@ -28,7 +28,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
void dumpKeyLEDState(const Simulator &simulator) { void dumpKeyLEDState(const Simulator_ &simulator) {
std::cout << "const uint8_t key_led_colors[][3] = {\n"; std::cout << "const uint8_t key_led_colors[][3] = {\n";
@ -56,7 +56,7 @@ void dumpKeyLEDState(const Simulator &simulator) {
std::cout << "};\n\n"; std::cout << "};\n\n";
} }
void assertKeyLEDState(const Simulator &simulator, void assertKeyLEDState(const Simulator_ &simulator,
const uint8_t key_led_colors[][3]) { const uint8_t key_led_colors[][3]) {
const auto &simulator_core = simulator.getCore(); const auto &simulator_core = simulator.getCore();

@ -26,18 +26,18 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief Dumps the state of the key LEDs as C++ code /// @brief Dumps the state of the key LEDs as C++ code
/// ///
void dumpKeyLEDState(const Simulator &simulator); void dumpKeyLEDState(const Simulator_ &simulator);
/// @brief Compares the current state of the key LEDs to a representation /// @brief Compares the current state of the key LEDs to a representation
/// stored in an array. /// stored in an array.
/// @param key_led_colors An array of key LED state data to compare the current /// @param key_led_colors An array of key LED state data to compare the current
/// state with. /// state with.
/// ///
void assertKeyLEDState(const Simulator &simulator, void assertKeyLEDState(const Simulator_ &simulator,
const uint8_t key_led_colors[][3]); const uint8_t key_led_colors[][3]);
} // namespace interface } // namespace interface

@ -20,7 +20,7 @@
#include "Arduino.h" #include "Arduino.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/ActionContainer_Impl.h" #include "kaleidoscope/simulator/interface/ActionContainer_Impl.h"
#include "kaleidoscope/simulator/interface/actions/Action_.h" #include "kaleidoscope/simulator/interface/actions/Action_.h"
#include "kaleidoscope/simulator/interface/aux/WallTimer.h" #include "kaleidoscope/simulator/interface/aux/WallTimer.h"
@ -86,7 +86,7 @@ void SimulatorStream_::reactOnLineEnd() {
this->getOStream() << "\n"; this->getOStream() << "\n";
} }
ErrorStream::ErrorStream(const Simulator *simulator) ErrorStream::ErrorStream(const Simulator_ *simulator)
: SimulatorStream_(simulator) { : SimulatorStream_(simulator) {
auto &out = this->getOStream(); auto &out = this->getOStream();
@ -119,7 +119,7 @@ void ErrorStream::reactOnLineStart() {
this->getOStream() << "!!! "; this->getOStream() << "!!! ";
} }
DebugStream::DebugStream(const Simulator *simulator) DebugStream::DebugStream(const Simulator_ *simulator)
: SimulatorStream_(simulator) { : SimulatorStream_(simulator) {
if (this->mute()) { if (this->mute()) {
return; return;
@ -155,7 +155,7 @@ void DebugStream::reactOnLineStart() {
this->getOStream() << "***Debug: "; this->getOStream() << "***Debug: ";
} }
LogStream::LogStream(const Simulator *simulator) LogStream::LogStream(const Simulator_ *simulator)
: SimulatorStream_(simulator) { : SimulatorStream_(simulator) {
} }
@ -167,7 +167,7 @@ LogStream::~LogStream() {
this->getOStream() << "\n"; this->getOStream() << "\n";
} }
HeaderStream::HeaderStream(const Simulator *simulator) HeaderStream::HeaderStream(const Simulator_ *simulator)
: SimulatorStream_(simulator) { : SimulatorStream_(simulator) {
if (this->mute()) { if (this->mute()) {
return; return;
@ -205,7 +205,7 @@ void HeaderStream::reactOnLineStart() {
this->getOStream() << "### "; this->getOStream() << "### ";
} }
Test::Test(Simulator *simulator, const char *name) Test::Test(Simulator_ *simulator, const char *name)
: simulator_(simulator), : simulator_(simulator),
name_(name), name_(name),
error_count_start_(simulator->getErrorCount()) { error_count_start_(simulator->getErrorCount()) {
@ -222,10 +222,10 @@ Test::~Test() {
} }
} }
Simulator::Simulator(std::ostream &out, Simulator_::Simulator_(std::ostream &out,
bool debug, bool debug,
int cycle_duration, int cycle_duration,
bool abort_on_first_error) bool abort_on_first_error)
: out_{&out}, : out_{&out},
debug_{debug}, debug_{debug},
@ -245,7 +245,7 @@ Simulator::Simulator(std::ostream &out,
this->headerText(); this->headerText();
} }
Simulator::~Simulator() { Simulator_::~Simulator_() {
this->footerText(); this->footerText();
if (!test_success_) { if (!test_success_) {
@ -254,24 +254,24 @@ Simulator::~Simulator() {
} }
} }
void Simulator::pressKey(uint8_t row, uint8_t col) { void Simulator_::pressKey(uint8_t row, uint8_t col) {
this->log() << "+ Activating key (" << (unsigned)row << ", " << (unsigned)col << ")"; this->log() << "+ Activating key (" << (unsigned)row << ", " << (unsigned)col << ")";
simulator_core_->pressKey(row, col); simulator_core_->pressKey(row, col);
} }
void Simulator::releaseKey(uint8_t row, uint8_t col) { void Simulator_::releaseKey(uint8_t row, uint8_t col) {
this->log() << "+ Releasing key (" << (unsigned)row << ", " << (unsigned)col << ")"; this->log() << "+ Releasing key (" << (unsigned)row << ", " << (unsigned)col << ")";
simulator_core_->releaseKey(row, col); simulator_core_->releaseKey(row, col);
} }
void Simulator::tapKey(uint8_t row, uint8_t col) { void Simulator_::tapKey(uint8_t row, uint8_t col) {
this->log() << "+- Tapping key (" << (unsigned)row << ", " << (unsigned)col << ")"; this->log() << "+- Tapping key (" << (unsigned)row << ", " << (unsigned)col << ")";
simulator_core_->tapKey(row, col); simulator_core_->tapKey(row, col);
} }
void Simulator::multiTapKeyInternal(int num_taps, uint8_t row, uint8_t col, void Simulator_::multiTapKeyInternal(int num_taps, uint8_t row, uint8_t col,
int tap_interval_cycles, int tap_interval_cycles,
std::shared_ptr<Action_> after_tap_and_cycles_action) { std::shared_ptr<Action_> after_tap_and_cycles_action) {
if (after_tap_and_cycles_action) { if (after_tap_and_cycles_action) {
after_tap_and_cycles_action->setSimulator(this); after_tap_and_cycles_action->setSimulator(this);
} }
@ -302,7 +302,7 @@ void Simulator::multiTapKeyInternal(int num_taps, uint8_t row, uint8_t col,
} }
} }
void Simulator::clearAllKeys() { void Simulator_::clearAllKeys() {
this->log() << "- Clearing all keys"; this->log() << "- Clearing all keys";
uint8_t rows = 0, cols = 0; uint8_t rows = 0, cols = 0;
@ -316,7 +316,7 @@ void Simulator::clearAllKeys() {
} }
} }
void Simulator::cycle(bool suppress_cycle_info_log) { void Simulator_::cycle(bool suppress_cycle_info_log) {
if (!suppress_cycle_info_log) { if (!suppress_cycle_info_log) {
this->log() << "Running single scan cycle"; this->log() << "Running single scan cycle";
} }
@ -328,8 +328,8 @@ void Simulator::cycle(bool suppress_cycle_info_log) {
} }
} }
void Simulator::cyclesInternal(int n, void Simulator_::cyclesInternal(int n,
const std::vector<std::shared_ptr<Action_>> &cycle_action_list) { const std::vector<std::shared_ptr<Action_>> &cycle_action_list) {
if (n == 0) { if (n == 0) {
n = scan_cycles_default_count_; n = scan_cycles_default_count_;
} }
@ -344,7 +344,7 @@ void Simulator::cyclesInternal(int n,
this->log() << ""; this->log() << "";
} }
void Simulator::advanceTimeBy(Simulator::TimeType delta_t) { void Simulator_::advanceTimeBy(Simulator_::TimeType delta_t) {
this->checkCycleDurationSet(); this->checkCycleDurationSet();
@ -353,13 +353,13 @@ void Simulator::advanceTimeBy(Simulator::TimeType delta_t) {
this->skipTimeInternal(delta_t); this->skipTimeInternal(delta_t);
} }
void Simulator::skipTimeInternal(Simulator::TimeType delta_t) { void Simulator_::skipTimeInternal(Simulator_::TimeType delta_t) {
auto start_cycle = cycle_id_; auto start_cycle = cycle_id_;
auto start_time = time_; auto start_time = time_;
Simulator::TimeType elapsed_time = 0; Simulator_::TimeType elapsed_time = 0;
while (elapsed_time < delta_t) { while (elapsed_time < delta_t) {
this->cycleInternal(true /* only_log_reports */); this->cycleInternal(true /* only_log_reports */);
elapsed_time = time_ - start_time; elapsed_time = time_ - start_time;
@ -370,7 +370,7 @@ void Simulator::skipTimeInternal(Simulator::TimeType delta_t) {
this->log() << ""; this->log() << "";
} }
void Simulator::advanceTimeTo(TimeType time) { void Simulator_::advanceTimeTo(TimeType time) {
if (time <= time_) { if (time <= time_) {
this->error() << "Failed cycling to time " << time << " ms. Target time is in the past."; this->error() << "Failed cycling to time " << time << " ms. Target time is in the past.";
return; return;
@ -383,12 +383,12 @@ void Simulator::advanceTimeTo(TimeType time) {
this->skipTimeInternal(delta_t); this->skipTimeInternal(delta_t);
} }
void Simulator::init() { void Simulator_::init() {
this->clearAllKeys(); this->clearAllKeys();
simulator_core_->init(); simulator_core_->init();
} }
bool Simulator::checkStatus() { bool Simulator_::checkStatus() {
if (!queued_report_actions_.empty()) { if (!queued_report_actions_.empty()) {
this->error() << "There are " << queued_report_actions_.size() this->error() << "There are " << queued_report_actions_.size()
@ -415,7 +415,7 @@ bool Simulator::checkStatus() {
return false; return false;
} }
void Simulator::headerText() { void Simulator_::headerText() {
// Foreground color yellow // Foreground color yellow
// //
@ -440,7 +440,7 @@ void Simulator::headerText() {
this->getOStream() << "\x1B[0m"; this->getOStream() << "\x1B[0m";
} }
void Simulator::footerText() { void Simulator_::footerText() {
// Foreground color yellow // Foreground color yellow
// //
@ -471,7 +471,7 @@ void Simulator::footerText() {
this->getOStream() << "\x1B[0m"; this->getOStream() << "\x1B[0m";
} }
void Simulator::cycleInternal(bool only_log_reports) { void Simulator_::cycleInternal(bool only_log_reports) {
++cycle_id_; ++cycle_id_;
n_reports_in_cycle_ = 0; n_reports_in_cycle_ = 0;
@ -516,14 +516,14 @@ void Simulator::cycleInternal(bool only_log_reports) {
} }
} }
void Simulator::checkCycleDurationSet() { void Simulator_::checkCycleDurationSet() {
if (cycle_duration_ == 0) { if (cycle_duration_ == 0) {
this->error() << "Please set test.cycle_duration_ to a value in " this->error() << "Please set test.cycle_duration_ to a value in "
"[ms] greater zero before using time based testing"; "[ms] greater zero before using time based testing";
} }
} }
void Simulator::assertNothingQueued() const { void Simulator_::assertNothingQueued() const {
if (!queued_report_actions_.empty()) { if (!queued_report_actions_.empty()) {
this->error() << "Report actions are left in queue"; this->error() << "Report actions are left in queue";
} }
@ -533,14 +533,14 @@ void Simulator::assertNothingQueued() const {
} }
} }
void Simulator::assertCondition(bool cond, const char *action_code) const { void Simulator_::assertCondition(bool cond, const char *action_code) const {
if (!cond) { if (!cond) {
this->error() << "Action failed: " << action_code; this->error() << "Action failed: " << action_code;
} }
} }
void Simulator::runRealtime(TimeType duration, void Simulator_::runRealtime(TimeType duration,
const std::function<void()> &cycle_function) { const std::function<void()> &cycle_function) {
auto n_cycles = duration / cycle_duration_; auto n_cycles = duration / cycle_duration_;
aux::WallTimer timer; aux::WallTimer timer;
@ -591,12 +591,12 @@ class DataCollectorThread {
uint16_t key_bitfield_[n_bytes_per_row] = {}; uint16_t key_bitfield_[n_bytes_per_row] = {};
std::mutex mutex_; std::mutex mutex_;
friend class Simulator; friend class Simulator_;
}; };
void Simulator::runRemoteControlled(const std::function<void()> &cycle_callback, void Simulator_::runRemoteControlled(const std::function<void()> &cycle_callback,
bool realtime bool realtime
) { ) {
aux::WallTimer timer; aux::WallTimer timer;
DataCollectorThread dct; DataCollectorThread dct;

@ -37,7 +37,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
class SimulatorCore_; class SimulatorCore_;
class Action_; class Action_;
@ -99,7 +99,7 @@ class SimulatorStream_ {
/// ///
struct Endl {}; struct Endl {};
SimulatorStream_(const Simulator *simulator) : simulator_(simulator) {} SimulatorStream_(const Simulator_ *simulator) : simulator_(simulator) {}
virtual ~SimulatorStream_() {} virtual ~SimulatorStream_() {}
@ -128,7 +128,7 @@ class SimulatorStream_ {
protected: protected:
const Simulator *simulator_; const Simulator_ *simulator_;
private: private:
@ -141,7 +141,7 @@ class ErrorStream : public SimulatorStream_ {
public: public:
ErrorStream(const Simulator *simulator); ErrorStream(const Simulator_ *simulator);
template<typename _T> template<typename _T>
ErrorStream &operator<<(const _T &t) { ErrorStream &operator<<(const _T &t) {
@ -162,7 +162,7 @@ class DebugStream : public SimulatorStream_ {
public: public:
DebugStream(const Simulator *simulator); DebugStream(const Simulator_ *simulator);
template<typename _T> template<typename _T>
DebugStream &operator<<(const _T &t) { DebugStream &operator<<(const _T &t) {
@ -186,7 +186,7 @@ class LogStream : public SimulatorStream_ {
public: public:
LogStream(const Simulator *simulator); LogStream(const Simulator_ *simulator);
virtual ~LogStream() override; virtual ~LogStream() override;
template<typename _T> template<typename _T>
@ -205,7 +205,7 @@ class HeaderStream : public SimulatorStream_ {
public: public:
HeaderStream(const Simulator *simulator); HeaderStream(const Simulator_ *simulator);
template<typename _T> template<typename _T>
HeaderStream &operator<<(const _T &t) { HeaderStream &operator<<(const _T &t) {
@ -229,12 +229,12 @@ class Test {
public: public:
Test(Simulator *simulator, const char *name); Test(Simulator_ *simulator, const char *name);
~Test(); ~Test();
private: private:
Simulator *simulator_; Simulator_ *simulator_;
const char *name_; const char *name_;
int error_count_start_; int error_count_start_;
}; };
@ -242,7 +242,7 @@ class Test {
/// @brief The main simulator object. /// @brief The main simulator object.
/// ///
class Simulator { class Simulator_ {
public: public:
@ -288,7 +288,7 @@ class Simulator {
public: public:
~Simulator(); ~Simulator_();
/// @details If the ErrorIfReportWithoutQueuedActions is enabled /// @details If the ErrorIfReportWithoutQueuedActions is enabled
/// it is considered an error if no actions are queued /// it is considered an error if no actions are queued
@ -712,10 +712,10 @@ class Simulator {
/// @param abort_on_first_error If enabled, testing is aborted after /// @param abort_on_first_error If enabled, testing is aborted after
/// the first error occurred. /// the first error occurred.
/// ///
Simulator(std::ostream &out, Simulator_(std::ostream &out,
bool debug = false, bool debug = false,
int cycle_duration = 1, int cycle_duration = 1,
bool abort_on_first_error = false); bool abort_on_first_error = false);
protected: protected:

@ -19,7 +19,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/Visualization.h" #include "kaleidoscope/simulator/interface/Visualization.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/SimulatorCore_.h" #include "kaleidoscope/simulator/interface/SimulatorCore_.h"
#include "kaleidoscope/simulator/interface/aux/terminal_escape_sequences.h" #include "kaleidoscope/simulator/interface/aux/terminal_escape_sequences.h"
@ -113,7 +113,7 @@ class KeyboardRenderer {
const SimulatorCore_ &simulator_core_; const SimulatorCore_ &simulator_core_;
}; };
void renderKeyboard(const Simulator &simulator, const char *ascii_keyboard) { void renderKeyboard(const Simulator_ &simulator, const char *ascii_keyboard) {
KeyAddrToKeyString lookup; KeyAddrToKeyString lookup;
KeyboardRenderer kr{simulator.getCore()}; KeyboardRenderer kr{simulator.getCore()};

@ -24,7 +24,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief Renders a keyboard's asscii representation. /// @brief Renders a keyboard's asscii representation.
/// ///
@ -32,7 +32,7 @@ class Simulator;
/// @param ascii_keyboard The ascii representation of the keyboards /// @param ascii_keyboard The ascii representation of the keyboards
/// key layout. /// key layout.
/// ///
void renderKeyboard(const Simulator &simulator, const char *ascii_keyboard); void renderKeyboard(const Simulator_ &simulator, const char *ascii_keyboard);
} // namespace interface } // namespace interface
} // namespace simulator } // namespace simulator

@ -20,7 +20,7 @@
#include "kaleidoscope/simulator/interface/actions/Action_.h" #include "kaleidoscope/simulator/interface/actions/Action_.h"
#include "kaleidoscope/simulator/interface/aux/demangle.h" #include "kaleidoscope/simulator/interface/aux/demangle.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {

@ -31,7 +31,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
class Report_; class Report_;
/// @private /// @private
@ -87,7 +87,7 @@ class Action_ {
/// @brief Register the test simulator with the action. /// @brief Register the test simulator with the action.
/// ///
virtual void setSimulator(const Simulator *simulator) { virtual void setSimulator(const Simulator_ *simulator) {
simulator_ = simulator; simulator_ = simulator;
} }
@ -96,7 +96,7 @@ class Action_ {
/// ///
/// @return A pointer to the current test simulator. /// @return A pointer to the current test simulator.
/// ///
const Simulator *getSimulator() const { const Simulator_ *getSimulator() const {
return simulator_; return simulator_;
} }
@ -161,7 +161,7 @@ class Action_ {
protected: protected:
bool valid_ = false; bool valid_ = false;
const Simulator *simulator_ = nullptr; const Simulator_ *simulator_ = nullptr;
private: private:

@ -21,7 +21,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/actions/Action_.h" #include "kaleidoscope/simulator/interface/actions/Action_.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
@ -38,7 +38,7 @@ class AssertElapsedTimeGreater {
/// @param delta_t The amount of time that is asserted being elapsed. /// @param delta_t The amount of time that is asserted being elapsed.
/// @param start_t An optional start point in time as reference (defaults to zero). /// @param start_t An optional start point in time as reference (defaults to zero).
/// ///
AssertElapsedTimeGreater(Simulator::TimeType delta_t, Simulator::TimeType start_t = 0) AssertElapsedTimeGreater(Simulator_::TimeType delta_t, Simulator_::TimeType start_t = 0)
: AssertElapsedTimeGreater(DelegateConstruction{}, delta_t, start_t) : AssertElapsedTimeGreater(DelegateConstruction{}, delta_t, start_t)
{} {}
@ -48,7 +48,7 @@ class AssertElapsedTimeGreater {
public: public:
Action(Simulator::TimeType delta_t, Simulator::TimeType start_t = 0) Action(Simulator_::TimeType delta_t, Simulator_::TimeType start_t = 0)
: start_t_(start_t), : start_t_(start_t),
delta_t_(delta_t) delta_t_(delta_t)
{} {}
@ -68,8 +68,8 @@ class AssertElapsedTimeGreater {
private: private:
Simulator::TimeType start_t_ = .0; Simulator_::TimeType start_t_ = .0;
Simulator::TimeType delta_t_ = .0; Simulator_::TimeType delta_t_ = .0;
}; };
SIMULATOR_AUTO_DEFINE_ACTION_INVENTORY(AssertElapsedTimeGreater) SIMULATOR_AUTO_DEFINE_ACTION_INVENTORY(AssertElapsedTimeGreater)

@ -19,7 +19,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/actions/Grouped.h" #include "kaleidoscope/simulator/interface/actions/Grouped.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {

@ -20,7 +20,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
#include "kaleidoscope/simulator/interface/actions/Action_.h" #include "kaleidoscope/simulator/interface/actions/Action_.h"
#include "kaleidoscope/simulator/interface/actions/generic_report/ReportAction.h" #include "kaleidoscope/simulator/interface/actions/generic_report/ReportAction.h"
@ -59,7 +59,7 @@ class GroupedAction_ : public _ActionType {
} }
} }
virtual void setSimulator(const Simulator *simulator) override { virtual void setSimulator(const Simulator_ *simulator) override {
this->Action_::setSimulator(simulator); this->Action_::setSimulator(simulator);
for (auto &action : actions_) { for (auto &action : actions_) {

@ -21,7 +21,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/actions/Action_.h" #include "kaleidoscope/simulator/interface/actions/Action_.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {

@ -21,7 +21,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/interface/actions/generic_report/ReportAction.h" #include "kaleidoscope/simulator/interface/actions/generic_report/ReportAction.h"
#include "kaleidoscope/simulator/interface/Simulator.h" #include "kaleidoscope/simulator/interface/Simulator_.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {

@ -34,7 +34,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief An interface hat facilitates analyzing absolute mouse reports. /// @brief An interface hat facilitates analyzing absolute mouse reports.
/// ///

@ -35,7 +35,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief An interface hat facilitates analyzing boot keyboard reports. /// @brief An interface hat facilitates analyzing boot keyboard reports.
/// ///

@ -35,7 +35,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief An interface hat facilitates analyzing keyboard reports. /// @brief An interface hat facilitates analyzing keyboard reports.
/// ///

@ -34,7 +34,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
/// @brief An interface hat facilitates analyzing mouse reports. /// @brief An interface hat facilitates analyzing mouse reports.
/// ///

@ -34,7 +34,7 @@ namespace kaleidoscope {
namespace simulator { namespace simulator {
namespace interface { namespace interface {
class Simulator; class Simulator_;
enum { enum {
AnyTypeReportTypeId = 0, AnyTypeReportTypeId = 0,
@ -74,7 +74,7 @@ class Report_ {
/// to the simulator's log stream. /// to the simulator's log stream.
/// @param add_indent An additional indentation string. /// @param add_indent An additional indentation string.
/// ///
virtual void dump(const Simulator &simulator, const char *add_indent = "") const = 0; virtual void dump(const Simulator_ &simulator, const char *add_indent = "") const = 0;
static const char *typeString() { static const char *typeString() {
return "generic report"; return "generic report";

Loading…
Cancel
Save