array_dec.h 5.86 KB
Newer Older
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*! \file array_dec.h
 * \brief array class declarations (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
 * $Id: array_dec.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $
 * \author Thomas Forbriger
 * \date 01/05/2002
 * 
 * array class declarations (prototypes)
 * 
 * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
 * 
 * REVISIONS and CHANGES 
 *  - 01/05/2002   V1.0   Thomas Forbriger
 *  - 22/11/2002   V1.1   
 *                        - use Strided as default
 *                        - index-constructors are deprecated (use shapers)
 * 
 * ============================================================================
 */

// include guard
#ifndef TF_ARRAY_DEC_H_VERSION

#define TF_ARRAY_DEC_H_VERSION \
  "TF_ARRAY_DEC_H   V1.1   "
#define TF_ARRAY_DEC_H_CVSID \
  "$Id: array_dec.h,v 1.1 2002-12-06 19:08:18 forbrig Exp $"

#include <contxx/repr/sharedheap.h>
#include <contxx/shape/strided_repr.h>
#include <contxx/shape/range.h>

namespace contxx {

#ifdef CONTXX_PREBUILT
namespace prebuilt {
#endif

#ifdef CONTXX_PREBUILT
  using namespace contxx::prebuilt::util;
  using namespace contxx::prebuilt::shape;
  using  contxx::prebuilt::representation::SharedHeap;
  using  contxx::prebuilt::subscriptor::StridedRepresentation;
#else
  using namespace contxx::util;
  using namespace contxx::shape;
  using  contxx::representation::SharedHeap;
  using  contxx::subscriptor::StridedRepresentation;
#endif

  /*! \brief Full multi-dimensional array functionality.
   *
   * The array class highly depends on base classes from which inherts most of
   * its functionality. 
   * The user may select from several provided array designs through template
   * parameters:
   * \param T element type of array (passed to Subscriptor base class)
   * \param N dimensionality of array (passed to Subscriptor base class)
   * \param Representation Representation (engine for memory access) base
   *        class type (passed to Subscriptor base class)
   * \param Subscriptor Subscriptor base class type
   *
   * \sa \ref page_shapes_and_subscriptors
   * \sa \ref page_representation
   * \sa \ref sec_main_modules
   * \sa tests/arraytest.cc
   */
  template<class T,
           Tdim N=1,
           template<class TT> 
             class Representation=SharedHeap,
           template<class TT, Tdim NN, template<class TTT> class RR> 
             class Subscriptor=StridedRepresentation>
    class Array:
      public Subscriptor<T, N, Representation>
    {
        public:
          //! Type of representation
          typedef Representation<T> Trepresentation;
          //! Type of subscriptor
          typedef Subscriptor<T, N, Representation> Tsubscriptor;
          //! Type of shape
          typedef typename Tsubscriptor::Tshape Tshape;
          //! Element type
          typedef typename Trepresentation::Tvalue Tvalue;
          //! Type of pointer to element
          typedef typename Trepresentation::Tpointer Tpointer;
          //! Type of reference to element
          typedef typename Trepresentation::Treference Treference;
          //! Type of const reference to element
          typedef typename Trepresentation::Tconst_reference Tconst_reference;
          //! Type to be used as data representation
          typedef typename Trepresentation::Tmutable_value Tmutable_value;
          //! Type to be used as element for const version
          typedef typename Trepresentation::Tconst_value Tconst_value;
          //! Type of this array
          typedef Array<T, N, Representation, Subscriptor> Tcontainer;
          //! Type of the array of const values
          typedef Array<Tconst_value, N, Representation, Subscriptor>
              Tcontainer_of_const;
          /*! \brief \b deprecated! Type of size array
           * \deprecated
           * This feature may be removed in future versions
           */
          typedef SimpleRigidArray<Tsize, N> Tsizes;
          /*! \brief \b deprecated! Type of range 
           * \deprecated
           * This feature may be removed in future versions
           */
          typedef Range<Tsubscript> Trange;
          /*! \brief \b deprecated! Type of range array
           * \deprecated
           * This feature may be removed in future versions
           */
          typedef SimpleRigidArray<Trange, N> Tranges;

          //! construct from nothing (empty)
          Array() { }
          //! construct from shape and representation
          Array(const Tshape& shape, 
                const Trepresentation& representation);
          //! construct from shape
          explicit Array(const Tshape& shape);
          /*! \brief \b deprecated! construct from sizes
           * \deprecated
           * This constructor may be removed in future versions
           * Use shapers instead.
           */
          explicit Array(const Tsizes& size);
          /*! \brief \b deprecated! construct from ranges
           * \deprecated
           * This constructor may be removed in future versions.
           * Use shapers instead.
           */
          explicit Array(const Tranges& ranges);

          //! conversion to container of const values
          operator Tcontainer_of_const() const
          {
            Tcontainer_of_const retval(*this, *this);
            return(retval);
          }

          //! by size we mean the size defined by the shape
          Tsize size(const Tsubscript& i) const
          { return(this->Tshape::size(i)); }
          //! by size we mean the size defined by the shape
          Tsize size() const
          { return(this->Tshape::size()); }
            
          //! set value to whole array
          Array& operator=(const T& value);

    }; // class Array

#ifdef CONTXX_PREBUILT
} // namespace prebuild
#endif

} // namespace contxx

#ifndef CONTXX_NO_DEFINITIONS
#include <contxx/array_def.h>
#endif

#endif // TF_ARRAY_DEC_H_VERSION (includeguard)

/* ----- END OF array_dec.h ----- */