Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72945a05 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Add operator<< for printing some dispatcher structs

When working on dispatcher code, it's very convenient to be able to
quickly print some of the dispatcher structs, like TouchState,
TouchedWindow, etc. Add operator<< to some of these structs in this CL.

This removes the need to memorize the specific function that needs to be
called, like "dump", "getDescription", etc.

Bug: 211379801
Test: none
Change-Id: I663b217a3449daa34476ac6f28f188cdf0618278
parent 20836a57
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -269,6 +269,11 @@ std::string MotionEntry::getDescription() const {
    return msg;
}

std::ostream& operator<<(std::ostream& out, const MotionEntry& motionEntry) {
    out << motionEntry.getDescription();
    return out;
}

// --- SensorEntry ---

SensorEntry::SensorEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <utils/Timers.h>
#include <functional>
#include <ostream>
#include <string>

namespace android::inputdispatcher {
@@ -189,6 +190,8 @@ struct MotionEntry : EventEntry {
    ~MotionEntry() override;
};

std::ostream& operator<<(std::ostream& out, const MotionEntry& motionEntry);

struct SensorEntry : EventEntry {
    int32_t deviceId;
    uint32_t source;
+5 −0
Original line number Diff line number Diff line
@@ -288,4 +288,9 @@ std::string TouchState::dump() const {
    return out;
}

std::ostream& operator<<(std::ostream& out, const TouchState& state) {
    out << state.dump();
    return out;
}

} // namespace android::inputdispatcher
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include <bitset>
#include <ostream>
#include <set>
#include "TouchedWindow.h"

@@ -79,5 +80,7 @@ struct TouchState {
    std::string dump() const;
};

std::ostream& operator<<(std::ostream& out, const TouchState& state);

} // namespace inputdispatcher
} // namespace android
+5 −0
Original line number Diff line number Diff line
@@ -256,5 +256,10 @@ std::string TouchedWindow::dump() const {
    return out;
}

std::ostream& operator<<(std::ostream& out, const TouchedWindow& window) {
    out << window.dump();
    return out;
}

} // namespace inputdispatcher
} // namespace android
Loading