user create tree

This commit is contained in:
vrd
2023-02-14 22:18:16 +02:00
parent b28cb604a2
commit 4e3816ae15
6 changed files with 83 additions and 45 deletions
+9 -7
View File
@@ -1,12 +1,14 @@
#!/bin/dash #!/bin/sh
mkdir -p bin/release mkdir -p bin/release
language=' language='
-std=gnu++20 -std=c++17
-fno-rtti -fno-rtti
-fno-exceptions -fno-exceptions
-fno-non-call-exceptions' -fno-non-call-exceptions
-fno-common'
# force each global variable to be only defined once
optimizations=' optimizations='
-Ofast -Ofast
@@ -14,7 +16,8 @@ optimizations='
-fipa-pta -fipa-pta
-fallow-store-data-races -fallow-store-data-races
-fgcse-sm -fgcse-sm
-fgcse-las' -fgcse-las
-march=native'
warnings=' warnings='
-Wall -Wall
@@ -24,8 +27,7 @@ warnings='
-Wvirtual-inheritance' #-fanalyzer -Wvirtual-inheritance' #-fanalyzer
# each global variable is only declared once per single object. other='-fno-fat-lto-objects'
other='-fno-common -fno-fat-lto-objects -march=native'
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 #-static -lncursesw -ltinfo
Executable
+21
View File
@@ -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
-12
View File
@@ -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
+30
View File
@@ -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();
}
+22 -24
View File
@@ -3,6 +3,8 @@
#include "tree.hpp" #include "tree.hpp"
#include "utils.hpp" #include "utils.hpp"
#include "create_tree.hpp"
using std::cin; using std::cin;
using std::cout; using std::cout;
int main() int main()
@@ -19,7 +21,7 @@ int main()
use_default_colors(); use_default_colors();
/* init_pair(5, COLOR_BLACK, COLOR_BLACK); */ /* init_pair(5, COLOR_BLACK, COLOR_BLACK); */
/* bkgd(COLOR_PAIR(5)); */ /* 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_FEMALE, COLOR_RED, -1);
init_pair(COLOR_SELECTED, COLOR_YELLOW, -1); init_pair(COLOR_SELECTED, COLOR_YELLOW, -1);
wnoutrefresh(stdscr); /* if not present the first real refresh is missed */ wnoutrefresh(stdscr); /* if not present the first real refresh is missed */
@@ -50,42 +52,38 @@ int main()
test2.display(); test2.display();
(test2 + test1).display(); (test2 + test1).display();
/* test2 += test1; */
/* test2.display(); */ create_tree();
/* test1.display(); */
/* 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("Кайн", true, 0, 1); */
firstTree.addPerson("Ева", false, Nobody, Nobody, {0, 1, 6});
firstTree.addRelation(0, Spouse, 1);
firstTree.addPerson("Кайн", true, 0, 1); /* firstTree.addPerson("Авел", true, 0, 1); */
/* firstTree.addRelation(2, Sibling, 3); */
firstTree.addPerson("Авел", true, 0, 1); /* firstTree.addPerson("Сит", true, 0, 1, 230); */
firstTree.addRelation(2, Sibling, 3); /* firstTree.addRelation(2, Sibling, 4); */
/* firstTree.addPerson("Енос", true, 4, Nobody, 435); */
firstTree.addPerson("Сит", true, 0, 1, 230); /* firstTree.addPerson("Каинан", true, 5 , Nobody, 605); */
firstTree.addRelation(2, Sibling, 4); /* firstTree.addPerson("Малелеил", true, 6, Nobody, 605); */
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, 3 , Nobody); */
firstTree.addPerson("Гаидад", true, 8 , Nobody); /* firstTree.addPerson("Гаидад", true, 8 , Nobody); */
firstTree.addPerson("Малелеил", true, 9, Nobody); /* firstTree.addPerson("Малелеил", true, 9, Nobody); */
/* firstTree.print(); */ /* firstTree.print(); */
firstTree.display(); /* firstTree.display(); */
/* firstTree.saveToFile(); */
/* firstTree.printRel(3); */ /* firstTree.printRel(3); */
firstTree.printOldestAncestors(3); /* firstTree.printOldestAncestors(3); */
/* ====================================================== */ /* ====================================================== */
+1 -2
View File
@@ -1,9 +1,8 @@
#include"tree.hpp" #include"tree.hpp"
#include"utils.hpp"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <assert.h> #include <assert.h>
#include"person.hpp"
#include"utils.hpp"
using std::ofstream; using std::ofstream;
using std::ifstream; using std::ifstream;