C++ mpi module for stochmagnet_main Package
MPI_Addrs.h
1 #ifndef MPI_Addrs_H
2 #define MPI_Addrs_H
3 
4 //mpi object
5 #include "MPI_Object.h"
6 
7 
8 //types header
9 #include "MPI_Type.h"
10 
19 class MPI_Addrs : public MPI_Object {
20 
21 
22  // ATTRIBUTES
23 
24 public:
25 
26 
27 
28 private:
29 
30  tMPIByte mAddress;
31 
32 public:
33  // METHODS
34 
35  // CONSTRUCTORS
36 
39  MPI_Addrs(void) {
40  mAddress=0;
41  }
42 
43 
44 
45  // DESTRUCTORS
46 
47 
50  virtual ~MPI_Addrs(void) {
51  }
52 
53 
54 public:
55 
58  virtual tMemSize getMemorySize() const {
59  return sizeof(*this)+getContentsMemorySize();
60  }
61 
62 public:
63 
68  template<class T>
69  inline MPI_Addrs& operator=(const T& variable) {
70  MPI_Get_address(&variable,&mAddress);
71  return (*this);
72  }
73 
74 
78  inline tMPIByte& operator()() {
79  return mAddress;
80  }
84  inline const tMPIByte& operator()() const {
85  return mAddress;
86  }
87 
88 
89 
90  //arithmetic operator
91  //==================
96  inline MPI_Addrs& operator+=(const MPI_Addrs& adr) {
97  mAddress=MPI_Aint_add(mAddress,adr());
98  return (*this);
99  }
104  inline MPI_Addrs& operator+=(const tMPIByte& adr) {
105  mAddress=MPI_Aint_add(mAddress,adr);
106  return (*this);
107  }
112  inline MPI_Addrs& operator-=(const MPI_Addrs& adr) {
113  mAddress=MPI_Aint_diff(mAddress,adr());
114  return (*this);
115  }
120  inline MPI_Addrs& operator-=(const tMPIByte& adr) {
121  mAddress=MPI_Aint_diff(mAddress,adr);
122  return (*this);
123  }
124 
125  // GET methods
126 
127 
128 public:
129 
130 public:
131 
132 
133  //primary type manupulation
134  //==========================
135 
136 public:
137 
138 
139 
147  template<typename T>
148  inline static tMPIError GetAddress(const T* variable,tMPIByte& address) {
149  return MPI_Get_address(variable,&address);
150  }
151 
152  /* !\brief sum the adress
153  * @param[in] addresse1 : the addresses to sum
154  * @param[in] addresse2 : the addresses to sum
155  * @return address1+address2
156  */
157  inline static tMPIByte Sum(const tMPIByte& address1,const tMPIByte& address2) {
158  return MPI_Aint_add(address1,address2);
159  }
165  inline static tMPIByte Sub(const tMPIByte& address1,const tMPIByte& address2) {
166  return MPI_Aint_diff(address1,address2);
167  }
168 
169 };
170 
171 
172 
173 #endif
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class manages MPI Addresses.
Definition: MPI_Addrs.h:19
MPI_Addrs & operator-=(const tMPIByte &adr)
sub operator
Definition: MPI_Addrs.h:120
virtual ~MPI_Addrs(void)
destroy
Definition: MPI_Addrs.h:50
MPI_Addrs & operator+=(const tMPIByte &adr)
add operator
Definition: MPI_Addrs.h:104
virtual tMemSize getMemorySize() const
return the memory size of the class
Definition: MPI_Addrs.h:58
MPI_Addrs & operator=(const T &variable)
set operator
Definition: MPI_Addrs.h:69
static tMPIError GetAddress(const T *variable, tMPIByte &address)
get the address
Definition: MPI_Addrs.h:148
MPI_Addrs & operator-=(const MPI_Addrs &adr)
sub operator
Definition: MPI_Addrs.h:112
const tMPIByte & operator()() const
get operator
Definition: MPI_Addrs.h:84
tMPIByte & operator()()
get operator
Definition: MPI_Addrs.h:78
MPI_Addrs & operator+=(const MPI_Addrs &adr)
add operator
Definition: MPI_Addrs.h:96
static tMPIByte Sub(const tMPIByte &address1, const tMPIByte &address2)
sub the adress
Definition: MPI_Addrs.h:165
MPI_Addrs(void)
create
Definition: MPI_Addrs.h:39
This class is a base class of E-MicromM core package.
Definition: MPI_Object.h:32