reactive_graph_behaviour_service_api/
entity_component_behaviour_registry.rs

1use std::sync::Arc;
2
3use async_trait::async_trait;
4use springtime_di::injectable;
5use uuid::Uuid;
6
7use reactive_graph_behaviour_model_api::prelude::*;
8
9use reactive_graph_graph::ComponentTypeId;
10use reactive_graph_lifecycle::Lifecycle;
11use reactive_graph_reactive_model_impl::ReactiveEntity;
12
13#[injectable]
14#[async_trait]
15pub trait EntityComponentBehaviourRegistry: Send + Sync + Lifecycle {
16    /// Registers a factory for creating entity component behaviours.
17    fn register(&self, component_behaviour_ty: ComponentBehaviourTypeId, factory: Arc<dyn BehaviourFactory<Uuid, ReactiveEntity> + Send + Sync>);
18
19    /// Unregisters a factory for creating entity component behaviours.
20    fn unregister(&self, component_behaviour_ty: &ComponentBehaviourTypeId);
21
22    /// Returns all entity component behaviours.
23    fn get_all(&self) -> Vec<ComponentBehaviourTypeId>;
24
25    /// Returns the entity behaviour factories for the given component type.
26    fn get(&self, component_ty: &ComponentTypeId) -> Vec<Arc<dyn BehaviourFactory<Uuid, ReactiveEntity> + Send + Sync>>;
27
28    /// Returns the component behaviours for the given component type.
29    fn get_behaviour_types(&self, component_ty: &ComponentTypeId) -> Vec<ComponentBehaviourTypeId>;
30
31    /// Returns the entity behaviour for the given behaviour type if the entity component behaviour exists.
32    fn get_by_behaviour_type(&self, behaviour_ty: &BehaviourTypeId) -> Option<ComponentBehaviourTypeId>;
33
34    /// Returns the count of entity component behaviours.
35    fn count(&self) -> usize;
36}