COOLFluiD
Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
|
A boost::shared_ptr is a specialized pointer to the allocated object that keeps and shares ownership with other boost::shared_ptr's to the same object. The allocated object is deleted from memory only when all boost::shared_ptr's are deleted.
Following snippet shows the advantages of boost::shared_ptr, used for the Component environment
More information on boost::shared_ptr can be found at boost::shared_ptr docs.
The Handle class is a specialized pointer type, working together with boost::shared_ptr's. Handle's don't share ownership as boost::shared_ptr's do. Handle's have a mechanism to keep track if there are still boost::shared_ptr's sharing ownership. If all boost::shared_ptr's are deleted, the boost::weak_ptr will know this.
A Handle can be created from any boost::shared_ptr or other handles:
When working with components it is generally advised to use Handles and not boost::shared_ptr's, as algorithms might keep objects in memory, even though the user specifically meant to delete a component from memory.
Do not use Handle as the return type for functions returning a boost::shared_ptr! This shared_ptr will be deleted immediately, and thus delete the allocated object, without transferring ownership to the handle. This mistake will not be caught by compilers!
Send comments to: COOLFluiD Web Admin |