Representation

Trait Representation 

Source
pub trait Representation:
    Send
    + Sync
    + Debug {
    // Required methods
    fn init(name: &Name, symtab: &SymbolTable) -> Option<Self>
       where Self: Sized;
    fn variable_name(&self) -> &Name;
    fn value_down(
        &self,
        value: Literal,
    ) -> Result<BTreeMap<Name, Literal>, ApplicationError>;
    fn value_up(
        &self,
        values: &BTreeMap<Name, Literal>,
    ) -> Result<Literal, ApplicationError>;
    fn expression_down(
        &self,
        symtab: &SymbolTable,
    ) -> Result<BTreeMap<Name, Expression>, ApplicationError>;
    fn declaration_down(&self) -> Result<Vec<DeclarationPtr>, ApplicationError>;
    fn repr_name(&self) -> &str;
    fn box_clone(&self) -> Box<dyn Representation>;
}
Expand description

Encodes the two-way relationship between a non-atomic variable and multiple auxiliary variables.

For example, a 2x2 matrix X might be represented by a variable for each element X1_1 X1_2 X2_1 X2_2. The Representation for X then allows us to set the value of the matrix, and takes care of assigning the individual variables accordingly. Conversly, we can set the values of the elements, and the Representation will return an assignment for the matrix as a whole.

Required Methods§

Source

fn init(name: &Name, symtab: &SymbolTable) -> Option<Self>
where Self: Sized,

Creates a representation object for the given name.

Source

fn variable_name(&self) -> &Name

The variable being represented.

Source

fn value_down( &self, value: Literal, ) -> Result<BTreeMap<Name, Literal>, ApplicationError>

Given an assignment for self, creates assignments for its representation variables.

Source

fn value_up( &self, values: &BTreeMap<Name, Literal>, ) -> Result<Literal, ApplicationError>

Given assignments for its representation variables, creates an assignment for self.

Source

fn expression_down( &self, symtab: &SymbolTable, ) -> Result<BTreeMap<Name, Expression>, ApplicationError>

Returns Expressions representing each representation variable.

Source

fn declaration_down(&self) -> Result<Vec<DeclarationPtr>, ApplicationError>

Creates declarations for the representation variables of self.

Source

fn repr_name(&self) -> &str

The rule name for this representaion.

Source

fn box_clone(&self) -> Box<dyn Representation>

Makes a clone of self into a Representation trait object.

Trait Implementations§

Source§

impl Clone for Box<dyn Representation>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§