nodesystem/examples/nodetree/main.c

79 lines
2.5 KiB
C

#include<stdio.h>
#include "NODESYS/node.h"
#include "NODESYS/node2d.h"
int main(int argc, char* *argv){
NOD_Node *distros = NOD_CreateNode("Distros");
NOD_Node *linoox = NOD_CreateNode("GNU/Linux");
NOD_Node *debian = NOD_CreateNode("Debian");
NOD_Node *ubuntu = NOD_CreateNode("Ubuntu");
NOD_Node *mint = NOD_CreateNode("Linux Mint");
NOD_Node *devuan = NOD_CreateNode("Devuan");
NOD_Node *kali = NOD_CreateNode("Kali Linux");
NOD_Node *voidlinux = NOD_CreateNode("Void Linux");
NOD_Node *arch = NOD_CreateNode("Arch");
NOD_Node *manjaro = NOD_CreateNode("Manjaro");
NOD_Node *parabola = NOD_CreateNode("Parabola");
NOD_Node *endeavouros = NOD_CreateNode("EndeavourOS");
NOD_Node *bsd = NOD_CreateNode("BSD");
NOD_Node *freebsd = NOD_CreateNode("FreeBSD");
NOD_Node *openbsd = NOD_CreateNode("OpenBSD");
NOD_Node *debianbsd = NOD_CreateNode("Debian GNU/kFreeBSD");
NOD_Node2D *point = NOD_CreateNode2D("Point2D");
NOD_Node2D *point2 = NOD_CreateNode2D("Point2D2");
point->pos.x = 2;
point->pos.y = 10;
printf("The X value of '%s' is %d!\n", point->node.name, point->pos.x);
printf("The Y value of '%s' is %d!\n", point->node.name, point->pos.y);
printf("\n");
point2->pos.x = 10;
point2->pos.y = 20;
printf("The X value of '%s' is %d!\n", point2->node.name, point2->pos.x);
printf("The Y value of '%s' is %d!\n", point2->node.name, point2->pos.y);
printf("\n");
NOD_NodeAddChild(point, point2);
printf("The true X value of '%s' is %d!\n", point2->node.name, NOD_GetAbsPosNode2D(point2).x);
printf("The true Y value of '%s' is %d!\n", point2->node.name, NOD_GetAbsPosNode2D(point2).y);
printf("\n");
printf("The parent of '%s' is '%s'.\n", NOD(point2)->name, NOD(NOD(point2)->parent)->name);
NOD_PrintNodeTree(point);
NOD_NodeAddChild(distros, linoox);
NOD_NodeAddChild(distros, bsd);
NOD_NodeAddChild(linoox, debian);
NOD_NodeAddChild(linoox, voidlinux);
NOD_NodeAddChild(linoox, arch);
NOD_NodeAddChild(debian, ubuntu);
NOD_NodeAddChild(debian, kali);
NOD_NodeAddChild(debian, devuan);
NOD_NodeAddChild(ubuntu, mint);
NOD_NodeAddChild(arch, manjaro);
NOD_NodeAddChild(arch, parabola);
NOD_NodeAddChild(arch, endeavouros);
NOD_NodeAddChild(bsd, freebsd);
NOD_NodeAddChild(bsd, openbsd);
NOD_NodeAddChild(bsd, debianbsd);
//NOD_NodeUnparent(child2);
NOD_PrintNodeTree(distros);
NOD_DestroyNodeBranch(distros);
return 0;
}