unknown state of work

This commit is contained in:
Marcel M. Otte 2020-12-30 12:46:05 +01:00
parent 0ccbee1438
commit 8785596ba2
24 changed files with 211 additions and 142 deletions

View File

@ -1,106 +1,115 @@
# NPC core # NPC
```plantuml ```plantuml
abstract class ARepository
abstract class ARepositoryFactory package Core {
class RepositoryFactory
class Repository { package Control {
+addStructure() class RepositoryFactory
+removeStructure() class ModelFactory
+getStructure() 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 { class RandomAccessBinary {
- binaryData - binaryData
+ setBytes(uint position, std::vector<uint8_t> data) + setBytes(uint position, std::vector<uint8_t> data)
+ setByte(uint position, uint8_t data) + setByte(uint position, uint8_t data)
+ setBit(uint64_t position, bool value) + setBit(uint64_t position, bool value)
+ setBit(uint bytePosition, uint bitPosition, bool value) + setBit(uint bytePosition, uint bitPosition, bool value)
+ setBits(uint64_t position, uint bits, uint value) + setBits(uint64_t position, uint bits, uint value)
+ setBits(uint bytePosition, uint bitPosition, uint bits, uint value) + setBits(uint bytePosition, uint bitPosition, uint bits, uint value)
+ getByte(uint position) + getByte(uint position)
+ getBytes(uint position, uint bytes) + getBytes(uint position, uint bytes)
+ getBit(uint64_t position) + getBit(uint64_t position)
+ getBit(uint bytePosition, uint bitPosition) + getBit(uint bytePosition, uint bitPosition)
+ getBits(uint64_t position, uint bits) + getBits(uint64_t position, uint bits)
+ getBits(uint bytePosition, uint bitPosition, uint bits) + getBits(uint bytePosition, uint bitPosition, uint bits)
+ get_uint32(uint position) + get_uint32(uint position)
+ get_uint16(uint position) + get_uint16(uint position)
+ get_uint64(uint position) + get_uint64(uint position)
+ get_float(uint position) + get_float(uint position)
+ get_double(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(uint position, uint length)
+ get_hex_string() + get_hex_string()
} }
ARepositoryFactory <|-- RepositoryFactory
ARepository <|-- Repository
RepositoryFactory --> Repository : creates > RepositoryFactory --> Repository : creates >
AStackModelFactory <|-- StackModelFactory ModelFactory -> Model: creates >
AStackModel <|-- StackModel
StackModelFactory --> StackModel: creates >
AStructureFactory <|-- StructureFactory StructureFactory -> Structure : creates >
AStructure <|-- Structure Model *- Structure
StructureFactory --> Structure : creates > Repository *- Structure
StackModel *-- Structure
Repository *-- Structure
AFieldFactory <|-- FieldFactory FieldFactory -> Field : creates >
AField <|-- Field
FieldFactory --> Field : creates >
Structure *-- Field Structure *- Field
StackModel *-- "1" RandomAccessBinary Model *-- "1" RandomAccessBinary
StructureField *-- Field
StackContainer *-- StructureField
``` ```

View File

@ -8,10 +8,10 @@ set(HEADERS
model/Model.h model/Model.h
model/Structure.h model/Structure.h
model/Field.h model/Field.h
control/ARepositoryFactory.h control/RepositoryFactory.h
control/AFieldFactory.h control/FieldFactory.h
control/AStructureFactory.h control/StructureFactory.h
control/AModelFactory.h control/ModelFactory.h
schemaio/AStructureReaderFactory.h schemaio/AStructureReaderFactory.h
schemaio/AStructureWriterFactory.h schemaio/AStructureWriterFactory.h
@ -28,10 +28,10 @@ set(SOURCES
model/Model.cpp model/Model.cpp
model/Structure.cpp model/Structure.cpp
model/Field.cpp model/Field.cpp
control/ARepositoryFactory.cpp control/RepositoryFactory.cpp
control/AFieldFactory.cpp control/FieldFactory.cpp
control/AStructureFactory.cpp control/StructureFactory.cpp
control/AModelFactory.cpp control/ModelFactory.cpp
schemaio/AStructureReaderFactory.cpp schemaio/AStructureReaderFactory.cpp
schemaio/AStructureWriterFactory.cpp schemaio/AStructureWriterFactory.cpp

View File

@ -1,5 +1,5 @@
#include "AFieldFactory.h" #include "FieldFactory.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
FieldFactory::FieldFactory() FieldFactory::FieldFactory()
{ {
@ -14,12 +14,17 @@ std::shared_ptr<Model::Field> FieldFactory::createField(std::string name, std::s
return f; return f;
} }
std::shared_ptr<Model::Field> FieldFactory::createFieldFull(std::string name, std::map<std::string, std::string> syntaxes, std::shared_ptr<Model::Structure> parentStructure) std::shared_ptr<Model::Field> FieldFactory::createFieldFull(std::string name, std::shared_ptr<std::map<std::string, std::string>> syntaxes, std::shared_ptr<Model::Structure> parentStructure)
{ {
auto f = std::make_shared<Model::Field>(); auto f = this->createField(name, parentStructure);
f->setName(name);
f->setSyntaxes(syntaxes); f->setSyntaxes(syntaxes);
f->setParentStructure(parentStructure);
return f; return f;
} }
}}
std::shared_ptr<Model::Field> FieldFactory::createFieldWithPredefinedValues(std::string name, std::shared_ptr<std::map<std::string, std::string> > choosableValues, std::shared_ptr<std::map<std::string, std::string> > syntaxes, std::shared_ptr<Model::Structure> parentStructure)
{
auto f = this->createFieldFull(name, syntaxes, parentStructure);
f->setChooseableValues(choosableValues);
return f;
}
}}}

View File

@ -4,7 +4,7 @@
#include "../model/Field.h" #include "../model/Field.h"
#include <memory> #include <memory>
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
class FieldFactory class FieldFactory
{ {
@ -13,7 +13,10 @@ public:
virtual ~FieldFactory(); virtual ~FieldFactory();
virtual std::shared_ptr<Model::Field> createField(std::string name, std::shared_ptr<Model::Structure> parentStructure = nullptr); virtual std::shared_ptr<Model::Field> createField(std::string name, std::shared_ptr<Model::Structure> parentStructure = nullptr);
virtual std::shared_ptr<Model::Field> createFieldFull(std::string name, std::map<std::string, std::string> syntaxes, std::shared_ptr<Model::Structure> parentStructure = nullptr); virtual std::shared_ptr<Model::Field> createFieldFull(std::string name, std::shared_ptr<std::map<std::string, std::string>> syntaxes, std::shared_ptr<Model::Structure> parentStructure = nullptr);
virtual std::shared_ptr<Model::Field> createFieldWithPredefinedValues(std::string name, std::shared_ptr<std::map<std::string, std::string>> choosableValues,
std::shared_ptr<std::map<std::string, std::string>> syntaxes,
std::shared_ptr<Model::Structure> parentStructure = nullptr);
}; };
}} }}}
#endif // AFIELDFACTORY_H #endif // AFIELDFACTORY_H

