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§
Sourcefn add_entity(
&mut self,
entity_id: &str,
entity: Value,
consumer: ChangeConsumer,
)
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 JSONconsumer- Function that adds the entity to the appropriate collection in the solution
Sourcefn remove_entity(&mut self, entity_id: &str, consumer: ChangeConsumer)
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 removeconsumer- Function that removes the entity from the appropriate collection
Sourcefn change_variable(
&mut self,
entity_id: &str,
variable_name: &str,
consumer: ChangeConsumer,
)
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 modifyvariable_name- Name of the planning variable to changeconsumer- Function that updates the variable value
Sourcefn add_problem_fact(
&mut self,
fact_id: &str,
fact: Value,
consumer: ChangeConsumer,
)
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 factfact- The problem fact data as JSONconsumer- Function that adds the fact to the appropriate collection
Sourcefn remove_problem_fact(&mut self, fact_id: &str, consumer: ChangeConsumer)
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 removeconsumer- Function that removes the fact from the appropriate collection
Sourcefn change_problem_property(&mut self, object_id: &str, consumer: ChangeConsumer)
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 factconsumer- Function that updates the property
Sourcefn look_up_working_object_or_fail(
&self,
external_id: &str,
) -> Result<Value, ProblemChangeError>
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
Sourcefn look_up_working_object(&self, external_id: &str) -> Option<Value>
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
Sourcefn update_shadow_variables(&mut self)
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.