commit 4fb58b4324b9eef86cb0fe18abba9532676559e7 Author: Gary Talent Date: Sun Oct 14 19:07:06 2018 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b823a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +dist +build diff --git a/.liccor.yml b/.liccor.yml new file mode 100644 index 0000000..7614823 --- /dev/null +++ b/.liccor.yml @@ -0,0 +1,9 @@ +--- +source: +- src +copyright_notice: |- + Copyright 2018 gtalent2@gmail.com + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5148451 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 2.8.8) + +project(bullock) + +set(QTDIR "" CACHE STRING "Path to Qt Libraries") + +set(CMAKE_PREFIX_PATH ${QTDIR}) +find_package(Qt5 COMPONENTS Core Network Widgets REQUIRED) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) +include(address_sanitizer) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DDEBUG) +else() + add_definitions(-DNDEBUG) +endif() + +if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare") + + if (CMAKE_BUILD_TYPE STREQUAL "Release") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # forces colored output when using ninja + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") + endif() +endif() + +if(APPLE) + set(CMAKE_MACOSX_RPATH OFF) + set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Library/bullock") + set(BULLOCK_DIST_BIN bullock.app/Contents/MacOS) + set(BULLOCK_DIST_LIB bullock.app/Contents/Library) + set(BULLOCK_DIST_PLUGIN bullock.app/Contents/Plugins) + set(BULLOCK_DIST_RESOURCES bullock.app/Contents/Resources) + set(BULLOCK_DIST_MAC_APP_CONTENTS bullock.app/Contents) +else() + set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib/bullock") + if(NOT ${QTDIR} STREQUAL "") + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} "${QTDIR}/lib") + endif() + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(BULLOCK_DIST_BIN bin) + set(BULLOCK_DIST_LIB lib) + set(BULLOCK_DIST_RESOURCES share) +endif() + +enable_testing() + +add_subdirectory(src) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9e45dc9 --- /dev/null +++ b/Makefile @@ -0,0 +1,82 @@ +OS=$(shell uname | tr [:upper:] [:lower:]) +HOST_ENV=${OS}-$(shell uname -m) +DEVENV=devenv$(shell pwd | sed 's/\//-/g') +DEVENV_IMAGE=bullock-devenv +ifneq ($(shell which gmake 2> /dev/null),) + MAKE=gmake -s +else + MAKE=make -s +endif +ifneq ($(shell which docker 2> /dev/null),) + ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running) + ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV} + endif +endif + +make: + ${ENV_RUN} ./scripts/run-make build +gba-pkg: + ${ENV_RUN} ./scripts/run-make build install + ${ENV_RUN} ./scripts/run-make build + ${ENV_RUN} ./scripts/gba-pkg +preinstall: + ${ENV_RUN} ./scripts/run-make build preinstall +install: + ${ENV_RUN} ./scripts/run-make build install +clean: + ${ENV_RUN} ./scripts/run-make build clean +purge: + ${ENV_RUN} rm -rf build +test: + ${ENV_RUN} ./scripts/run-make build test + +run: install + ./dist/current/bin/bullock + +devenv-image: + docker build . -t ${DEVENV_IMAGE} +devenv-create: + docker run -d \ + -e LOCAL_USER_ID=$(shell id -u ${USER}) \ + -e DISPLAY=$(DISPLAY) \ + -e QT_AUTO_SCREEN_SCALE_FACTOR=1 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -v /run/dbus/:/run/dbus/ \ + -v $(shell pwd):/usr/src/project \ + -v /dev/shm:/dev/shm \ + --restart=always \ + --name ${DEVENV} \ + -t ${DEVENV_IMAGE} bash +devenv-destroy: + docker rm -f ${DEVENV} + +shell: + ${ENV_RUN} bash + +release: + ${ENV_RUN} rm -rf build/${HOST_ENV}-release + ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} release + +debug: + ${ENV_RUN} rm -rf build/${HOST_ENV}-debug + ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} debug + +asan: + ${ENV_RUN} rm -rf build/${HOST_ENV}-asan + ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} asan + +windows: + ${ENV_RUN} rm -rf build/windows + ${ENV_RUN} ./scripts/setup-build.ps1 windows + +windows-debug: + ${ENV_RUN} rm -rf build/windows + ${ENV_RUN} ./scripts/setup-build.ps1 windows debug + +gba: + ${ENV_RUN} rm -rf build/gba-release + ${ENV_RUN} ./scripts/setup-build.ps1 gba release + +gba-debug: + ${ENV_RUN} rm -rf build/gba-debug + ${ENV_RUN} ./scripts/setup-build.ps1 gba debug diff --git a/cmake/modules/address_sanitizer.cmake b/cmake/modules/address_sanitizer.cmake new file mode 100644 index 0000000..f1076b2 --- /dev/null +++ b/cmake/modules/address_sanitizer.cmake @@ -0,0 +1,52 @@ +# This file belongs Nick Overdijk, and is from https://github.com/NickNick/wubwubcmake +# The MIT License (MIT) +# +# Copyright (c) 2013 Nick Overdijk +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.option(USE_ASAN "Enable Address Sanitizer, if your compiler supports it" ON) + +option(USE_ASAN "Enable Address Sanitizer, if your compiler supports it" OFF) +if(USE_ASAN) + include(CheckCXXSourceCompiles) + # If the compiler understands -fsanitize=address, add it to the flags (gcc since 4.8 & clang since version 3.2) + set(CMAKE_REQUIRED_FLAGS_BAK "${CMAKE_REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize=address") + CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" FLAG_FSANA_SUPPORTED) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_BAK}") + + if(FLAG_FSANA_SUPPORTED) + set(asan_flag "-fsanitize=address") + else(FLAG_FSANA_SUPPORTED) + # Alternatively, try if it understands -faddress-sanitizer (clang until version 3.2) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -faddress-sanitizer") + CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" FLAG_FASAN_SUPPORTED) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_BAK}") + + if(FLAG_FASAN_SUPPORTED) + set(asan_flag "-faddress-sanitizer") + endif(FLAG_FASAN_SUPPORTED) + endif(FLAG_FSANA_SUPPORTED) + + if(FLAG_FSANA_SUPPORTED OR FLAG_FASAN_SUPPORTED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${asan_flag}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${asan_flag}") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${asan_flag}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${asan_flag}") + endif() + +endif(USE_ASAN) diff --git a/scripts/run-make b/scripts/run-make new file mode 100755 index 0000000..28dfe61 --- /dev/null +++ b/scripts/run-make @@ -0,0 +1,8 @@ +#! /usr/bin/env bash + +set -e + +for f in $(find $1 -maxdepth 1 -mindepth 1 -type d) +do + cmake --build "$f" --target $2 +done diff --git a/scripts/setup-build.ps1 b/scripts/setup-build.ps1 new file mode 100755 index 0000000..3ef3f43 --- /dev/null +++ b/scripts/setup-build.ps1 @@ -0,0 +1,51 @@ +#! /usr/bin/env pwsh + +Param( + [parameter(Mandatory=$true,Position=0)][String] ${target}, + [parameter(Mandatory=$true,Position=1)][String] ${buildType} +) + +$project=(Get-Location).Path + +if (${target} -eq "windows") { + $toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake" +} elseif (${target} -eq "gba") { + $toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake" + $oxUseStdLib="-DOX_USE_STDLIB=OFF" +} + +if (${buildType} -eq "asan") { + $buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug" +} elseif (${buildType} -eq "debug") { + $buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug" +} elseif (${buildType} -eq "release") { + $buildTypeArgs="-DCMAKE_BUILD_TYPE=Release" +} + +if (${env:QTDIR} -ne "") { + $qtPath="-DQTDIR=${env:QTDIR}" +} + +$buildDir="${project}/build/${target}-${buildType}" +$distDir="${project}/dist/${target}-${buildType}" + +New-Item -ItemType Directory -Path $buildDir | Out-Null +Push-Location $buildDir +cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ` + -DCMAKE_INSTALL_PREFIX="$distDir" ` + -G Ninja ` + $buildTool ` + $nostalgiaBuildType ` + $oxUseStdLib ` + $buildTypeArgs ` + $qtPath ` + $toolchain ` + $project +Pop-Location + +rm -f build/current dist/current +if (!(Test-Path -Path dist)) { + New-Item -ItemType Directory -Path dist | Out-Null +} +ln -s ${target}-${buildType} build/current +ln -s ${target}-${buildType} dist/current diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..0dc8372 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,36 @@ +project(bullock) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +find_package(Qt5Widgets) +set(CMAKE_AUTOMOC ON) + +add_executable( + bullock MACOSX_BUNDLE + main.cpp + mainwindow.cpp + processdata.cpp + procselector.cpp + server.cpp + traceeventmodel.cpp + traceview.cpp +) + +target_link_libraries( + bullock + Qt5::Core + Qt5::Network + Qt5::Widgets +) + +if(APPLE) + set_target_properties(bullock PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) +endif() + +install( + TARGETS + bullock + RUNTIME DESTINATION + ${BULLOCK_DIST_BIN} + BUNDLE DESTINATION . +) diff --git a/src/Info.plist b/src/Info.plist new file mode 100644 index 0000000..3dc7523 --- /dev/null +++ b/src/Info.plist @@ -0,0 +1,29 @@ + + + + + CFBundleExecutable + nostalgia-studio + CFBundleGetInfoString + Nostalgia Studio + CFBundleIconFile + + CFBundleIdentifier + net.drinkingtea.nostalgia.studio + CFBundlePackageType + APPL + CFBundleVersion + 1.2.8 + LSMinimumSystemVersion + 10.13.0 + + + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + + NSHumanReadableCopyright + Copyright (c) 2016-2018 Gary Talent <gtalent2@gmail.com> + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..bde818c --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "server.hpp" +#include "mainwindow.hpp" + +int main(int argc, char **args) { + QApplication app(argc, args); + + LogServer server; + + MainWindow w; + app.setApplicationName(w.windowTitle()); + w.show(); + + QObject::connect(&server, &LogServer::newDataFeed, &w, &MainWindow::addDataFeed); + + return app.exec(); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..4a69c8c --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "traceview.hpp" + +#include "mainwindow.hpp" + +MainWindow::MainWindow() { + setWindowTitle(tr("Bullock")); + + auto screenSize = QApplication::desktop()->screenGeometry(); + constexpr auto sizePct = 0.85; + resize(screenSize.width() * sizePct, screenSize.height() * sizePct); + move(-x(), -y()); + move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2); + + auto central = new QWidget(this); + auto splitter = new QSplitter(central); + + auto leftPane = new QWidget(this); + auto leftPaneSplitter = new QSplitter(Qt::Vertical, leftPane); + m_procSelector = new ProcessSelector(leftPaneSplitter); + leftPaneSplitter->addWidget(m_procSelector); + + splitter->addWidget(leftPaneSplitter); + splitter->addWidget(new TraceView(splitter)); + splitter->setStretchFactor(1, 3); + + setCentralWidget(splitter); + setupMenu(); +} + +MainWindow::~MainWindow() { +} + +void MainWindow::addDataFeed(DataFeed *feed) { + m_procData.push_back(feed->procData()); + auto time = QDateTime::currentDateTime(); + m_procSelector->addProcess(time.toString()); +} + +void MainWindow::setupMenu() { + auto menu = menuBar(); + auto fileMenu = menu->addMenu(tr("&File")); + auto helpMenu = menu->addMenu(tr("&Help")); + + auto quit = fileMenu->addAction(tr("&Quit")); + quit->setShortcuts(QKeySequence::Quit); + quit->setStatusTip(tr("Quit application")); + connect(quit, &QAction::triggered, this, &MainWindow::close); + + helpMenu->addAction(tr("&About")); +} diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp new file mode 100644 index 0000000..abb1f4a --- /dev/null +++ b/src/mainwindow.hpp @@ -0,0 +1,32 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "procselector.hpp" +#include "server.hpp" + +class MainWindow: public QMainWindow { + Q_OBJECT + + private: + QVector> m_procData; + ProcessSelector *m_procSelector = nullptr; + + public: + MainWindow(); + + ~MainWindow(); + + public slots: + void addDataFeed(DataFeed*); + + private: + void setupMenu(); + +}; diff --git a/src/processdata.cpp b/src/processdata.cpp new file mode 100644 index 0000000..18f17c9 --- /dev/null +++ b/src/processdata.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "processdata.hpp" + +Field::Field(QJsonObject field) { + this->name = field["name"].toString(); + this->type = field["field_type"].toString(); + this->value = field["value"].toString(); + auto fields = field["fields"].toArray(); + for (auto field : fields) { + this->fields.push_back(field.toObject()); + } +} + +Frame::Frame(QJsonObject frame) { + this->arch = frame["arch"].toString(); + this->file = frame["file"].toString(); + this->line = frame["line"].toDouble(); + auto fields = frame["fields"].toArray(); + for (auto field : fields) { + this->fields.push_back(field.toObject()); + } +} + +TraceEvent::TraceEvent(QJsonObject tp) { + this->logMsg = tp["trace_msg"].toString(); + auto frames = tp["frames"].toArray(); + for (auto frame : frames) { + this->frames.push_back(frame.toObject()); + } +} + diff --git a/src/processdata.hpp b/src/processdata.hpp new file mode 100644 index 0000000..0328e00 --- /dev/null +++ b/src/processdata.hpp @@ -0,0 +1,47 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include + +struct Field { + QString name; + QString type; + QString value; + QVector fields; + + Field(QJsonObject field = {}); + +}; + +struct Frame { + QString arch; + QString file; + int line = 0; + QVector fields; + + Frame(QJsonObject frame = {}); + +}; + +struct TraceEvent { + QString channel; + QString logMsg; + QVector frames; + + TraceEvent(QJsonObject tp = {}); + +}; + +struct ProcessData { + QString cmd; + QVector traceEvents; +}; diff --git a/src/procselector.cpp b/src/procselector.cpp new file mode 100644 index 0000000..b452c00 --- /dev/null +++ b/src/procselector.cpp @@ -0,0 +1,20 @@ + +#include +#include + +#include "procselector.hpp" + +ProcessSelector::ProcessSelector(QWidget *parent): QWidget(parent) { + auto lyt = new QVBoxLayout(this); + lyt->addWidget(new QLabel(tr("Processes"), this)); + lyt->addWidget(m_list); + m_list->addItem(tr("Most Recent")); + m_list->setCurrentRow(RowLatest); +} + +void ProcessSelector::addProcess(QString procKey) { + m_list->insertItem(1, procKey); + if (m_list->currentRow() == RowLatest) { + emit selectionChanged(procKey); + } +} diff --git a/src/procselector.hpp b/src/procselector.hpp new file mode 100644 index 0000000..edad308 --- /dev/null +++ b/src/procselector.hpp @@ -0,0 +1,33 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include + +class ProcessSelector: public QWidget { + Q_OBJECT + + private: + enum Rows { + RowLatest = 0 + }; + + QListWidget *m_list = new QListWidget(this); + + public: + ProcessSelector(QWidget *parent = nullptr); + + public slots: + void addProcess(QString procKey); + + signals: + void selectionChanged(QString procKey); + +}; diff --git a/src/server.cpp b/src/server.cpp new file mode 100644 index 0000000..ec22421 --- /dev/null +++ b/src/server.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "server.hpp" + +DataFeed::DataFeed(QIODevice *dev): QObject(dev) { + m_dev = dev; + connect(m_dev, &QIODevice::readyRead, this, &DataFeed::handleInit); +} + +QSharedPointer DataFeed::procData() { + return m_procData; +} + +void DataFeed::handleInit() { + auto doc = QJsonDocument::fromJson(m_dev->readLine()); + if (doc.isObject()) { + auto msg = doc.object(); + if (msg["type"].toString() == "Init") { + disconnect(m_dev, &QIODevice::readyRead, this, &DataFeed::handleInit); + connect(m_dev, &QIODevice::readyRead, this, &DataFeed::read); + } + } +} + +void DataFeed::read() { + while (m_dev->bytesAvailable()) { + auto doc = QJsonDocument::fromJson(m_dev->readLine()); + if (m_procData) { + m_procData->traceEvents.push_back(doc.object()); + } + } +} + + +LogServer::LogServer() { + m_server->listen(QHostAddress::LocalHost, 5590); + connect(m_server, &QTcpServer::newConnection, this, &LogServer::handleConnection); +} + +void LogServer::handleConnection() { + auto conn = m_server->nextPendingConnection(); + connect(conn, &QAbstractSocket::disconnected, conn, &QObject::deleteLater); + connect(this, &QObject::destroyed, conn, &QObject::deleteLater); + emit newDataFeed(new DataFeed(conn)); +} diff --git a/src/server.hpp b/src/server.hpp new file mode 100644 index 0000000..e2d0397 --- /dev/null +++ b/src/server.hpp @@ -0,0 +1,53 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include "processdata.hpp" + +class DataFeed: public QObject { + Q_OBJECT + + private: + QSharedPointer m_procData = QSharedPointer(new ProcessData); + QIODevice *m_dev = nullptr; + + public: + DataFeed(QIODevice *dev); + + QSharedPointer procData(); + + public slots: + void handleInit(); + + void read(); +}; + +class LogServer: public QObject { + Q_OBJECT + + private: + QPointer m_server = new QTcpServer(this); + + public: + LogServer(); + + public slots: + void handleConnection(); + + signals: + void newDataFeed(DataFeed*); +}; diff --git a/src/traceeventmodel.cpp b/src/traceeventmodel.cpp new file mode 100644 index 0000000..e572bba --- /dev/null +++ b/src/traceeventmodel.cpp @@ -0,0 +1,25 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "traceeventmodel.hpp" + +int TraceEventModel::rowCount(const QModelIndex &parent) const { + if (m_procData) { + return m_procData->traceEvents.size(); + } else { + return 0; + } +} + +int TraceEventModel::columnCount(const QModelIndex &parent) const { + return Column::End; +} + +QVariant TraceEventModel::data(const QModelIndex &index, int role) const { + return {}; +} diff --git a/src/traceeventmodel.hpp b/src/traceeventmodel.hpp new file mode 100644 index 0000000..046f11b --- /dev/null +++ b/src/traceeventmodel.hpp @@ -0,0 +1,34 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "processdata.hpp" + +#include + + +class TraceEventModel: public QAbstractItemModel { + Q_OBJECT + + private: + enum Column { + Channel, + Message, + End + }; + + ProcessData *m_procData = nullptr; + + public: + int rowCount(const QModelIndex &parent = QModelIndex()) const override ; + + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; +}; diff --git a/src/traceview.cpp b/src/traceview.cpp new file mode 100644 index 0000000..77d0838 --- /dev/null +++ b/src/traceview.cpp @@ -0,0 +1,18 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include + +#include "traceview.hpp" + +TraceView::TraceView(QWidget *parent): QWidget(parent) { + auto lyt = new QHBoxLayout; + setLayout(lyt); + lyt->addWidget(new QTableView(this)); +} diff --git a/src/traceview.hpp b/src/traceview.hpp new file mode 100644 index 0000000..336b913 --- /dev/null +++ b/src/traceview.hpp @@ -0,0 +1,19 @@ +/* + * Copyright 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +class TraceView: public QWidget { + Q_OBJECT + + public: + TraceView(QWidget *parent = nullptr); + +};