reactive_graph_behaviour_service_api/
relation_component_behaviour_registry.rs

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