On 18/01/2007, at 8:33 PM, Andy Dent wrote:
On 18/01/2007, at 3:53 PM, Tom Benson wrote:
Each block of data will be represented by a class object by my
framework, so I'd like to instantiate only one object and pass it
byref to the parts of the program that will be working with it.
Do you really mean ByRef in the RB sense or as a reference, which
of course all objects are passed as?
ie: will the things working with it send back a different object?
I'd like every part of the program that is modifying the unique data
object to be working with the same instance, so that once one part of
the program changes something it is reflected when other parts of the
program access that data block.
This is easy enough, as each block has a unique signature, so I've
set up a dictionary to store the single instance keyed against
that data blocks unique id.
Unless the lookups are very very frequent, you will still get a
fairly efficient lookup from a string storing the hex
representation of the object ID.
off the top of my head:
dim v as variant = myObject
dim id as integer = v.integerValue ' we now have the unique ID
dim theKey as string = Hex(id) ' string representation has no link
to the object, so no effect on reference count
I would put the above into an extends method on Object, so you can
use it any time.
We used string keys in an Object layer in a c++ program talking to
the MS SQL engine. It was plenty fast enough for dealing with
hundreds of objects when doing lookups to see if things were cached.
I was under the impression that there was no guarantee that
variant.integerValue would return a unique value for an object, only
for integer's and colours... or am I thinking of variant.hash???
Either way, my database automatically supplies a unique id with each
data block, so that is not really the issue. The issue is removing
that object from my lookup dictionary once the rest of the program
drops all references to that object.
- Tom
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>