OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
IndexedField.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef INDEXED_FIELD_H
12 #define INDEXED_FIELD_H
13 
14 // include files
15 #include "Field/IndexedBareField.h"
16 #include "Utility/PAssert.h"
17 
18 #include <iostream>
19 
20 // forward declarations
21 template<class T, unsigned D, class M, class C> class Field;
22 
23 //----------------------------------------------------------------------
24 
25 template < class T, unsigned Dim, unsigned Brackets, class M, class C>
26 class IndexedField : public IndexedBareField<T,Dim,Brackets>
27 {
28 
29  friend class IndexedField<T,Dim,Brackets-1,M,C>;
30  friend class Field<T,Dim,M,C>;
31 
32 public:
33 
35  {
36  CTAssert(Brackets<Dim);
38  }
40  {
41  CTAssert(Brackets<Dim);
43  }
44  // Also allow using a single NDIndex instead of N Index objects:
46  {
47  CTAssert(Brackets<Dim);
49  }
50 
51  void operator=(T x)
52  {
53  assign(*this,x);
54  }
55 
58  {
59  CTAssert(Dim==Brackets);
60  assign(*this,x);
61  return *this;
62  }
63 
65  operator=(const Index& x)
66  {
67  assign(*this,x);
68  return *this;
69  }
70 
71  template<class T1, unsigned Dim1, unsigned Brackets1, class M1, class C1>
74  {
75  CTAssert(Dim1==Brackets1);
76  assign(*this,x);
77  return *this;
78  }
79 
80  template<class B>
83  {
84  assign(*this,x);
85  return *this;
86  }
87 
88 
89  Field<T,Dim,M,C>& getField() { return F; }
90  const Field<T,Dim,M,C>& getField() const { return F; }
91 
92 protected:
93 
95 
96  // Make the constructors private so that only Field and IndexedField
97  // can construct them.
99  : IndexedBareField<T,Dim,Brackets>(f,idx), F(f) {}
101  : IndexedBareField<T,Dim,Brackets>(f,i), F(f) {}
103  : IndexedBareField<T,Dim,Brackets>(f,idx,i), F(f) {}
104  // Also allow using a single NDIndex instead of N Index objects:
106  : IndexedBareField<T,Dim,Dim>(f,ndidx), F(f) {}
107 
108 };
109 
111 
112 #endif // INDEXED_FIELD_H
113 
114 /***************************************************************************
115  * $RCSfile: IndexedField.h,v $ $Author: adelmann $
116  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
117  * IPPL_VERSION_ID: $Id: IndexedField.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
118  ***************************************************************************/
IndexedField< T, Dim, Brackets+1, M, C > operator[](const Index &idx)
Definition: IndexedField.h:34
Definition: PETE.h:80
Definition: rbendmap.h:8
void operator=(T x)
Definition: IndexedField.h:51
IndexedField< T, Dim, Dim, M, C > operator[](const NDIndex< Dim > &ndidx)
Definition: IndexedField.h:45
IndexedField< T, Dim, Brackets+1, M, C > operator[](int i)
Definition: IndexedField.h:39
#define CTAssert(c)
Definition: PAssert.h:40
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
Field< T, Dim, M, C > & getField()
Definition: IndexedField.h:89
IndexedField< T, Dim, Brackets, M, C > & operator=(const IndexedField< T, Dim, Brackets, M, C > &x)
Definition: IndexedField.h:57
IndexedField(Field< T, Dim, M, C > &f, const Index &idx)
Definition: IndexedField.h:98
Definition: Index.h:236
IndexedField(Field< T, Dim, M, C > &f, const NDIndex< Dim > &ndidx)
Definition: IndexedField.h:105
IndexedField(Field< T, Dim, M, C > &f, int i)
Definition: IndexedField.h:100
IndexedField< T, Dim, Brackets, M, C > & operator=(const IndexedField< T1, Dim1, Brackets1, M1, C1 > &x)
Definition: IndexedField.h:73
const unsigned Dim
const Field< T, Dim, M, C > & getField() const
Definition: IndexedField.h:90
IndexedField(Field< T, Dim, M, C > &f, const NDIndex< Brackets-1 > &idx, const Index &i)
Definition: IndexedField.h:102
IndexedField< T, Dim, Brackets, M, C > & operator=(const PETE_Expr< B > &x)
Definition: IndexedField.h:82
IndexedField< T, Dim, Brackets, M, C > & operator=(const Index &x)
Definition: IndexedField.h:65
Field< T, Dim, M, C > & F
Definition: IndexedField.h:94