PR #1012 is a refactoring of Arrays in a least-intrusive manner: in summary it adds move support, std-like allocator support and removes dependencies. There is a possibility for further enhancement of Arrays, but this will be more intrusive. This ticket is to collect ideas and discuss these. Similar things might hold for other parts within the casa module, but this ticket aims at Arrays only. For now.
Ideas:
Make Array assignment and construction semantically equal (so either both value semantics, or both reference semantics). This could make the move constructor & assignment much simpler, making those faster. Movement of Arrays could also to some level make some of the pointer methods and shared storages redundant.
Same for MaskedArray.
Replace Array::getStorage() and Array::putStorage() by ones that take/return a smart pointer. Remove freeStorage().
Make Array::nrefs() private; it's dangerous (shared-constructed storages would return 1) and an internal detail. New function isShared could be made public instead.
Rename & replace Arrays::cbegin() and cend(), similar to C++11 containers where they refer to the const iterator variants, while in Arrays they are the contiguous variants.
Rename Arrays::reference(). Container::reference is normally a typedef for a reference to the element type.
The methods like median(const Array&, ...) (ArrayMath.h) with in-place sorting and const Array parameter should not be exposed.
Remove StorageInitPolicy enum and use tag dispatch, factory methods/named constructors or, in the case of takeStorage, just specifically named methods or overloads.
Improve the use of virtual methods. Some methods have two implementations, one with a 'V' behind it for polymorphism. I think this can be cleaned somewhat.
Think about a ArrayView class, as to make the Array class always contiguous.
PR #1012 is a refactoring of Arrays in a least-intrusive manner: in summary it adds move support, std-like allocator support and removes dependencies. There is a possibility for further enhancement of Arrays, but this will be more intrusive. This ticket is to collect ideas and discuss these. Similar things might hold for other parts within the casa module, but this ticket aims at Arrays only. For now.
Ideas:
Array::getStorage()
andArray::putStorage()
by ones that take/return a smart pointer. RemovefreeStorage()
.Array::nrefs()
private; it's dangerous (shared-constructed storages would return 1) and an internal detail. New function isShared could be made public instead.Arrays::cbegin()
andcend()
, similar to C++11 containers where they refer to the const iterator variants, while in Arrays they are the contiguous variants.Arrays::reference()
.Container::reference
is normally a typedef for a reference to the element type.median(const Array&, ...)
(ArrayMath.h) with in-place sorting and const Array parameter should not be exposed.std::string IPosition::toString() const
, favour to_string(IPosition).StorageInitPolicy
enum and use tag dispatch, factory methods/named constructors or, in the case of takeStorage, just specifically named methods or overloads.