use crate::facet::applied::AppliedArgument;
use crate::node::constant::ConstExprNode;
use crate::node::interface::InterfaceNode;
use crate::node::type_::TypeNode;
use alloc::string::String;
use alloc::vec::Vec;
use zerodds_ast_core::{Id, Ref, RepositoryId};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum RepositoryIdOrigin {
Derived,
PragmaPrefix,
PragmaVersion,
PragmaId,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ComponentRole {
Facet {
name: String,
interface: Ref<InterfaceNode>,
},
Receptacle {
name: String,
interface: Ref<InterfaceNode>,
multiple: bool,
},
EventSource {
name: String,
event: Ref<TypeNode>,
publisher: bool,
},
EventSink {
name: String,
event: Ref<TypeNode>,
},
HomeFactory,
HomeFinder,
PortTypeRole,
ConnectorRole,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StateVisibility {
Public,
Private,
}
impl StateVisibility {
pub const ALL: [Self; 2] = [Self::Public, Self::Private];
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Public => "public",
Self::Private => "private",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TemplateParamKind {
TypeName,
Const,
Sequence,
Interface,
ValueType,
EventType,
Struct,
Union,
Exception,
Enum,
}
impl TemplateParamKind {
pub const ALL: [Self; 10] = [
Self::TypeName,
Self::Const,
Self::Sequence,
Self::Interface,
Self::ValueType,
Self::EventType,
Self::Struct,
Self::Union,
Self::Exception,
Self::Enum,
];
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TemplateParam {
pub name: String,
pub kind: TemplateParamKind,
pub constraint: Option<Ref<TypeNode>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TemplateArg {
Type(Ref<TypeNode>),
Const(Id<ConstExprNode>),
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct CorbaFacet {
pub repository_id: Option<RepositoryId>,
pub repository_id_origin: Option<RepositoryIdOrigin>,
pub component_role: Option<ComponentRole>,
pub supports: Vec<Ref<InterfaceNode>>,
pub state_visibility: Option<StateVisibility>,
pub is_event_type: bool,
pub template_params: Vec<TemplateParam>,
pub template_args: Vec<TemplateArg>,
pub native_mapping: Option<String>,
pub is_service: bool,
pub service_arguments: Vec<AppliedArgument>,
pub is_ami: bool,
pub manages: Option<HomeManages>,
pub imports: Vec<String>,
pub repository_directives: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HomeManages {
pub component: Ref<InterfaceNode>,
pub primary_key: Option<Ref<TypeNode>>,
}