View File

@ -1,8 +1,8 @@
#include "AModelFactory.h" #include "ModelFactory.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
ModelFactory::ModelFactory() ModelFactory::ModelFactory()
{ {
} }
}} }}}

View File

@ -1,12 +1,12 @@
#ifndef AMODELFACTORY_H #ifndef AMODELFACTORY_H
#define AMODELFACTORY_H #define AMODELFACTORY_H
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
class ModelFactory class ModelFactory
{ {
public: public:
ModelFactory(); ModelFactory();
}; };
}} }}}
#endif // AMODELFACTORY_H #endif // AMODELFACTORY_H

View File

@ -0,0 +1,8 @@
#include "RepositoryFactory.h"
namespace NPC { namespace core {
namespace Control {
RepositoryFactory::RepositoryFactory()
{
}
}}}

View File

@ -1,12 +1,12 @@
#ifndef AREPOSITORYFACTORY_H #ifndef AREPOSITORYFACTORY_H
#define AREPOSITORYFACTORY_H #define AREPOSITORYFACTORY_H
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
class RepositoryFactory class RepositoryFactory
{ {
public: public:
RepositoryFactory(); RepositoryFactory();
}; };
}} }}}
#endif // AREPOSITORYFACTORY_H #endif // AREPOSITORYFACTORY_H

View File

@ -1,8 +0,0 @@
#include "ARepositoryFactory.h"
namespace NPC_core {
namespace Control {
RepositoryFactory::RepositoryFactory()
{
}
}}

View File

@ -1,8 +1,8 @@
#include "AStructureFactory.h" #include "StructureFactory.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
StructureFactory::StructureFactory() StructureFactory::StructureFactory()
{ {
} }
}} }}}

View File

@ -1,12 +1,12 @@
#ifndef ASTRUCTUREFACTORY_H #ifndef ASTRUCTUREFACTORY_H
#define ASTRUCTUREFACTORY_H #define ASTRUCTUREFACTORY_H
namespace NPC_core { namespace NPC { namespace core {
namespace Control { namespace Control {
class StructureFactory class StructureFactory
{ {
public: public:
StructureFactory(); StructureFactory();
}; };
}} }}}
#endif // ASTRUCTUREFACTORY_H #endif // ASTRUCTUREFACTORY_H

View File

@ -1,6 +1,6 @@
#include "Field.h" #include "Field.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
Field::Field() Field::Field()
{ {
@ -58,4 +58,4 @@ void Field::setChooseableValues(const std::shared_ptr<std::map<std::string, std:
} }
} }
} }}

View File

@ -6,7 +6,7 @@
#include <string> #include <string>
#include <map> #include <map>
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
class Structure; class Structure;
@ -39,6 +39,6 @@ protected:
std::string value; std::string value;
std::shared_ptr<std::map<std::string, std::string>> chooseableValues; std::shared_ptr<std::map<std::string, std::string>> chooseableValues;
}; };
}} }}}
#endif // AFIELD_H #endif // AFIELD_H

View File

@ -1,8 +1,8 @@
#include "Model.h" #include "Model.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
Model::Model() Model::Model()
{ {
} }
}} }}}

