path.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* node_tree/path.h - Node tree path
  2. * Copyright (C) 2017-2018 caryoscelus
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef CORE_NODE_TREE_PATH_H_17A557AE_B48F_5C2A_AB42_99B184998CBC
  18. #define CORE_NODE_TREE_PATH_H_17A557AE_B48F_5C2A_AB42_99B184998CBC
  19. #include "node_tree.h"
  20. namespace rainynite::core {
  21. struct NodeTreePath {
  22. NodeTreePath(vector<size_t> const& idxs) :
  23. indexes(idxs)
  24. {}
  25. NodeTreePath() = default;
  26. vector<size_t> indexes;
  27. bool operator==(NodeTreePath const& other) const {
  28. return indexes == other.indexes;
  29. }
  30. bool operator!=(NodeTreePath const& other) const {
  31. return !(*this == other);
  32. }
  33. };
  34. NodeTree::Index tree_path_to_index(NodeTree const& tree, NodeTreePath const& path);
  35. NodeTreePath tree_index_to_path(NodeTree const& tree, NodeTree::Index index);
  36. AbstractReference get_node_by_path(NodeTree const& tree, NodeTreePath const& path);
  37. } // namespace rainynite::core
  38. #endif