ProblemChangeDirector

Trait ProblemChangeDirector 

Source
pub trait ProblemChangeDirector: Send {
    // Required methods
    fn add_entity(
        &mut self,
        entity_id: &str,
        entity: Value,
        consumer: ChangeConsumer,
    );
    fn remove_entity(&mut self, entity_id: &str, consumer: ChangeConsumer);
    fn change_variable(
        &mut self,
        entity_id: &str,
        variable_name: &str,
        consumer: ChangeConsumer,
    );
    fn add_problem_fact(
        &mut self,
        fact_id: &str,
        fact: Value,
        consumer: ChangeConsumer,
    );
    fn remove_problem_fact(&mut self, fact_id: &str, consumer: ChangeConsumer);
    fn change_problem_property(
        &mut self,
        object_id: &str,
        consumer: ChangeConsumer,
    );
    fn look_up_working_object_or_fail(
        &self,
        external_id: &str,
    ) -> Result<Value, ProblemChangeError>;
    fn look_up_working_object(&self, external_id: &str) -> Option<Value>;
    fn update_shadow_variables(&mut self);
}
Expand description

Director for applying problem changes to the working solution.

All modifications to the solution during a problem change must go through this director to ensure proper tracking and variable listener notification.

Required Methods§

Source

fn add_entity( &mut self, entity_id: &str, entity: Value, consumer: ChangeConsumer, )

Add a new planning entity to the solution.

§Arguments
  • entity_id - Unique identifier for the entity (typically the @PlanningId value)
  • entity - The entity data as JSON
  • consumer - Function that adds the entity to the appropriate collection in the solution
Source

fn remove_entity(&mut self, entity_id: &str, consumer: ChangeConsumer)

Remove a planning entity from the solution.

The entity is looked up by its ID and the working copy is passed to the consumer.

§Arguments
  • entity_id - The ID of the entity to remove
  • consumer - Function that removes the entity from the appropriate collection
Source

fn change_variable( &mut self, entity_id: &str, variable_name: &str, consumer: ChangeConsumer, )

Change a planning variable on an entity.

§Arguments
  • entity_id - The ID of the entity to modify
  • variable_name - Name of the planning variable to change
  • consumer - Function that updates the variable value
Source

fn add_problem_fact( &mut self, fact_id: &str, fact: Value, consumer: ChangeConsumer, )

Add a new problem fact to the solution.

§Arguments
  • fact_id - Unique identifier for the problem fact
  • fact - The problem fact data as JSON
  • consumer - Function that adds the fact to the appropriate collection
Source

fn remove_problem_fact(&mut self, fact_id: &str, consumer: ChangeConsumer)

Remove a problem fact from the solution.

§Arguments
  • fact_id - The ID of the problem fact to remove
  • consumer - Function that removes the fact from the appropriate collection
Source

fn change_problem_property(&mut self, object_id: &str, consumer: ChangeConsumer)

Change a property on an entity or problem fact.

§Arguments
  • object_id - The ID of the entity or problem fact
  • consumer - Function that updates the property
Source

fn look_up_working_object_or_fail( &self, external_id: &str, ) -> Result<Value, ProblemChangeError>

Look up a working object by its external ID.

Returns a clone of the working object, or an error if not found.

§Arguments
  • external_id - The ID of the object to look up
Source

fn look_up_working_object(&self, external_id: &str) -> Option<Value>

Look up a working object by its external ID.

Returns None if the object is not found, rather than failing.

§Arguments
  • external_id - The ID of the object to look up
Source

fn update_shadow_variables(&mut self)

Trigger variable listeners for changes made so far.

This is called automatically after the entire problem change is processed, but can be called manually to trigger listeners mid-change.

Implementors§