source: branches/NewStructure/src/DataArrays/DataArrayBase.hh

Last change on this file was 1414, checked in by MatthewWhiting, 10 years ago

Adding a SmartMask? class, and tidying up some of the code in DataArrayBase?.

File size: 1.7 KB
Line 
1#ifndef DUCHAMP_DATA_ARRAY_BASE_H_
2#define DUCHAMP_DATA_ARRAY_BASE_H_
3
4#include <iostream>
5#include <duchamp/duchamp.hh>
6#include <vector>
7
8namespace duchamp
9{
10    template <class T>
11    class DataArrayBase
12    {
13    public:
14        DataArrayBase<T>();
15        DataArrayBase<T>(std::vector<size_t> dim);
16        DataArrayBase<T>(const DataArrayBase<T>& other);
17        DataArrayBase<T>& operator= (const DataArrayBase<T>& other);
18        virtual ~DataArrayBase<T>();
19
20        T *data(){return itsArray;};
21        void setArray(T *arr){itsArray=arr;}; // share the storage
22        void copyArray(T *arr); // deep copy of array
23
24        std::vector<size_t> dim(){return itsDim;};
25        size_t ndim(){return itsDim.size();};
26        size_t size(){return itsNumPixels;};
27
28        T operator()(size_t pix);
29        T operator()(size_t *pix);
30        T operator()(std::vector<size_t> pix); // make pass-by-value, so we can allow for things like casa::IPosition::asStdVector()
31
32        void operator+=(T val);
33        void operator+=(DataArrayBase<T> &other);
34        void operator*=(T val);
35        void operator*=(DataArrayBase<T> &other);
36        void operator-=(T val);
37        void operator-=(DataArrayBase<T> &other);
38        void operator/=(T val);
39        void operator/=(DataArrayBase<T> &other);
40
41        DataArrayBase<T> operator+(DataArrayBase<T> &other);
42        DataArrayBase<T> operator-(DataArrayBase<T> &other);
43        DataArrayBase<T> operator*(DataArrayBase<T> &other);
44        DataArrayBase<T> operator/(DataArrayBase<T> &other);
45
46        void throwInitErr(){DUCHAMPTHROW("DataArrayBase", "Array not initialised");};
47
48    protected:
49   
50        void setup();
51        size_t pixArrayToPos(size_t *pix);
52        size_t pixVecToPos(std::vector<size_t> pix);
53   
54        T *itsArray;
55        std::vector<size_t> itsDim;
56        size_t itsNumPixels;
57   
58    };
59
60}
61
62#include <duchamp/DataArrays/DataArrayBase.tcc>
63
64#endif
Note: See TracBrowser for help on using the repository browser.