things

Sat, 24 Aug 2019 14:44:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 24 Aug 2019 14:44:42 +0300
changeset 2
2bdc3ac5e77c
parent 1
51d14b0c68c0
child 3
55a55a9ec2c2

things

CMakeLists.txt file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/main.h file | annotate | diff | comparison | revisions
src/modelobject.cpp file | annotate | diff | comparison | revisions
src/modelobject.h file | annotate | diff | comparison | revisions
src/uuid.cpp file | annotate | diff | comparison | revisions
src/uuid.h file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Sat Aug 03 01:18:56 2019 +0300
+++ b/CMakeLists.txt	Sat Aug 24 14:44:42 2019 +0300
@@ -20,11 +20,16 @@
 set (LDFORGE_SOURCES
 	src/main.cpp
 	src/mainwindow.cpp
+        src/modelobject.cpp
+        src/uuid.cpp
 	src/version.cpp
 )
 set (LDFORGE_HEADERS
 	src/main.h
 	src/mainwindow.h
+        src/mainwindow.h
+        src/modelobject.h
+        src/uuid.h
 	src/version.h
 )
 set (LDFORGE_FORMS
--- a/src/main.cpp	Sat Aug 03 01:18:56 2019 +0300
+++ b/src/main.cpp	Sat Aug 24 14:44:42 2019 +0300
@@ -1,6 +1,7 @@
 #include <QApplication>
 #include "main.h"
 #include "mainwindow.h"
+#include <QTextStream>
 
 int main(int argc, char *argv[])
 {
--- a/src/main.h	Sat Aug 03 01:18:56 2019 +0300
+++ b/src/main.h	Sat Aug 24 14:44:42 2019 +0300
@@ -1,1 +1,6 @@
 #pragma once
+#include <QString>
+#include <QVector>
+#include <QSet>
+
+static constexpr long double pi = 3.14159265358979323846264338327950288419716939937510L;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/modelobject.cpp	Sat Aug 24 14:44:42 2019 +0300
@@ -0,0 +1,22 @@
+#include "modelobject.h"
+
+static Uuid &getUuidForNewObject()
+{
+    static Uuid running_uuid {0, 0};
+    incrementUuid(running_uuid);
+    return running_uuid;
+}
+
+ModelObject::ModelObject() :
+    id {getUuidForNewObject()}
+{
+}
+
+ModelObject::~ModelObject()
+{
+}
+
+
+Comment::Comment(QStringView text) :
+    ModelObject{},
+    storedText{text} {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/modelobject.h	Sat Aug 24 14:44:42 2019 +0300
@@ -0,0 +1,24 @@
+#pragma once
+#include <QString>
+#include <QStringView>
+#include "uuid.h"
+
+class ModelObject
+{
+public:
+    ModelObject();
+    virtual ~ModelObject();
+
+    const Uuid id;
+    virtual void toString(QTextStream &out) = 0;
+private:
+
+};
+
+class Comment : public ModelObject
+{
+    Comment(QStringView text);
+
+private:
+    QStringView storedText;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/uuid.cpp	Sat Aug 24 14:44:42 2019 +0300
@@ -0,0 +1,22 @@
+#include "uuid.h"
+#include <QIODevice>
+
+void uuidToString(const Uuid &uuid, QTextStream &stream)
+{
+    stream << "0x";
+    stream << QString::number(uuid.a, 16);
+    stream << QString::number(uuid.b, 16);
+}
+
+void incrementUuid(Uuid &uuid)
+{
+    if (uuid.b == std::numeric_limits<decltype(uuid.b)>::max())
+    {
+        uuid.a += 1;
+        uuid.b = 0;
+    }
+    else
+    {
+        uuid.b += 1;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/uuid.h	Sat Aug 24 14:44:42 2019 +0300
@@ -0,0 +1,12 @@
+#pragma once
+#include <QString>
+#include <QTextStream>
+
+struct Uuid
+{
+    quint64 a;
+    quint64 b;
+};
+
+void incrementUuid(Uuid &uuid);
+void uuidToString(const Uuid &uuid, QTextStream &stream);

mercurial