diff --git a/model.graphml b/model.graphml
new file mode 100644
index 0000000..a0c0522
--- /dev/null
+++ b/model.graphml
@@ -0,0 +1,334 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Field
+
+
+
+
+
+
+
+ - owningStructure
+- binary
+- logical
+- visual
+- representation
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Binary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Logical
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Visual
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Representation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Structure
+
+
+
+
+
+
+
+ - name
+- description
+- fields
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FieldFactory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ StructureFactory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AStructureFactory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AFieldFactory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages.graphml b/packages.graphml
new file mode 100644
index 0000000..a9bd522
--- /dev/null
+++ b/packages.graphml
@@ -0,0 +1,203 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GUI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Model
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ByteDispatcher
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DefinitionManager
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProtocolDefinitions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reads/Writes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Generates/Produces
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Displays
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 33203c5..66648cb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,7 +7,8 @@ set(SOURCES mainwindow.cpp
add_subdirectory(model)
add_subdirectory(editor)
add_subdirectory(parser)
+add_subdirectory(core)
add_library(src ${HEADERS} ${SOURCES})
-target_link_libraries(src model editor protocol)
+target_link_libraries(src model editor protocol core )
qt5_use_modules(src Widgets)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
new file mode 100644
index 0000000..4eb5148
--- /dev/null
+++ b/src/core/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+set(HEADERS
+ Tree.h
+ TreeNode.h
+)
+
+set(SOURCES
+)
+
+add_library(core ${HEADERS} ${SOURCES})
diff --git a/src/model/Tree.h b/src/core/Tree.h
similarity index 100%
rename from src/model/Tree.h
rename to src/core/Tree.h
diff --git a/src/model/TreeNode.h b/src/core/TreeNode.h
similarity index 95%
rename from src/model/TreeNode.h
rename to src/core/TreeNode.h
index 6b892a4..c3eac94 100644
--- a/src/model/TreeNode.h
+++ b/src/core/TreeNode.h
@@ -30,6 +30,7 @@ public:
void moveChildren(std::shared_ptr> to); //all
void addChild(std::shared_ptr> child);
+ void addChildren(std::shared_ptr> nodeWithChildren);
bool removeChild(std::shared_ptr> child);
bool remove();
@@ -190,11 +191,22 @@ template
void TreeNode::addChild(std::shared_ptr> child)
{
this->getChildren().push_back(child);
- //this->getChildren().append(child);
child->setParent(std::shared_ptr>(this));
fireTreeChanged();
}
+
+template
+void TreeNode::addChildren(std::shared_ptr> nodeWithChildren)
+{
+ for(std::shared_ptr> child : nodeWithChildren->getChildren())
+ {
+ this->getChildren().push_back(child);
+ child->setParent(std::shared_ptr>(this));
+ }
+ fireTreeChanged();
+}
+
template
bool TreeNode::removeChild(std::shared_ptr> child)
{
diff --git a/src/editor/editorelementdata.cpp b/src/editor/editorelementdata.cpp
index 034f06d..1c796ca 100644
--- a/src/editor/editorelementdata.cpp
+++ b/src/editor/editorelementdata.cpp
@@ -53,12 +53,12 @@ void EditorElementData::setIsMultiLine(bool value)
multiline = value;
}
-ValueType EditorElementData::getType() const
+ValueTypeShort EditorElementData::getType() const
{
return type;
}
-void EditorElementData::setType(const ValueType &value)
+void EditorElementData::setType(const ValueTypeShort &value)
{
type = value;
}
diff --git a/src/editor/editorelementdata.h b/src/editor/editorelementdata.h
index 749ee0e..ced03be 100644
--- a/src/editor/editorelementdata.h
+++ b/src/editor/editorelementdata.h
@@ -6,7 +6,7 @@
#include
#include
-enum class ValueType {
+enum class ValueTypeShort {
BIN,OCT,DEC,HEX,TXT
};
@@ -43,8 +43,8 @@ public:
bool isMultiLine() const;
void setIsMultiLine(bool value);
- ValueType getType() const;
- void setType(const ValueType &value);
+ ValueTypeShort getType() const;
+ void setType(const ValueTypeShort &value);
QString getRegex() const;
void setRegex(const QString &value);
@@ -78,7 +78,7 @@ private:
QString id;
QList syntaxes;
bool multiline;
- ValueType type;
+ ValueTypeShort type;
ulong bytes;
ulong bits;
QString regex;
diff --git a/src/editor/guidededitorelementview.cpp b/src/editor/guidededitorelementview.cpp
index 045273d..15fbe9d 100644
--- a/src/editor/guidededitorelementview.cpp
+++ b/src/editor/guidededitorelementview.cpp
@@ -9,7 +9,7 @@
#include
-GuidedEditorElementView::GuidedEditorElementView(const std::shared_ptr &ref, QWidget* parent)
+GuidedEditorElementView::GuidedEditorElementView(const std::shared_ptr> &ref, QWidget* parent)
: GuidedEditorElementView(parent)
{
this->setReference(ref);
@@ -34,13 +34,13 @@ void GuidedEditorElementView::render()
}
//title
- title->setText(reference->getData()->getTitle());
+ title->setText(QString::fromStdString(reference->getData()->getName()));
layout->addWidget(title);
if (reference->getChildren().size() == 0) {
// need global information about showing syntax, and other hints
- if (reference->getData()->isMultiLine()) {
+ if (false ){// reference->getData()->isMultiLine()) {
layout->addWidget(edit);
} else {
layout->addWidget(line);
@@ -51,7 +51,7 @@ void GuidedEditorElementView::render()
subContainer = new QWidget(this);
FlowLayout* flayout = new FlowLayout(subContainer);
//create and render subelementviews! this is DEPTH_FIRST!!! TODO: make this breadth first!
- for (std::shared_ptr node : reference->getChildren()) {
+ for (std::shared_ptr> node : reference->getChildren()) {
GuidedEditorElementView* view = new GuidedEditorElementView(subContainer);
view->setReference(node);
flayout->addWidget(view);
@@ -104,15 +104,15 @@ void GuidedEditorElementView::nodeChanged()
this->render();
}
-std::shared_ptr GuidedEditorElementView::getReference() const
+std::shared_ptr> GuidedEditorElementView::getReference() const
{
return reference;
}
-void GuidedEditorElementView::setReference(const std::shared_ptr& value)
+void GuidedEditorElementView::setReference(const std::shared_ptr>& value)
{
reference = value;
- QRegExp r(reference->getData()->getRegex());
+ /*QRegExp r(reference->getData()->getRegex());
validator->setRegExp(r);
if (reference->getData()->isMultiLine()) {
edit = new QTextEdit(this);
@@ -120,5 +120,5 @@ void GuidedEditorElementView::setReference(const std::shared_ptr& valu
} else {
line = new QLineEdit(this);
this->connect(line, &QLineEdit::textChanged, this, &GuidedEditorElementView::dataChanged);
- }
+ }*/
}
diff --git a/src/editor/guidededitorelementview.h b/src/editor/guidededitorelementview.h
index ff3cd4c..67a8edb 100644
--- a/src/editor/guidededitorelementview.h
+++ b/src/editor/guidededitorelementview.h
@@ -11,17 +11,18 @@
#include
#include "editorelementdata.h"
-#include "EditorNode.h"
+#include "../core/TreeNode.h"
+#include "../model/Field.h"
class GuidedEditorElementView : public QWidget {
Q_OBJECT
public:
- explicit GuidedEditorElementView(const std::shared_ptr &ref,QWidget* parent = 0);
+ explicit GuidedEditorElementView(const std::shared_ptr> &ref,QWidget* parent = 0);
explicit GuidedEditorElementView(QWidget* parent = 0);
- std::shared_ptr getReference() const;
- void setReference(const std::shared_ptr &value);
+ std::shared_ptr> getReference() const;
+ void setReference(const std::shared_ptr> &value);
signals:
@@ -40,7 +41,7 @@ private:
QMap otherWidgets;
QRegExpValidator* validator;
QWidget* subContainer;
- std::shared_ptr reference;
+ std::shared_ptr> reference;
};
#endif // GUIDEDEDITORELEMENTVIEW_H
diff --git a/src/editor/guidededitorview.cpp b/src/editor/guidededitorview.cpp
index 4366b31..9222348 100644
--- a/src/editor/guidededitorview.cpp
+++ b/src/editor/guidededitorview.cpp
@@ -24,7 +24,7 @@ GuidedEditorView::GuidedEditorView(QWidget* parent)
}
GuidedEditorView::GuidedEditorView(
- EditorTree* tree,
+ Tree* tree,
QWidget* parent)
: GuidedEditorView(parent)
{
@@ -41,13 +41,13 @@ void GuidedEditorView::addElement(EditorElementData* element)
//this->update();
}
-void GuidedEditorView::setTree(EditorTree* tree)
+void GuidedEditorView::setTree(Tree* tree)
{
this->tree = tree;
}
-void GuidedEditorView::treeDataChangedSlot(std::shared_ptr node)
+void GuidedEditorView::treeDataChangedSlot(std::shared_ptr> node)
{
// get node view
auto view = nodeToViewMap[node];
@@ -55,7 +55,7 @@ void GuidedEditorView::treeDataChangedSlot(std::shared_ptr node)
view->dataChanged();
}
-void GuidedEditorView::treeChangedSlot(std::shared_ptr node)
+void GuidedEditorView::treeChangedSlot(std::shared_ptr> node)
{
// get node view
auto view = nodeToViewMap[node];
@@ -67,7 +67,7 @@ void GuidedEditorView::render()
{
if(tree != nullptr) {
// root node is invisible!
- for(std::shared_ptr node : tree->getRoot()->getChildren()){
+ for(std::shared_ptr> node : tree->getRoot()->getChildren()){
auto view = new GuidedEditorElementView(node, this);
this->editorLayout->addWidget(view);
this->nodeToViewMap.insert(node, view);
diff --git a/src/editor/guidededitorview.h b/src/editor/guidededitorview.h
index d4fb912..8f20e86 100644
--- a/src/editor/guidededitorview.h
+++ b/src/editor/guidededitorview.h
@@ -1,6 +1,6 @@
#ifndef GUIDEDEDITOR_H
#define GUIDEDEDITOR_H
-#include "EditorTree.h"
+#include "../core/Tree.h"
#include "editorelementdata.h"
#include "guidededitorelementview.h"
#include "flowlayout.h"
@@ -11,24 +11,24 @@ class GuidedEditorView : public QWidget {
Q_OBJECT
public:
explicit GuidedEditorView(QWidget* parent = 0);
- explicit GuidedEditorView(EditorTree* tree, QWidget* parent = 0);
+ explicit GuidedEditorView(Tree* tree, QWidget* parent = 0);
~GuidedEditorView();
signals:
public slots:
void addElement(EditorElementData* element);
- void setTree(EditorTree* tree);
+ void setTree(Tree* tree);
- void treeDataChangedSlot(std::shared_ptr node);
- void treeChangedSlot(std::shared_ptr node);
+ void treeDataChangedSlot(std::shared_ptr> node);
+ void treeChangedSlot(std::shared_ptr> node);
void render();
private:
FlowLayout* editorLayout;
- EditorTree* tree;
- QMap, GuidedEditorElementView*> nodeToViewMap;
+ Tree* tree;
+ QMap>, GuidedEditorElementView*> nodeToViewMap;
};
diff --git a/src/model/CMakeLists.txt b/src/model/CMakeLists.txt
index c77df50..90d561d 100644
--- a/src/model/CMakeLists.txt
+++ b/src/model/CMakeLists.txt
@@ -1,8 +1,6 @@
set(HEADERS Protocol.h
Field.h
- Tree.h
- TreeNode.h
)
set(SOURCES Protocol.cpp
diff --git a/src/model/Field.cpp b/src/model/Field.cpp
index 2197e72..46f721b 100644
--- a/src/model/Field.cpp
+++ b/src/model/Field.cpp
@@ -1,4 +1,4 @@
-#include "field.h"
+#include "Field.h"
#include
Field::Field(std::string name, uint32_t sizeInBit, uint16_t layer): name(name), sizeInBit(sizeInBit), layer(layer)
diff --git a/src/model/Field.h b/src/model/Field.h
index ab663d8..bbec912 100644
--- a/src/model/Field.h
+++ b/src/model/Field.h
@@ -78,7 +78,7 @@ class Field
{
public:
Field(std::string name, uint32_t sizeInBit, uint16_t layer);
- void setValue(std::string& value) {this->value = value; this->valueType = ValueType::text; }
+ void setValue(std::string& value) { this->value = value; this->valueType = ValueType::text; }
void setValue(std::string& value, ValueType type);
const std::string getValue() { return value; }
diff --git a/src/parser/DataLoader.cpp b/src/parser/DataLoader.cpp
index f4a146a..35e2e91 100644
--- a/src/parser/DataLoader.cpp
+++ b/src/parser/DataLoader.cpp
@@ -42,19 +42,19 @@ void DataLoader::loadSingleProtocol(std::__cxx11::string filename)
protocolList.push_back(node);
}
-std::shared_ptr DataLoader::generateTree(YAML::Node &node)
+std::shared_ptr> DataLoader::generateTree(YAML::Node &node)
{
if(!node["protocol"])
return nullptr;
// root node containing the protocol.
- std::shared_ptr editorNode = std::shared_ptr(new EditorNode());
- std::shared_ptr data = std::shared_ptr(new EditorElementData());
+ std::shared_ptr> editorNode = std::shared_ptr>(new TreeNode());
+ /*/std::shared_ptr data = std::shared_ptr(new EditorElementData());
- data->setTitle(node["protocol"]["name"].as());
+ //data->setTitle(node["protocol"]["name"].as());
if(node["protocol"]["longname"])
data->setHint("subtitle", node["protocol"]["longname"].as());
- editorNode->setData(data);
+ editorNode->setData(data);*/
// add children containing the fields
auto fields = node["protocol"]["fields"];
for(YAML::Node n : fields) {
@@ -87,12 +87,12 @@ std::list DataLoader::getProtocolNames()
return names;
}
-std::shared_ptr DataLoader::genNode(YAML::Node &n, std::shared_ptr parent)
+std::shared_ptr> DataLoader::genNode(YAML::Node &n, std::shared_ptr> parent)
{
- std::shared_ptr newNode = std::shared_ptr(new EditorNode());
+ std::shared_ptr> newNode = std::shared_ptr>(new TreeNode());
newNode->setParent(parent);
- std::shared_ptr newData = std::shared_ptr(new EditorElementData());
+ /*std::shared_ptr newData = std::shared_ptr(new EditorElementData());
newData->setTitle(n["field"].as());
if(n["desc"])
newData->setHint("desc",n["desc"].as());
@@ -106,7 +106,7 @@ std::shared_ptr DataLoader::genNode(YAML::Node &n, std::shared_ptrsetOptional(n["data"].as());
if(n["nextlayer"])
newData->setNextLayer(n["nextlayer"].as());
- newNode->setData(newData);
+ newNode->setData(newData);*/
if(n["subfields"])
{
auto fields = n["subfields"];
diff --git a/src/parser/DataLoader.h b/src/parser/DataLoader.h
index a4b7fe7..9dd889c 100644
--- a/src/parser/DataLoader.h
+++ b/src/parser/DataLoader.h
@@ -6,7 +6,8 @@
#include
#include
-#include "../model/TreeNode.h"
+#include "../core/TreeNode.h"
+#include "../model/Field.h"
class DataLoader {
@@ -18,13 +19,13 @@ public:
void loadSingleProtocol(std::string filename);
- std::shared_ptr> generateTree(YAML::Node &node);
+ std::shared_ptr> generateTree(YAML::Node &node);
bool getProtocolByName(std::string name, YAML::Node &node);
std::list getProtocolNames();
private:
- std::shared_ptr> genNode(YAML::Node& n, std::shared_ptr> parent = nullptr);
+ std::shared_ptr> genNode(YAML::Node& n, std::shared_ptr> parent = nullptr);
std::string directory;
std::list protocolList;
};