Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <glibmm.h>
- #include <iostream>
- struct Vec2
- {
- long x;
- long y;
- Vec2(long x, long y)
- : x(x), y(y)
- {}
- };
- struct Entity
- {
- Vec2 position;
- Vec2 velocity;
- Vec2 acceleration;
- const char *name;
- Entity(const char *name)
- : position(0, 0),
- velocity(0, 0),
- acceleration(0, 0),
- name(name)
- {}
- ~Entity()
- {
- std::cout << "Entity " << name << " says goodbye\n";
- }
- };
- typedef Glib::NodeTree<Entity> ENode;
- bool travFun(ENode &node)
- {
- std::cout << "Traversing node: " << node.data().name << "\n";
- return false;
- }
- int main(int, char**)
- {
- Entity root("Root");
- root.position = Vec2(10, 20);
- ENode tree(root);
- tree.append_data("child");
- tree.append_data("child2");
- tree.traverse(sigc::ptr_fun(&travFun), Glib::TRAVERSE_POST_ORDER);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement