ValueTree request/suggestion


#1

This may appear slightly esoteric, but…

Would it be possible to have a kind of ValueTreeWeakReference? I.e., an object which refers to a shared ValueTree content object only if it still exists, without keeping it alive; it could plop out a ValueTree for its target, which would be invalid if it’s already been destroyed elsewhere.

I won’t go into detail about the cases I’d be wanting it for just yet - first just thought I’d gauge the level of offence caused by the suggestion.


#2

Hmm… Not crazy about the idea… It’d mean adding another data member to every ValueTree to support the weak reference, so would need to have a pretty good reason for adding it.


#3

yeah, i figured it’d be a bit of an unwelcome bulk. There are other ways to do what I want anyway :slight_smile:


#4

You could always check the reference count, and if it’s 1, you know that nothing else is using the object.


#5

well, the main issue I have isn’t actually knowing whether it’s still in use, but allowing it to actually be destroyed naturally whilst something else is interested in knowing where the data is [without actually holding a ValueTree of it, as that would keep it alive].

Not to worry, I can achieve the same end by having a ‘search’ to re-locate the node, but I would have preferred to not have to - though of course not at the expense of the ValueTree’s slender perfection :)].


#6

Yeah, tricky one… Can’t think of a neat solution without fattening it up.


#7

was just thinking some more about this, and how i might be able to do something with the reference count - but there’s no access to the reference count anyway, is there? [as the count belongs to the secret shared object]


#8

Did I not provide an accessor method for the secret shared object? (Probably better not to, really…)


#9

No, and it makes sense for it to be so.

Value provides access to its ValueSource, but then ValueSource is also a visible class [whereas the ValueTree is a maximum security vault]. It’d be nice to be able to have access to the refcount like you can with refcounted objects in general, but it’s obviously pretty dangerous for the wrapper to have a direct interface to it.

i shall have to find another way!