summaryrefslogtreecommitdiffstats
path: root/rasodmg/marray.hh
blob: 8b5e5ea39a567e40e553391e5529eb1443785a26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/
/**
 * INCLUDE: marray.hh
 *
 * MODULE:  rasodmg
 * CLASS:   r_Marray
 *
 * COMMENTS:
 *		None
*/

#ifndef _D_MARRAY_
#define _D_MARRAY_

#include "rasodmg/gmarray.hh"

#include <iostream>

using namespace std;

 
//@ManMemo: Module: {\bf rasodmg}

/*@Doc:

 The central class of the library for representing an MDD
 object is named r_Marray. Through overloading operators,
 the handling of an MDD object is similar to the usage of
 a normal C or C++ array from the programmers point of view. 
 
*/ 
 
template<class T>
class r_Marray : public r_GMarray
{
  public:
    /// function type for initialization function
    typedef T (*r_InitFunction)(const r_Point&);
    
    /// default constructor (no memory is allocated!)
    r_Marray() throw(r_Error);
    
    /// constructor for uninitialized MDD objects
    r_Marray( const r_Minterval&, r_Storage_Layout* stl = 0 ) throw(r_Error);
    /**
      If a storage layout pointer is provided, the object refered to is
      taken and memory control moves to the \Ref{r_Marray} class.
      The user has to take care, that each creation of \Ref{r_Marray}
      objects get a new storage layout object.
    */

    /// constructor for constant MDD objects
    r_Marray( const r_Minterval&, const T&, r_Storage_Layout* stl = 0 ) throw(r_Error);         
    /**
      If a storage layout pointer is provided, the object refered to is
      taken and memory control moves to the \Ref{r_Marray} class.
      The user has to take care, that each creation of \Ref{r_Marray}
      objects get a new storage layout object.
    */

    /// constructor with initializing function
    r_Marray( const r_Minterval&, r_InitFunction, r_Storage_Layout* stl = 0 ) throw(r_Error);
    /**
      If a storage layout pointer is provided, the object refered to is
      taken and memory control moves to the \Ref{r_Marray} class.
      The user has to take care, that each creation of \Ref{r_Marray}
      objects get a new storage layout object.
    */
                                       
    /// copy constructor
    r_Marray( const r_Marray<T>& ) throw(r_Error);

    /// constructor getting an object of type r_GMarray
    r_Marray( r_GMarray& ) throw(r_Error);
    /*
      This constructor is used for converting general \Ref{r_GMarray} objects
      to cell type safe \Ref{r_Marray} objects. Care has to be taken because
      the memory of the \Ref{r_GMarray} can not be used anymore; it is passed 
      to the \Ref{r_Marray<T>} object.
    */

    /// destructor
    virtual ~r_Marray();

    /// assignment: cleanup + copy
    const r_Marray& operator= ( const r_Marray& ); 

    /// subscript operator for projection in the 1st dimension 
    r_Marray<T> operator[]( long ) const 
      throw(r_Eindex_violation);
    
    /// subscript operator for restriction/extension combination  
    r_Marray<T> operator[]( const r_Minterval& ) const
      throw( r_Edim_mismatch );
    
    /// subscript operator for read access of a cell
    const T& operator[]( const r_Point& ) const
      throw(r_Edim_mismatch, r_Eindex_violation);
      
    /// subscript operator for write access of a cell
    T& operator[]( const r_Point& )
      throw(r_Edim_mismatch, r_Eindex_violation);

    /// cast operator for converting to base type for cell access
    operator T()
      throw( r_Eno_cell ); 
      
    /// writes the state of the object to the specified stream
    virtual void print_status( std::ostream& s = cout ) const;
};

#include "rasodmg/marray.icc"

#ifdef EARLY_TEMPLATE
#ifdef __EXECUTABLE__
#ifdef __VISUALC__
#include "rasodmg/marray.cpp"
#else
#include "rasodmg/marray.cc"
#endif
#endif 
#endif

#endif