octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about sharing data structure in octave


From: John W. Eaton
Subject: Question about sharing data structure in octave
Date: Sat, 28 Jun 2008 04:54:40 -0400

On 27-Jun-2008, Michael Goffioul wrote:

| I would like to request some comments about the best way to
| implement shared data structure in octave. What I'm thinking
| about is to have a C++ object that I want to make accessible
| from the interpreter, through some octave_base_value inherited
| class. At the interpreter level, I want this data structure to act
| as a reference/pointer, not as a value: assigning to another
| variable would share the same data structure without copying
| it. This means in fine to use some reference counting. Now the
| question is where to implement this mechanism:
| 
| 1) octave_value uses sharing mechanism with its internal
| octave_base_value representation; so I could inherit from
| octave_base_value and implement my C++ data structure
| in it, using implicitly the octave_value reference counting.
| However, what I don't know is the situation where octave_value
| decides to clone/copy itself: it must do so, because by
| default octave deals with values and not references
| 
| 2) define 2 classes: one pure C++ to hold my data structure
| and is reference-counted, and one class inheriting from
| octave_base_value that contains the pure C++ object and
| handle the reference counting. This decouples completely
| the sharing mechanism with the one from octave_value,
| but increases the complexity and number of classes/objects

I'm not sure I understand precisely what it is you want to do, but
since the reference counting is managed in the octave_value class, why
not add a field that says what the copying policy should be, then use
that in the functions that manipulate the reference count?  Would that
work for what you want to do?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]