From 8785596ba2d84d334b3e7df78a167d3c9021a523 Mon Sep 17 00:00:00 2001 From: "Marcel M. Otte" Date: Wed, 30 Dec 2020 12:46:05 +0100 Subject: [PATCH] unknown state of work --- doc/model.md | 171 +++++++++++++------------ src/core/CMakeLists.txt | 16 +-- src/core/control/FieldFactory.cpp | 19 ++- src/core/control/FieldFactory.h | 9 +- src/core/control/ModelFactory.cpp | 6 +- src/core/control/ModelFactory.h | 4 +- src/core/control/RepositoryFactory.cpp | 8 ++ src/core/control/RepositoryFactory.h | 4 +- src/core/control/RepositoryFactorycpp | 8 -- src/core/control/StructureFactory.cpp | 6 +- src/core/control/StructureFactory.h | 4 +- src/core/model/Field.cpp | 4 +- src/core/model/Field.h | 4 +- src/core/model/Model.cpp | 4 +- src/core/model/Model.h | 4 +- src/core/model/Repository.cpp | 4 +- src/core/model/Repository.h | 4 +- src/core/model/Structure.cpp | 20 ++- src/core/model/Structure.h | 4 +- src/editor/CMakeLists.txt | 2 + src/editor/StackContainer.cpp | 6 + src/editor/StackContainer.h | 26 ++++ src/editor/StructureField.cpp | 7 +- src/editor/StructureField.h | 9 +- 24 files changed, 211 insertions(+), 142 deletions(-) create mode 100644 src/core/control/RepositoryFactory.cpp delete mode 100644 src/core/control/RepositoryFactorycpp create mode 100644 src/editor/StackContainer.cpp create mode 100644 src/editor/StackContainer.h diff --git a/doc/model.md b/doc/model.md index 85f485e..dfb98d1 100644 --- a/doc/model.md +++ b/doc/model.md @@ -1,106 +1,115 @@ -# NPC core +# NPC ```plantuml -abstract class ARepository -abstract class ARepositoryFactory -class RepositoryFactory -class Repository { - +addStructure() - +removeStructure() - +getStructure() + +package Core { + + package Control { + class RepositoryFactory + class ModelFactory + class StructureFactory + class FieldFactory{ + + createField() + } + } + + package Model as PKGmodel { + class Repository { + +addStructure() + +removeStructure() + +getStructure() + } + class Model { + +getBinary():byte[] + +getStructures():Structure[] + +addStructure() + +removeStructure() + } + class Structure { + -name + -description + -fields + -data + +putData(Field, data) + +validateData(Field, data) + +updateData() + } + class Field { + - owningStructure + - binary + - logical + - visual + - representation + } + } + +} +package Editor { + class MainWindow + class DockWidget_Tools + class DockWidget_Helpers + class StackContainer + class Syntax + class Name + class Input + class Representation + class StructureField + + StructureField *-- Syntax + StructureField *-- Name + StructureField *-- Input + StructureField *-- Representation + + MainWindow *- StackContainer: as centralWidget } -abstract class AStackModelFactory -class StackModelFactory -abstract class AStackModel -class StackModel { - +getBinary():byte[] - +getStructures():Structure[] - +addStructure() - +removeStructure() -} - -abstract class AStructureFactory -class StructureFactory -abstract class AStructure -class Structure { - -name - -description - -fields - -data - +putData(Field, data) - +validateData(Field, data) - +updateData() -} - -abstract class AFieldFactory{ -+ createField() -+ createFieldBinaryInformation() -+ createFieldLogicalInformation() -+ createFieldVisualInformation() -+ createFieldRepresentation() -} -class FieldFactory -abstract class AField -class Field { - - owningStructure - - binary - - logical - - visual - - representation -} class RandomAccessBinary { - binaryData + setBytes(uint position, std::vector data) -+ setByte(uint position, uint8_t data) + + setByte(uint position, uint8_t data) -+ setBit(uint64_t position, bool value) -+ setBit(uint bytePosition, uint bitPosition, bool value) -+ setBits(uint64_t position, uint bits, uint value) -+ setBits(uint bytePosition, uint bitPosition, uint bits, uint value) + + setBit(uint64_t position, bool value) + + setBit(uint bytePosition, uint bitPosition, bool value) + + setBits(uint64_t position, uint bits, uint value) + + setBits(uint bytePosition, uint bitPosition, uint bits, uint value) -+ getByte(uint position) -+ getBytes(uint position, uint bytes) + + getByte(uint position) + + getBytes(uint position, uint bytes) -+ getBit(uint64_t position) -+ getBit(uint bytePosition, uint bitPosition) -+ getBits(uint64_t position, uint bits) -+ getBits(uint bytePosition, uint bitPosition, uint bits) + + getBit(uint64_t position) + + getBit(uint bytePosition, uint bitPosition) + + getBits(uint64_t position, uint bits) + + getBits(uint bytePosition, uint bitPosition, uint bits) -+ get_uint32(uint position) -+ get_uint16(uint position) -+ get_uint64(uint position) -+ get_float(uint position) -+ get_double(uint position) + + get_uint32(uint position) + + get_uint16(uint position) + + get_uint64(uint position) + + get_float(uint position) + + get_double(uint position) -+ get_string(uint position, uint length) + + get_string(uint position, uint length) -+ get_hex_string(uint position, uint length) -+ get_hex_string() + + get_hex_string(uint position, uint length) + + get_hex_string() } -ARepositoryFactory <|-- RepositoryFactory -ARepository <|-- Repository RepositoryFactory --> Repository : creates > -AStackModelFactory <|-- StackModelFactory -AStackModel <|-- StackModel -StackModelFactory --> StackModel: creates > +ModelFactory -> Model: creates > -AStructureFactory <|-- StructureFactory -AStructure <|-- Structure -StructureFactory --> Structure : creates > -StackModel *-- Structure -Repository *-- Structure +StructureFactory -> Structure : creates > +Model *- Structure +Repository *- Structure -AFieldFactory <|-- FieldFactory -AField <|-- Field -FieldFactory --> Field : creates > +FieldFactory -> Field : creates > -Structure *-- Field +Structure *- Field -StackModel *-- "1" RandomAccessBinary +Model *-- "1" RandomAccessBinary + +StructureField *-- Field +StackContainer *-- StructureField ``` diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a7a8470..502cdc4 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -8,10 +8,10 @@ set(HEADERS model/Model.h model/Structure.h model/Field.h - control/ARepositoryFactory.h - control/AFieldFactory.h - control/AStructureFactory.h - control/AModelFactory.h + control/RepositoryFactory.h + control/FieldFactory.h + control/StructureFactory.h + control/ModelFactory.h schemaio/AStructureReaderFactory.h schemaio/AStructureWriterFactory.h @@ -28,10 +28,10 @@ set(SOURCES model/Model.cpp model/Structure.cpp model/Field.cpp - control/ARepositoryFactory.cpp - control/AFieldFactory.cpp - control/AStructureFactory.cpp - control/AModelFactory.cpp + control/RepositoryFactory.cpp + control/FieldFactory.cpp + control/StructureFactory.cpp + control/ModelFactory.cpp schemaio/AStructureReaderFactory.cpp schemaio/AStructureWriterFactory.cpp diff --git a/src/core/control/FieldFactory.cpp b/src/core/control/FieldFactory.cpp index d967a80..dde992f 100644 --- a/src/core/control/FieldFactory.cpp +++ b/src/core/control/FieldFactory.cpp @@ -1,5 +1,5 @@ -#include "AFieldFactory.h" -namespace NPC_core { +#include "FieldFactory.h" +namespace NPC { namespace core { namespace Control { FieldFactory::FieldFactory() { @@ -14,12 +14,17 @@ std::shared_ptr FieldFactory::createField(std::string name, std::s return f; } -std::shared_ptr FieldFactory::createFieldFull(std::string name, std::map syntaxes, std::shared_ptr parentStructure) +std::shared_ptr FieldFactory::createFieldFull(std::string name, std::shared_ptr> syntaxes, std::shared_ptr parentStructure) { - auto f = std::make_shared(); - f->setName(name); + auto f = this->createField(name, parentStructure); f->setSyntaxes(syntaxes); - f->setParentStructure(parentStructure); return f; } -}} + +std::shared_ptr FieldFactory::createFieldWithPredefinedValues(std::string name, std::shared_ptr > choosableValues, std::shared_ptr > syntaxes, std::shared_ptr parentStructure) +{ + auto f = this->createFieldFull(name, syntaxes, parentStructure); + f->setChooseableValues(choosableValues); + return f; +} +}}} diff --git a/src/core/control/FieldFactory.h b/src/core/control/FieldFactory.h index e72c9f2..2424573 100644 --- a/src/core/control/FieldFactory.h +++ b/src/core/control/FieldFactory.h @@ -4,7 +4,7 @@ #include "../model/Field.h" #include -namespace NPC_core { +namespace NPC { namespace core { namespace Control { class FieldFactory { @@ -13,7 +13,10 @@ public: virtual ~FieldFactory(); virtual std::shared_ptr createField(std::string name, std::shared_ptr parentStructure = nullptr); - virtual std::shared_ptr createFieldFull(std::string name, std::map syntaxes, std::shared_ptr parentStructure = nullptr); + virtual std::shared_ptr createFieldFull(std::string name, std::shared_ptr> syntaxes, std::shared_ptr parentStructure = nullptr); + virtual std::shared_ptr createFieldWithPredefinedValues(std::string name, std::shared_ptr> choosableValues, + std::shared_ptr> syntaxes, + std::shared_ptr parentStructure = nullptr); }; -}} +}}} #endif // AFIELDFACTORY_H diff --git a/src/core/control/ModelFactory.cpp b/src/core/control/ModelFactory.cpp index 3827248..2eeb6c6 100644 --- a/src/core/control/ModelFactory.cpp +++ b/src/core/control/ModelFactory.cpp @@ -1,8 +1,8 @@ -#include "AModelFactory.h" -namespace NPC_core { +#include "ModelFactory.h" +namespace NPC { namespace core { namespace Control { ModelFactory::ModelFactory() { } -}} +}}} diff --git a/src/core/control/ModelFactory.h b/src/core/control/ModelFactory.h index 4ab9b26..47aa16e 100644 --- a/src/core/control/ModelFactory.h +++ b/src/core/control/ModelFactory.h @@ -1,12 +1,12 @@ #ifndef AMODELFACTORY_H #define AMODELFACTORY_H -namespace NPC_core { +namespace NPC { namespace core { namespace Control { class ModelFactory { public: ModelFactory(); }; -}} +}}} #endif // AMODELFACTORY_H diff --git a/src/core/control/RepositoryFactory.cpp b/src/core/control/RepositoryFactory.cpp new file mode 100644 index 0000000..2476f15 --- /dev/null +++ b/src/core/control/RepositoryFactory.cpp @@ -0,0 +1,8 @@ +#include "RepositoryFactory.h" +namespace NPC { namespace core { +namespace Control { +RepositoryFactory::RepositoryFactory() +{ + +} +}}} diff --git a/src/core/control/RepositoryFactory.h b/src/core/control/RepositoryFactory.h index 3d57bf9..3e74eb5 100644 --- a/src/core/control/RepositoryFactory.h +++ b/src/core/control/RepositoryFactory.h @@ -1,12 +1,12 @@ #ifndef AREPOSITORYFACTORY_H #define AREPOSITORYFACTORY_H -namespace NPC_core { +namespace NPC { namespace core { namespace Control { class RepositoryFactory { public: RepositoryFactory(); }; -}} +}}} #endif // AREPOSITORYFACTORY_H diff --git a/src/core/control/RepositoryFactorycpp b/src/core/control/RepositoryFactorycpp deleted file mode 100644 index e2f9cfd..0000000 --- a/src/core/control/RepositoryFactorycpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "ARepositoryFactory.h" -namespace NPC_core { -namespace Control { -RepositoryFactory::RepositoryFactory() -{ - -} -}} diff --git a/src/core/control/StructureFactory.cpp b/src/core/control/StructureFactory.cpp index bbe37ec..350554b 100644 --- a/src/core/control/StructureFactory.cpp +++ b/src/core/control/StructureFactory.cpp @@ -1,8 +1,8 @@ -#include "AStructureFactory.h" -namespace NPC_core { +#include "StructureFactory.h" +namespace NPC { namespace core { namespace Control { StructureFactory::StructureFactory() { } -}} +}}} diff --git a/src/core/control/StructureFactory.h b/src/core/control/StructureFactory.h index 8d71c69..7adf407 100644 --- a/src/core/control/StructureFactory.h +++ b/src/core/control/StructureFactory.h @@ -1,12 +1,12 @@ #ifndef ASTRUCTUREFACTORY_H #define ASTRUCTUREFACTORY_H -namespace NPC_core { +namespace NPC { namespace core { namespace Control { class StructureFactory { public: StructureFactory(); }; -}} +}}} #endif // ASTRUCTUREFACTORY_H diff --git a/src/core/model/Field.cpp b/src/core/model/Field.cpp index 18ba7a2..b3891b8 100644 --- a/src/core/model/Field.cpp +++ b/src/core/model/Field.cpp @@ -1,6 +1,6 @@ #include "Field.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { Field::Field() { @@ -58,4 +58,4 @@ void Field::setChooseableValues(const std::shared_ptr #include -namespace NPC_core { +namespace NPC { namespace core { namespace Model { class Structure; @@ -39,6 +39,6 @@ protected: std::string value; std::shared_ptr> chooseableValues; }; -}} +}}} #endif // AFIELD_H diff --git a/src/core/model/Model.cpp b/src/core/model/Model.cpp index 5a0ca97..007f52b 100644 --- a/src/core/model/Model.cpp +++ b/src/core/model/Model.cpp @@ -1,8 +1,8 @@ #include "Model.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { Model::Model() { } -}} +}}} diff --git a/src/core/model/Model.h b/src/core/model/Model.h index 92287c7..c6df3a4 100644 --- a/src/core/model/Model.h +++ b/src/core/model/Model.h @@ -4,7 +4,7 @@ #include "../Tree.h" #include "Field.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { class Model { @@ -15,5 +15,5 @@ public: private: Tree stack; }; -}} +}}} #endif // AMODEL_H diff --git a/src/core/model/Repository.cpp b/src/core/model/Repository.cpp index bc3c2c2..2ec8e05 100644 --- a/src/core/model/Repository.cpp +++ b/src/core/model/Repository.cpp @@ -1,8 +1,8 @@ #include "Repository.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { Repository::Repository() { } -}} +}}} diff --git a/src/core/model/Repository.h b/src/core/model/Repository.h index d8bf141..c59f169 100644 --- a/src/core/model/Repository.h +++ b/src/core/model/Repository.h @@ -4,7 +4,7 @@ #include #include "Structure.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { class Repository { @@ -15,5 +15,5 @@ public: private: std::map structures; }; -}} +}}} #endif // AREPOSITORY_H diff --git a/src/core/model/Structure.cpp b/src/core/model/Structure.cpp index 5e13dc4..647c902 100644 --- a/src/core/model/Structure.cpp +++ b/src/core/model/Structure.cpp @@ -1,5 +1,5 @@ #include "Structure.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { Structure::Structure() { @@ -25,4 +25,20 @@ void Structure::setLayer(const uint &value) { layer = value; } -}} + +std::shared_ptr > Structure::getElements() const +{ + return elements; +} + +void Structure::setElements(const std::shared_ptr > &value) +{ + elements = value; +} + +std::shared_ptr > Structure::getElementCopy() +{ + if(elements != nullptr) + return elements->getRoot()->rcopy(); +} +}}} diff --git a/src/core/model/Structure.h b/src/core/model/Structure.h index a66ad41..7822ea7 100644 --- a/src/core/model/Structure.h +++ b/src/core/model/Structure.h @@ -6,7 +6,7 @@ #include "Field.h" #include "../Tree.h" -namespace NPC_core { +namespace NPC { namespace core { namespace Model { class Field; @@ -28,6 +28,6 @@ private: std::string name; uint layer; }; -}} +}}} #endif // ASTRUCTURE_H diff --git a/src/editor/CMakeLists.txt b/src/editor/CMakeLists.txt index d04d9b0..987e4c4 100644 --- a/src/editor/CMakeLists.txt +++ b/src/editor/CMakeLists.txt @@ -2,11 +2,13 @@ set(HEADERS flowlayout.h StructureField.h + StackContainer.h ) set(SOURCES flowlayout.cpp StructureField.cpp + StackContainer.cpp ) add_library(editor ${HEADERS} ${SOURCES}) diff --git a/src/editor/StackContainer.cpp b/src/editor/StackContainer.cpp new file mode 100644 index 0000000..10885cb --- /dev/null +++ b/src/editor/StackContainer.cpp @@ -0,0 +1,6 @@ +#include "StackContainer.h" +using namespace NPC::editor; +StackContainer::StackContainer(QWidget *parent) : QWidget(parent) +{ + +} diff --git a/src/editor/StackContainer.h b/src/editor/StackContainer.h new file mode 100644 index 0000000..6a287ee --- /dev/null +++ b/src/editor/StackContainer.h @@ -0,0 +1,26 @@ +#ifndef STACKCONTAINER_H +#define STACKCONTAINER_H + +#include +#include +#include "../core/model/Model.h" + +namespace NPC { +namespace editor { + + +class StackContainer : public QWidget +{ + Q_OBJECT +public: + explicit StackContainer(QWidget *parent = nullptr); + void setModel(std::shared_ptr model); + +signals: + +public slots: +}; + +}} + +#endif // STACKCONTAINER_H diff --git a/src/editor/StructureField.cpp b/src/editor/StructureField.cpp index 25c2282..8ea0127 100644 --- a/src/editor/StructureField.cpp +++ b/src/editor/StructureField.cpp @@ -1,6 +1,7 @@ #include "StructureField.h" -namespace NPC_editor { +namespace NPC { +namespace editor { StructureField::StructureField(QWidget *parent) : QWidget(parent) { @@ -14,7 +15,7 @@ StructureField::StructureField(QWidget *parent) : QWidget(parent) this->syntax = new QLabel(this); } -StructureField::StructureField(const std::shared_ptr field, QWidget *parent) : QWidget(parent) +StructureField::StructureField(const std::shared_ptr field, QWidget *parent) : StructureField(parent) { this->field = field; } @@ -56,4 +57,4 @@ void StructureField::initialRender() this->render(); } -} +}} diff --git a/src/editor/StructureField.h b/src/editor/StructureField.h index 32b1d20..1196ee1 100644 --- a/src/editor/StructureField.h +++ b/src/editor/StructureField.h @@ -10,14 +10,15 @@ #include "../core/model/Field.h" #include -namespace NPC_editor { +namespace NPC{ +namespace editor { class StructureField : public QWidget { Q_OBJECT public: explicit StructureField(QWidget *parent = nullptr); - explicit StructureField(const std::shared_ptr field, QWidget *parent = nullptr); + explicit StructureField(const std::shared_ptr field, QWidget *parent = nullptr); signals: @@ -30,7 +31,7 @@ public slots: void initialRender(); private: - std::shared_ptr field; + std::shared_ptr field; // layout QVBoxLayout* layout; QLabel* title; @@ -41,5 +42,5 @@ private: QRegExpValidator* validator; QWidget* subContainer; }; -} +}} #endif // STRUCTUREFIELD_H