Just a quick question, if you have the following code :
c4_View viewB = viewA.Duplicate();
and then you want to re-assign viewB i.e.
viewB = viewC.Duplicate();
What should you call prior to re-assigning viewB to ensure that the "first"
viewB is properly destroyed. For example, would the following do it :
viewB = viewA.Duplicate(); viewB.RemoveAll (); viewB = viewC.Duplicate();
There are two types of destruction. If the view is attached to a storage, the RemoveAll() will make sure all its rows are deleted (on file too, after commit).
If all you care about is memory use and object clean-up, then you don't have to do anything. MK uses a technique called "smart pointers" in C++, which automatically manages all reference counts. The line
viewB = viewC.Duplicate();
does a number of things:
- it creates a new view with copies of what is in viewC
- it increments the reference count of that new view
- it decrements the refcount of whatever was in viewB
- it makes viewB refer to the newly created copy
If viewB previously referred to a copy of viewA, and if no other view object refers to it, then the decrement will cause that copy to be cleaned up.
This is fully automatic in C++, as long as you stay away from pointers to c4_Views. There is no need whatsoever for these (same for c4_Storage, btw), not even performance-wise because c4_View objects are very very lightweight objects. Enjoy the magic of smart pointers!
-jcw
_______________________________________________ metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit
