behaviortree-core 0.1.0

Core implementaion of behaviortree
Documentation
// Copyright © 2025 Stephan Kunz
//! [`BehaviorDescription`] implementation.

use crate::{ConstString, EMPTY_STR};

/// Description of a Behavior, used in xml parsing and creating.
#[derive(Clone, Debug, Default)]
pub struct BehaviorDescription {
	/// Name of the behavior, with which it is used in the [`BehaviorTree`](crate::tree::BehaviorTree).
	name: ConstString,
	/// Id of the behavior under which it can be found in the [`BehaviorTreeFactory`](crate::factory::BehaviorTreeFactory).
	id: ConstString,
	/// Path for Groot2
	groot2_path: ConstString,
	/// Path for Groot2
	configuration: ConstString,
	/// Flag to indicate whether this behavior is builtin by Groot2.
	groot2: bool,
}

impl BehaviorDescription {
	/// Create a behavior description.
	#[must_use]
	pub fn new(name: &str, id: &str, groot2: bool) -> Self {
		Self {
			name: name.into(),
			id: id.into(),
			groot2_path: EMPTY_STR.into(),
			configuration: EMPTY_STR.into(),
			groot2,
		}
	}

	/// Get name
	#[must_use]
	pub const fn name(&self) -> &ConstString {
		&self.name
	}

	/// Method to set the name.
	pub fn set_name(&mut self, name: ConstString) {
		self.name = name;
	}

	/// Get id
	#[must_use]
	pub const fn id(&self) -> &ConstString {
		&self.id
	}

	/// If is builtin of Groot2
	#[must_use]
	pub const fn groot2(&self) -> bool {
		self.groot2
	}

	/// Get the configuration string of the behavior.
	#[must_use]
	pub const fn configuration(&self) -> &ConstString {
		&self.configuration
	}

	/// Set the configuration of the behavior.
	pub fn set_configuration(&mut self, configuration: ConstString) {
		self.configuration = configuration.into();
	}

	/// Get the path for Groot2.
	#[must_use]
	pub const fn groot2_path(&self) -> &ConstString {
		&self.groot2_path
	}

	/// Set the path for Groot2.
	pub fn set_groot2_path(&mut self, groot2_path: ConstString) {
		self.groot2_path = groot2_path.into();
	}
}