1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This is free and unencumbered software released into the public domain.

use crate::ParsedMember;
use sysml_model::{
    prelude::{String, Vec},
    BlockUsage, Element, Feature, ItemUsage, Namespace, OccurrenceUsage, PartUsage, QualifiedName,
    Type, Usage,
};

#[doc(hidden)]
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ParsedBlock {
    pub name: Option<String>,
    pub short_name: Option<String>,
    pub definition: Option<QualifiedName>,
    pub members: Vec<ParsedMember>,
}

impl From<&str> for ParsedBlock {
    fn from(name: &str) -> Self {
        Self {
            name: Some(name.into()),
            ..Default::default()
        }
    }
}

impl BlockUsage for ParsedBlock {}
impl PartUsage for ParsedBlock {}
impl ItemUsage for ParsedBlock {}
impl OccurrenceUsage for ParsedBlock {}
impl Usage for ParsedBlock {}
impl Feature for ParsedBlock {}
impl Type for ParsedBlock {}
impl Namespace for ParsedBlock {}

impl Element for ParsedBlock {
    fn name(&self) -> Option<&str> {
        self.name.as_deref()
    }

    fn short_name(&self) -> Option<&str> {
        self.short_name.as_deref()
    }
}