View File

@ -4,7 +4,7 @@
#include "../Tree.h" #include "../Tree.h"
#include "Field.h" #include "Field.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
class Model class Model
{ {
@ -15,5 +15,5 @@ public:
private: private:
Tree<Field> stack; Tree<Field> stack;
}; };
}} }}}
#endif // AMODEL_H #endif // AMODEL_H

View File

@ -1,8 +1,8 @@
#include "Repository.h" #include "Repository.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
Repository::Repository() Repository::Repository()
{ {
} }
}} }}}

View File

@ -4,7 +4,7 @@
#include <map> #include <map>
#include "Structure.h" #include "Structure.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
class Repository class Repository
{ {
@ -15,5 +15,5 @@ public:
private: private:
std::map<std::string, Structure> structures; std::map<std::string, Structure> structures;
}; };
}} }}}
#endif // AREPOSITORY_H #endif // AREPOSITORY_H

View File

@ -1,5 +1,5 @@
#include "Structure.h" #include "Structure.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
Structure::Structure() Structure::Structure()
{ {
@ -25,4 +25,20 @@ void Structure::setLayer(const uint &value)
{ {
layer = value; layer = value;
} }
}}
std::shared_ptr<Tree<Field> > Structure::getElements() const
{
return elements;
}
void Structure::setElements(const std::shared_ptr<Tree<Field> > &value)
{
elements = value;
}
std::shared_ptr<TreeNode<Field> > Structure::getElementCopy()
{
if(elements != nullptr)
return elements->getRoot()->rcopy();
}
}}}

View File

@ -6,7 +6,7 @@
#include "Field.h" #include "Field.h"
#include "../Tree.h" #include "../Tree.h"
namespace NPC_core { namespace NPC { namespace core {
namespace Model { namespace Model {
class Field; class Field;
@ -28,6 +28,6 @@ private:
std::string name; std::string name;
uint layer; uint layer;
}; };
}} }}}
#endif // ASTRUCTURE_H #endif // ASTRUCTURE_H

View File

@ -2,11 +2,13 @@
set(HEADERS set(HEADERS
flowlayout.h flowlayout.h
StructureField.h StructureField.h
StackContainer.h
) )
set(SOURCES set(SOURCES
flowlayout.cpp flowlayout.cpp
StructureField.cpp StructureField.cpp
StackContainer.cpp
) )
add_library(editor ${HEADERS} ${SOURCES}) add_library(editor ${HEADERS} ${SOURCES})

View File

@ -0,0 +1,6 @@
#include "StackContainer.h"
using namespace NPC::editor;
StackContainer::StackContainer(QWidget *parent) : QWidget(parent)
{
}

View File

@ -0,0 +1,26 @@
#ifndef STACKCONTAINER_H
#define STACKCONTAINER_H
#include <QWidget>
#include <memory>
#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<NPC::core::Model::Model> model);
signals:
public slots:
};
}}
#endif // STACKCONTAINER_H

View File

@ -1,6 +1,7 @@
#include "StructureField.h" #include "StructureField.h"
namespace NPC_editor { namespace NPC {
namespace editor {
StructureField::StructureField(QWidget *parent) : QWidget(parent) StructureField::StructureField(QWidget *parent) : QWidget(parent)
{ {
@ -14,7 +15,7 @@ StructureField::StructureField(QWidget *parent) : QWidget(parent)
this->syntax = new QLabel(this); this->syntax = new QLabel(this);
} }
StructureField::StructureField(const std::shared_ptr<NPC_core::Model::Field> field, QWidget *parent) : QWidget(parent) StructureField::StructureField(const std::shared_ptr<NPC::core::Model::Field> field, QWidget *parent) : StructureField(parent)
{ {
this->field = field; this->field = field;
} }
@ -56,4 +57,4 @@ void StructureField::initialRender()
this->render(); this->render();
} }
} }}

View File

@ -10,14 +10,15 @@
#include "../core/model/Field.h" #include "../core/model/Field.h"
#include <memory> #include <memory>
namespace NPC_editor { namespace NPC{
namespace editor {
class StructureField : public QWidget class StructureField : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit StructureField(QWidget *parent = nullptr); explicit StructureField(QWidget *parent = nullptr);
explicit StructureField(const std::shared_ptr<NPC_core::Model::Field> field, QWidget *parent = nullptr); explicit StructureField(const std::shared_ptr<NPC::core::Model::Field> field, QWidget *parent = nullptr);
signals: signals:
@ -30,7 +31,7 @@ public slots:
void initialRender(); void initialRender();
private: private:
std::shared_ptr<NPC_core::Model::Field> field; std::shared_ptr<NPC::core::Model::Field> field;
// layout // layout
QVBoxLayout* layout; QVBoxLayout* layout;
QLabel* title; QLabel* title;
@ -41,5 +42,5 @@ private:
QRegExpValidator* validator; QRegExpValidator* validator;
QWidget* subContainer; QWidget* subContainer;
}; };
} }}
#endif // STRUCTUREFIELD_H #endif // STRUCTUREFIELD_H