Compare commits

...
This repository has been archived on 2020-12-30. You can view files and clone it, but cannot push or open issues or pull requests.

3 Commits

Author SHA1 Message Date
Marcel M. Otte 8785596ba2 unknown state of work 2020-12-30 12:46:05 +01:00
Marcel M. Otte 0ccbee1438 Just renaming some files ... 2018-01-16 17:38:22 +01:00
Marcel M. Otte 9b5ce8b7a1 Working on renaming and structuring source 2018-01-16 17:35:42 +01:00
28 changed files with 293 additions and 196 deletions

View File

@ -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<uint8_t> 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
```

View File

@ -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

View File

@ -1,25 +0,0 @@
#include "AFieldFactory.h"
namespace NPC_core {
namespace Control {
AFieldFactory::AFieldFactory()
{
}
std::shared_ptr<Model::Field> AFieldFactory::createField(std::string name, std::shared_ptr<Model::Structure> parentStructure)
{
auto f = std::make_shared<Model::Field>();
f->setName(name);
f->setParentStructure(parentStructure);
return f;
}
std::shared_ptr<Model::Field> AFieldFactory::createFieldFull(std::string name, std::map<std::string, std::string> syntaxes, std::shared_ptr<Model::Structure> parentStructure)
{
auto f = std::make_shared<Model::Field>();
f->setName(name);
f->setSyntaxes(syntaxes);
f->setParentStructure(parentStructure);
return f;
}
}}

View File

@ -1,19 +0,0 @@
#ifndef AFIELDFACTORY_H
#define AFIELDFACTORY_H
#include "../model/Field.h"
#include <memory>
namespace NPC_core {
namespace Control {
class AFieldFactory
{
public:
AFieldFactory();
virtual ~AFieldFactory();
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);
};
}}
#endif // AFIELDFACTORY_H

View File

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

View File

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

View File

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

View File

@ -0,0 +1,30 @@
#include "FieldFactory.h"
namespace NPC { namespace core {
namespace Control {
FieldFactory::FieldFactory()
{
}
std::shared_ptr<Model::Field> FieldFactory::createField(std::string name, std::shared_ptr<Model::Structure> parentStructure)
{
auto f = std::make_shared<Model::Field>();
f->setName(name);
f->setParentStructure(parentStructure);
return f;
}
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 = this->createField(name, parentStructure);
f->setSyntaxes(syntaxes);
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

@ -0,0 +1,22 @@
#ifndef AFIELDFACTORY_H
#define AFIELDFACTORY_H
#include "../model/Field.h"
#include <memory>
namespace NPC { namespace core {
namespace Control {
class FieldFactory
{
public:
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> 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

View File

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

View File

@ -1,12 +1,12 @@
#ifndef AMODELFACTORY_H
#define AMODELFACTORY_H
namespace NPC_core {
namespace NPC { namespace core {
namespace Control {
class AModelFactory
class ModelFactory
{
public:
AModelFactory();
ModelFactory();
};
}}
}}}
#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
#define AREPOSITORYFACTORY_H
namespace NPC_core {
namespace NPC { namespace core {
namespace Control {
class ARepositoryFactory
class RepositoryFactory
{
public:
ARepositoryFactory();
RepositoryFactory();
};
}}
}}}
#endif // AREPOSITORYFACTORY_H

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#include "Field.h"
namespace NPC_core {
namespace NPC { namespace core {
namespace Model {
Field::Field()
{
@ -17,12 +17,12 @@ void Field::setName(const std::string &value)
name = value;
}
std::map<std::string, std::string> Field::getSyntaxes() const
std::shared_ptr<std::map<std::string, std::string> > Field::getSyntaxes() const
{
return syntaxes;
}
void Field::setSyntaxes(const std::map<std::string, std::string> &value)
void Field::setSyntaxes(const std::shared_ptr<std::map<std::string, std::string>> &value)
{
syntaxes = value;
}
@ -47,5 +47,15 @@ void Field::setParentStructure(const std::shared_ptr<Structure> &value)
parentStructure = value;
}
std::shared_ptr<std::map<std::string, std::string> > Field::getChooseableValues() const
{
return chooseableValues;
}
void Field::setChooseableValues(const std::shared_ptr<std::map<std::string, std::string> > &value)
{
chooseableValues = value;
}
}
}}

View File

@ -6,7 +6,7 @@
#include <string>
#include <map>
namespace NPC_core {
namespace NPC { namespace core {
namespace Model {
class Structure;
@ -20,8 +20,8 @@ public:
std::string getName() const;
void setName(const std::string &value);
std::map<std::string, std::string> getSyntaxes() const;
void setSyntaxes(const std::map<std::string, std::string> &value);
std::shared_ptr<std::map<std::string, std::string>> getSyntaxes() const;
void setSyntaxes(const std::shared_ptr<std::map<std::string, std::string>> &value);
std::string getValue() const;
void setValue(const std::string &value);
@ -29,12 +29,16 @@ public:
std::shared_ptr<Structure> getParentStructure() const;
void setParentStructure(const std::shared_ptr<Structure> &value);
std::shared_ptr<std::map<std::string, std::string> > getChooseableValues() const;
void setChooseableValues(const std::shared_ptr<std::map<std::string, std::string> > &value);
protected:
std::shared_ptr<Structure> parentStructure;
std::string name;
std::map<std::string, std::string> syntaxes; // example : regex; for validation
std::shared_ptr<std::map<std::string, std::string>> syntaxes; // example : regex; for validation
std::string value;
std::shared_ptr<std::map<std::string, std::string>> chooseableValues;
};
}}
}}}
#endif // AFIELD_H

View File

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

View File

@ -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<Field> stack;
};
}}
}}}
#endif // AMODEL_H

View File

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

View File

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

View File

@ -1,5 +1,5 @@
#include "Structure.h"
namespace NPC_core {
namespace NPC { namespace core {
namespace Model {
Structure::Structure()
{
@ -15,4 +15,30 @@ void Structure::setName(const std::string &value)
{
name = value;
}
}}
uint Structure::getLayer() const
{
return layer;
}
void Structure::setLayer(const uint &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 "../Tree.h"
namespace NPC_core {
namespace NPC { namespace core {
namespace Model {
class Field;
@ -20,10 +20,14 @@ public:
std::string getName() const;
void setName(const std::string &value);
uint getLayer() const;
void setLayer(const uint &value);
private:
Tree<Field> elements;
std::string name;
uint layer;
};
}}
}}}
#endif // ASTRUCTURE_H

View File

@ -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})

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"
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<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;
}
@ -56,4 +57,4 @@ void StructureField::initialRender()
this->render();
}
}
}}

View File

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