This enhancement renames the HolonFieldGettable Trait to HolonGettable and changes both the signature and implementation of this trait to push the need for mutable references deeper by leveraging interior mutability. Specifically, this enhancement:
enhances CacheManager to support interior mutability
renames HolonFieldGettable Trait to HolonGettable Trait
changes signatures of existing trait functions to take &self instead of &mut self.
changes the implementation of this trait for Holon, HolonReference, StagedReference, and SmartReference to reflect the above changes.
Dependencies
[x] Issue 84
[x] Issue 105
Current State
Currently, the methods in HolonFieldGettable support a couple of "read" operations on Holons and the objects that reference them. But despite being "read-only" operations, they take a &mut self parameter because some Memory Layer changes take place as a result of invoking these methods.
Proposal
Enhance the CacheManager to support interior mutability, then change the HolonFieldGettable trait and implementation to take advantage of this change.
Enhance CacheManager to support interior mutability
In the cache_manager.rs file
[x] Enhance the HolonCache definition to allow holons to be mutable
change the definition of HolonCache to pub struct HolonCache(Cache<HolonId, Rc<RefCell<Holon>>>) to allow inner mutation of the holon.
fix any code affected by this change
[x] Change get_rc_holon to return Rc<RefCell> and fix any code affected by this change
Change name, definition and implementation of HolonFieldGettable Trait
In the holon.rs file
[x] Shorten name of HolonFieldGettable Trait to just HolonGettable Trait
[x] Change get_property_value method to take &self instead of &mut self
[x] Change get_key method to take &self instead of &mut self
[x] Change the name and implementation of the HolonFieldGettable for the Holon struct
_In the holonreference.rs file
[x] Change the name and implementation of the HolonFieldGettable Trait for the HolonReference struct
_In the stagedreference.rs file
[x] Change the name and implementation of the HolonFieldGettable Trait for the StagedReference struct
In the holon.rs file
[x] Change the name and implementation of the HolonFieldGettable Trait for the SmartReference struct
Testing
Since this is just a re-factoring of existing functionality, no new tests are required.
This enhancement renames the
HolonFieldGettable
Trait toHolonGettable
and changes both the signature and implementation of this trait to push the need for mutable references deeper by leveraging interior mutability. Specifically, this enhancement:HolonFieldGettable
Trait toHolonGettable
Trait&self
instead of&mut self
.Holon
,HolonReference
,StagedReference
, andSmartReference
to reflect the above changes.Dependencies
Current State
Currently, the methods in HolonFieldGettable support a couple of "read" operations on Holons and the objects that reference them. But despite being "read-only" operations, they take a
&mut self
parameter because some Memory Layer changes take place as a result of invoking these methods.Proposal
Enhance the CacheManager to support interior mutability, then change the
HolonFieldGettable
trait and implementation to take advantage of this change.Enhance CacheManager to support interior mutability
In the cache_manager.rs file
[x] Enhance the HolonCache definition to allow holons to be mutable
pub struct HolonCache(Cache<HolonId, Rc<RefCell<Holon>>>)
to allow inner mutation of the holon.[x] Change> and fix any code affected by this change
get_rc_holon
to return Rc<RefCellChange name, definition and implementation of
HolonFieldGettable
TraitIn the holon.rs file
HolonFieldGettable
Trait to justHolonGettable
Trait&self
instead of&mut self
&self
instead of&mut self
_In the holonreference.rs file
_In the stagedreference.rs file
In the holon.rs file
Testing
Since this is just a re-factoring of existing functionality, no new tests are required.
Definition of Done