diff --git a/compile.sh b/build.sh similarity index 60% rename from compile.sh rename to build.sh index 442f3b4..2004640 100755 --- a/compile.sh +++ b/build.sh @@ -1,12 +1,14 @@ -#!/bin/dash +#!/bin/sh mkdir -p bin/release language=' - -std=gnu++20 + -std=c++17 -fno-rtti -fno-exceptions - -fno-non-call-exceptions' + -fno-non-call-exceptions + -fno-common' +# force each global variable to be only defined once optimizations=' -Ofast @@ -14,7 +16,8 @@ optimizations=' -fipa-pta -fallow-store-data-races -fgcse-sm - -fgcse-las' + -fgcse-las + -march=native' warnings=' -Wall @@ -24,8 +27,7 @@ warnings=' -Wvirtual-inheritance' #-fanalyzer -# each global variable is only declared once per single object. -other='-fno-common -fno-fat-lto-objects -march=native' +other='-fno-fat-lto-objects' -g++ -o bin/release/famt $language $optimizations $warnings $other -DNDEBUG -s *.cpp -lncursesw +g++ -o bin/release/famt $language $optimizations $warnings $other -DNDEBUG -pipe -s *.cpp -lncursesw #-static -lncursesw -ltinfo diff --git a/build_debug.sh b/build_debug.sh new file mode 100755 index 0000000..524d57b --- /dev/null +++ b/build_debug.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +mkdir -p bin/debug + +language=' + -std=c++17 + -fno-rtti + -fno-exceptions + -fno-non-call-exceptions + -fno-common' +# force each global variable to be only defined once + + +warnings=' + -Wall + -Wextra + -Wpedantic + -Wmultiple-inheritance + -Wvirtual-inheritance' #-fanalyzer + +g++ -o bin/debug/famt $language -g -O0 -march=native $warnings -pipe *.cpp -lncursesw diff --git a/compile_debug.sh b/compile_debug.sh deleted file mode 100755 index d94df72..0000000 --- a/compile_debug.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/dash - -mkdir -p bin/debug - -warnings=' - -Wall - -Wextra - -Wpedantic - -Wmultiple-inheritance - -Wvirtual-inheritance' #-fanalyzer - -g++ -o bin/debug/famt -std=gnu++20 -g -O0 -march=native $warnings *.cpp -lncursesw diff --git a/create_tree.hpp b/create_tree.hpp new file mode 100644 index 0000000..09bcfab --- /dev/null +++ b/create_tree.hpp @@ -0,0 +1,30 @@ +void create_tree() +{ + // Declare your tree + Tree tree("first_tree"); + + // Add member Adam with parents Nobody, Born: y, m, d + tree.addPerson("Адам", true, Nobody, Nobody, {0, 1, 6}); // ID 0 + tree.addPerson("Ева", false, Nobody, Nobody, {0, 1, 6}); // ID 1 + + // Adam (0) is a Spouse of Eve (1) + tree.addRelation(0, Spouse, 1); + + // Add Cain with parents Adam (0) and Eve + tree.addPerson("Кайн", true, 0, 1); + + tree.addPerson("Авел", true, 0, 1); + + tree.addPerson("Сит", true, 0, 1, 230); + tree.addPerson("Енос", true, 4, Nobody, 435); + tree.addPerson("Каинан", true, 5 , Nobody, 605); + tree.addPerson("Малелеил", true, 6, Nobody, 605); + + + tree.addPerson("Енох", true, 3 , Nobody); + tree.addPerson("Гаидад", true, 8 , Nobody); + tree.addPerson("Малелеил", true, 9, Nobody); + + tree.saveToFile(); + tree.display(); +} diff --git a/main.cpp b/famt.cpp similarity index 89% rename from main.cpp rename to famt.cpp index f4dd12e..ffd49d3 100644 --- a/main.cpp +++ b/famt.cpp @@ -3,6 +3,8 @@ #include "tree.hpp" #include "utils.hpp" +#include "create_tree.hpp" + using std::cin; using std::cout; int main() @@ -19,7 +21,7 @@ int main() use_default_colors(); /* init_pair(5, COLOR_BLACK, COLOR_BLACK); */ /* bkgd(COLOR_PAIR(5)); */ - init_pair(COLOR_MALE, COLOR_BLUE, -1); /* -1 means use default */ + init_pair(COLOR_MALE, COLOR_CYAN, -1); /* -1 means use default */ init_pair(COLOR_FEMALE, COLOR_RED, -1); init_pair(COLOR_SELECTED, COLOR_YELLOW, -1); wnoutrefresh(stdscr); /* if not present the first real refresh is missed */ @@ -50,42 +52,38 @@ int main() test2.display(); (test2 + test1).display(); - /* test2 += test1; */ - /* test2.display(); */ - /* test1.display(); */ + + create_tree(); - /* test2.saveToFile(); */ - Tree firstTree("firstTree"); + /* Tree firstTree("firstTree"); */ + /* firstTree.addPerson("Адам", true, Nobody, Nobody, {0, 1, 6}); */ + /* firstTree.addPerson("Ева", false, Nobody, Nobody, {0, 1, 6}); */ + /* firstTree.addRelation(0, Spouse, 1); */ - firstTree.addPerson("Адам", true, Nobody, Nobody, {0, 1, 6}); - firstTree.addPerson("Ева", false, Nobody, Nobody, {0, 1, 6}); - firstTree.addRelation(0, Spouse, 1); + /* firstTree.addPerson("Кайн", true, 0, 1); */ - firstTree.addPerson("Кайн", true, 0, 1); + /* firstTree.addPerson("Авел", true, 0, 1); */ + /* firstTree.addRelation(2, Sibling, 3); */ - firstTree.addPerson("Авел", true, 0, 1); - firstTree.addRelation(2, Sibling, 3); - - firstTree.addPerson("Сит", true, 0, 1, 230); - firstTree.addRelation(2, Sibling, 4); - firstTree.addPerson("Енос", true, 4, Nobody, 435); - firstTree.addPerson("Каинан", true, 5 , Nobody, 605); - firstTree.addPerson("Малелеил", true, 6, Nobody, 605); + /* firstTree.addPerson("Сит", true, 0, 1, 230); */ + /* firstTree.addRelation(2, Sibling, 4); */ + /* firstTree.addPerson("Енос", true, 4, Nobody, 435); */ + /* firstTree.addPerson("Каинан", true, 5 , Nobody, 605); */ + /* firstTree.addPerson("Малелеил", true, 6, Nobody, 605); */ - firstTree.addPerson("Енох", true, 3 , Nobody); - firstTree.addPerson("Гаидад", true, 8 , Nobody); - firstTree.addPerson("Малелеил", true, 9, Nobody); + /* firstTree.addPerson("Енох", true, 3 , Nobody); */ + /* firstTree.addPerson("Гаидад", true, 8 , Nobody); */ + /* firstTree.addPerson("Малелеил", true, 9, Nobody); */ /* firstTree.print(); */ - firstTree.display(); - /* firstTree.saveToFile(); */ + /* firstTree.display(); */ /* firstTree.printRel(3); */ - firstTree.printOldestAncestors(3); + /* firstTree.printOldestAncestors(3); */ /* ====================================================== */ diff --git a/tree.cpp b/tree.cpp index 18337ee..5bac128 100644 --- a/tree.cpp +++ b/tree.cpp @@ -1,9 +1,8 @@ #include"tree.hpp" +#include"utils.hpp" #include #include #include -#include"person.hpp" -#include"utils.hpp" using std::ofstream; using std::ifstream;