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
46
47
48
49
50
51
//! Contains action definitions via the [`ActionDefinition`] type.

use crate::types::TypedVariables;
use crate::types::{ActionSymbol, Effect, PreGD};

/// An action definition.
#[derive(Debug, Clone, PartialEq)]
pub struct ActionDefinition<'a> {
    symbol: ActionSymbol<'a>,
    parameters: TypedVariables<'a>,
    precondition: Option<PreGD<'a>>,
    effect: Option<Effect<'a>>,
}

impl<'a> ActionDefinition<'a> {
    pub const fn new(
        symbol: ActionSymbol<'a>,
        parameters: TypedVariables<'a>,
        precondition: Option<PreGD<'a>>,
        effect: Option<Effect<'a>>,
    ) -> Self {
        Self {
            symbol,
            parameters,
            precondition,
            effect,
        }
    }

    pub const fn symbol(&self) -> &ActionSymbol<'a> {
        &self.symbol
    }

    pub const fn parameters(&self) -> &TypedVariables<'a> {
        &self.parameters
    }

    pub const fn precondition(&self) -> &Option<PreGD<'a>> {
        &self.precondition
    }

    pub const fn effect(&self) -> &Option<Effect<'a>> {
        &self.effect
    }
}

impl<'a> AsRef<ActionSymbol<'a>> for ActionDefinition<'a> {
    fn as_ref(&self) -> &ActionSymbol<'a> {
        &self.symbol
    }
}