Added a nodetree and a node skeleton classes. With a few notes.

This commit is contained in:
Relintai 2022-01-07 16:56:26 +01:00
parent 78c5601a9b
commit ad55c03d59
5 changed files with 70 additions and 0 deletions

View File

@ -16,6 +16,7 @@ env.add_source_files(env.core_sources, "./database/*.cpp")
env.add_source_files(env.core_sources, "./os/*.cpp")
env.add_source_files(env.core_sources, "./threading/*.cpp")
env.add_source_files(env.core_sources, "./settings/*.cpp")
env.add_source_files(env.core_sources, "./nodes/*.cpp")
# Build it all as a library
lib = env.add_library("core", env.core_sources)

10
core/nodes/node.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "node.h"
#include "request.h"
Node::Node() : Object() {
}
Node::~Node() {
}

14
core/nodes/node.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef NODE_H
#define NODE_H
#include "core/object.h"
class Node : public Object {
public:
Node();
~Node();
protected:
};
#endif

8
core/nodes/node_tree.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "node_tree.h"
NodeTree::NodeTree() : Object() {
}
NodeTree::~NodeTree() {
}

37
core/nodes/node_tree.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef NODE_TREE_H
#define NODE_TREE_H
#include "core/object.h"
//should be a template
//It should be inherited from
//Similar idea to godot's scenetree
//Should handle all functionality of base nodes
//refreshes etc -> good for web nodes aswell -> can use dirtying if there are updates, or clearing caches
//Should have a root node (templated)
//Nodes should have a tree set into them (not templated) -> set() should be virtual
//For the web:
//The webserver could be a webtree, the nodes themselves could handle routing with their hierarchy (easy to cache) would have the same speed
//Routing could be overridable per node
//MIddlewares can be handled by the tree before sending the request to the tree, also files (that could be a middleware aswell)
//WebTree : public NodeTree<WebNode>
//and then Server : public WebTree
//This way webapps could be build like guis in godot.
//WebTree
// - WebRoot (Normal WebNode - if uri is '/news/...' if it has a news node, pushes the uri stack and forwards the request to that node. Else 404
// ---- news (News node f.e. - handles request, stops forwarding)
// ---- projects (Projects node, either forwards, or if /projects sends back a list etc)
// -------- p1
//etc
class NodeTree : public Object {
public:
NodeTree();
~NodeTree();
protected:
};
#endif