Skip to content

This repository provides a tree class implementation for C++, including iterators, tests, and an example.

Notifications You must be signed in to change notification settings

TomH22/Tree_class_for_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree class for C++

This repository provides a tree class implementation for C++, including iterators, tests, and an example.

The header only file can be found here: lib/Tree.h. Tree.h includes nlohmann/json.hpp. Nlohmann Json must be available, otherwise Json serialization can't work!

Features

  • template based tree items
  • one base iterator and 3 example iterators
  • to and from Json serialization
  • get node per structure or position
  • change unique nodes
  • find unique nodes
  • sort of columns

Sample code for creating tree data

#include "Tree.h"
using namespace henn;
...

Staff loos(L"Loos", Staff::RANK::STAFF_SERGANT);// highest rank
Staff quaas(L"Quaas", Staff::RANK::SERGANT);
Staff cox(L"Cox", Staff::RANK::SERGANT);

TreeModel<Staff> treeModel(loos);// Create tree model. Give the constructor also root element.
treeModel.Append(quaas, loos);// 1. sergant of staff sergant
treeModel.Append(cox, loos);// 2. sergant of staff sergant
treeModel.Append(Staff(L"Epheser", Staff::RANK::CORPORAL), cox);

Sample application

The sample application demonstrates the usage of the tree class with a graphical user interface implemented using Dear ImGui. The example uses military staff data for illustration purposes. The main functionality of the application is to display and filter elements in the tree.

Watch the video demonstration:

Video

Usage

Building the project

If you just want to build the tests, you can skip the steps 2-5.

This was tested on Windows 10 (07/2023).

  1. clone this repository
git clone --recursive https://github.com/TomH22/Tree_class_for_cpp.git 
  1. clone the GLFW repository
git clone --recursive https://github.com/glfw/glfw.git
  1. clone the Dear ImGui repository
git clone --recursive https://github.com/ocornut/imgui.git
  1. install Vulkan SDK

    components:

    • GLM headers
    • SDL2 libraries and headers
    • Volk header, source and library
    • The Vulkan SDK Core (Always Installed)

    download link: https://vulkan.lunarg.com/sdk/home#windows

  2. modify 2 lines in the CMakeLists.txt file to point to the locations of the "glfw" and "imgui" repositories. For example:

    # Set this to point to an up-to-date GLFW repo.
    set(GLFW_DIR "C:/Users/Tom/Documents/git/glfw")

    # Set this to point to an up-to-date imgui repo.
    set(IMGUI_DIR "C:/Users/Tom/Documents/git/imgui")
  1. build the project using CMake
cmake -S . -B ../../tree_build
  1. open the project, for example, with Visual Studio

About

This repository provides a tree class implementation for C++, including iterators, tests, and an example.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published