xc
ConstantILayerVarRef.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //ConstantILayerVarRef.h
22 
23 #ifndef CONSTANTILAYERVARREF_H
24 #define CONSTANTILAYERVARREF_H
25 
26 #include "Array3dRange.h"
27 
28 
30 //
32 template <class ARRAY_3D>
33 class ConstantILayerVarRef: public Array3dBoxVarRef<ARRAY_3D>
34  {
35  public:
36  typedef typename Array3dBoxVarRef<ARRAY_3D>::const_reference const_reference;
37  typedef typename Array3dBoxVarRef<ARRAY_3D>::reference reference;
38 
39  explicit ConstantILayerVarRef(ARRAY_3D &m,const size_t &iLayer=1,const size_t &f= 1,const size_t &c= 1);
40  ConstantILayerVarRef(ARRAY_3D &m,const size_t &,const size_t &,const size_t &,const size_t &,const size_t &);
41  ConstantILayerVarRef(ARRAY_3D &t,const size_t &iLayer,const RangoIndice &row_range,const RangoIndice &column_range);
42  inline virtual ~ConstantILayerVarRef(void) {}
43  size_t getLayerIndex(void) const
44  { return this->offset_cp+1; }
45  virtual const_reference operator()(size_t iRow=1,size_t col=1) const
46  { return Array3dBoxVarRef<ARRAY_3D>::operator()(1,iRow,col); }
47  virtual reference operator()(size_t iRow=1,size_t col=1)
48  { return Array3dBoxVarRef<ARRAY_3D>::operator()(1,iRow,col); }
49  };
50 
51 template<class ARRAY_3D>
52 ConstantILayerVarRef<ARRAY_3D>::ConstantILayerVarRef(ARRAY_3D &t,const size_t &iLayer,const size_t &f,const size_t &c)
53  : Array3dBoxVarRef<ARRAY_3D>(t,Array3dRange(iLayer,RangoIndice(f,t.getNumberOfRows()),RangoIndice(c,t.getNumberOfColumns()))) {}
54 
55 template<class ARRAY_3D>
56 ConstantILayerVarRef<ARRAY_3D>::ConstantILayerVarRef(ARRAY_3D &t,const size_t &iLayer,const size_t &f1,const size_t &c1,const size_t &f2,const size_t &c2)
57  : Array3dBoxVarRef<ARRAY_3D>(t,iLayer,RangoIndice(f1,f2),RangoIndice(c1,c2)) {}
58 
59 template<class ARRAY_3D>
60 ConstantILayerVarRef<ARRAY_3D>::ConstantILayerVarRef(ARRAY_3D &t,const size_t &iLayer,const RangoIndice &row_range,const RangoIndice &column_range)
61  : Array3dBoxVarRef<ARRAY_3D>(t,iLayer,row_range,column_range)
62  {}
63 
64 #endif
size_t offset_cp
Offset layer.
Definition: Array3dBoxRefBase.h:40
Reference to a "sub-array".
Definition: Array3dBoxVarRef.h:33
Reference to a layer of the array which points have constant I index.
Definition: ConstantILayerVarRef.h:33
Rangos de variación de tres índices, se emplea en BoxConstRef.
Definition: Array3dRange.h:32
Rango de variación de un índice, se emplea en BoxConstRef.
Definition: RangoIndice.h:30