← Back to team overview

dolfin team mailing list archive

Re: Ownership

 

2008/6/26 Garth N. Wells <gnw20@xxxxxxxxx>:
> Martin Sandve Alnæs wrote:
>>
>> If we can use references somewhere we use pointers, we should change
>> that. All factory functions will of course return pointers, and they
>> clearly give away ownership to the caller. Where else do we need to
>> use pointers?
>
> DiscreteFunction is an example where we use a number of pointers because a
> DiscreteFunction may or may not own the data. Without having a bunch of
> constructors, I don't know how to tell DiscreteFunction what it does and
> doesn't own.
>
> Pointers are also used quite a bit in DofMap and DofMapSet. These of course
> will be overhauled in the near future.

Ok. Also, we should allow FooVector and FooMatrix to be a "view" of an
object they don't own, or take over ownership. This may be important
if somebody tries to use dolfin as a component on the side and not the
main application framework, e.g. if they have an existing PETSc Mat or
Epetra_FEVector to use. Both are possible with shared_ptr, possibly
with custom deleters in special cases.

--
Martin


Follow ups

References