// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================

#ifndef FENNEC_SCENE_SCENE_H
#define FENNEC_SCENE_SCENE_H

#include <fennec/containers/rdtree.h>
#include <fennec/memory/pointers.h>
#include <fennec/string/string.h>

#include <fennec/scene/forward.h>


namespace fennec
{

///
/// \brief Main Scene Hierarchy
/// \details This structure only contains the names of nodes and defers storage for components to
///          their respective systems. Simple components may be isolated, \see components.h for more info.
///          The hierarchy should be displayed using pre-order traversal.
class scene {

// Definitions =========================================================================================================
private:
	using elem_t = unique_ptr<scene_node>;
	using tree_t = rdtree<elem_t>;


// Access ==============================================================================================================
public:
	///
	/// \brief Find a node by name.
	/// \details If multiple nodes have the same name, finds the first one in pre-order traversal.
	/// \param name The name of the node to search for
	/// \returns The id of the node, \emph{npos} if not found.
	scene_node* operator[](const cstring& name) const;

	///
	/// \brief Find a node by name.
	/// \details If multiple nodes have the same name, finds the first one in pre-order traversal.
	/// \param name The name of the node to search for
	/// \returns The id of the node, \emph{npos} if not found.
	scene_node* operator[](const string& name) const;

private:
	tree_t _tree;
};

}

#endif // FENNEC_SCENE_SCENE_H
