00001
00002 #include "dataclient.h"
00003
00004 #ifndef _DATACLIENT_RECV_H_
00005 #define _DATACLIENT_RECV_H_
00006
00007 template <class Etype>
00008 int DataClient::RecvVariable(char *keyword, Etype *a)
00009 {
00010 int handle;
00011 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00012 if (!isVariable(handle)) return POSSE_FAILURE;
00013 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00014
00015 *a = 0;
00016 int size = QueryKeyword(keyword);
00017 if (size) RemoteSocket::RecvVar(a);
00018
00019 return POSSE_SUCCESS;
00020 }
00021
00022 template <class Etype>
00023 Etype DataClient::RecvVariable(char *keyword)
00024 {
00025 Etype a;
00026 RecvVariable(keyword, &a);
00027
00028 return a;
00029 }
00030
00031 inline int DataClient::RecvArray(char *keyword, void *a)
00032 {
00033 int handle;
00034 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00035 if (!isStaticArray(handle)) return POSSE_FAILURE;
00036
00037 int size = QueryKeyword(keyword);
00038 int elemsize = RecvVar<int>();
00039 RecvArrayGeneric(a, size, elemsize);
00040
00041 return POSSE_SUCCESS;
00042 }
00043
00044 template <class Etype>
00045 inline int DataClient::RecvArray1D(char *keyword, Etype *a)
00046 {
00047 int handle;
00048 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00049 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00050 if (!isDynamicArray(handle, 1)) return POSSE_FAILURE;
00051
00052 int n1 = QueryKeyword(keyword);
00053 RemoteSocket::RecvArray1D(a, n1);
00054
00055 return POSSE_SUCCESS;
00056 }
00057
00058 template <class Etype>
00059 inline int DataClient::RecvArray1D(char *keyword, Etype **ptr)
00060 {
00061 int handle;
00062 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00063 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00064 if (!isDynamicArray(handle, 1)) return POSSE_FAILURE;
00065
00066 Etype *a;
00067 int n1 = QueryKeyword(keyword);
00068 ALLOC1D(&a, n1);
00069 RemoteSocket::RecvArray1D(a, n1);
00070
00071 *ptr = a;
00072 return POSSE_SUCCESS;
00073 }
00074
00075 template <class Etype>
00076 inline int DataClient::RecvArray2D(char *keyword, Etype **a)
00077 {
00078 int handle;
00079 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00080 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00081 if (!isDynamicArray(handle, 2)) return POSSE_FAILURE;
00082
00083 int n1 = QueryKeyword(keyword);
00084 int n2 = RecvVar<int>();
00085 RemoteSocket::RecvArray2D(a, n1, n2);
00086
00087 return POSSE_SUCCESS;
00088 }
00089
00090 template <class Etype>
00091 inline int DataClient::RecvArray2D(char *keyword, Etype ***ptr)
00092 {
00093 int handle;
00094 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00095 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00096 if (!isDynamicArray(handle, 2)) return POSSE_FAILURE;
00097
00098 Etype **a;
00099 int n1 = QueryKeyword(keyword);
00100 int n2 = RecvVar<int>();
00101 ALLOC2D(&a, n1, n2);
00102 RemoteSocket::RecvArray2D(a, n1, n2);
00103
00104 *ptr = a;
00105 return POSSE_SUCCESS;
00106 }
00107
00108 template <class Etype>
00109 inline int DataClient::RecvArray3D(char *keyword, Etype ***a)
00110 {
00111 int handle;
00112 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00113 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00114 if (!isDynamicArray(handle, 3)) return POSSE_FAILURE;
00115
00116 int n1 = QueryKeyword(keyword);
00117 int n2 = RecvVar<int>();
00118 int n3 = RecvVar<int>();
00119 RemoteSocket::RecvArray3D(a, n1, n2, n3);
00120
00121 return POSSE_SUCCESS;
00122 }
00123
00124 template <class Etype>
00125 inline int DataClient::RecvArray3D(char *keyword, Etype ****ptr)
00126 {
00127 int handle;
00128 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00129 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00130 if (!isDynamicArray(handle, 3)) return POSSE_FAILURE;
00131
00132 Etype ***a;
00133 int n1 = QueryKeyword(keyword);
00134 int n2 = RecvVar<int>();
00135 int n3 = RecvVar<int>();
00136 ALLOC3D(&a, n1, n2, n3);
00137 RemoteSocket::RecvArray3D(a, n1, n2, n3);
00138
00139 *ptr = a;
00140 return POSSE_SUCCESS;
00141 }
00142
00143 template <class Etype>
00144 inline int DataClient::RecvArray4D(char *keyword, Etype ****a)
00145 {
00146 int handle;
00147 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00148 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00149 if (!isDynamicArray(handle, 4)) return POSSE_FAILURE;
00150
00151 int n1 = QueryKeyword(keyword);
00152 int n2 = RecvVar<int>();
00153 int n3 = RecvVar<int>();
00154 int n4 = RecvVar<int>();
00155 RemoteSocket::RecvArray4D(a, n1, n2, n3, n4);
00156
00157 return POSSE_SUCCESS;
00158 }
00159
00160 template <class Etype>
00161 inline int DataClient::RecvArray4D(char *keyword, Etype *****ptr)
00162 {
00163 int handle;
00164 if (!isValidKeyword(keyword, &handle)) return POSSE_FAILURE;
00165 if (!VerifyElementSize(handle, sizeof(Etype))) return POSSE_FAILURE;
00166 if (!isDynamicArray(handle, 4)) return POSSE_FAILURE;
00167
00168 Etype ****a;
00169 int n1 = QueryKeyword(keyword);
00170 int n2 = RecvVar<int>();
00171 int n3 = RecvVar<int>();
00172 int n4 = RecvVar<int>();
00173 ALLOC4D(&a, n1, n2, n3, n4);
00174 RemoteSocket::RecvArray4D(a, n1, n2, n3, n4);
00175
00176 *ptr = a;
00177 return POSSE_SUCCESS;
00178 }
00179
00180 template <class myStruct>
00181 inline double DataClient::RecvStruct(char *keyword, myStruct *S, Semaphore *sem)
00182 {
00183 if (!isValidKeyword(keyword)) return POSSE_FAILURE;
00184 SendKeyword(keyword);
00185 return RemoteSocket::RecvStruct(S, sem);
00186 }
00187
00188 inline int DataClient::RecvFile(char *filename, char *destfile)
00189 {
00190 SendKeyword("internal_ftp");
00191 SendLine(filename);
00192 int status;
00193 if (destfile == NULL)
00194 status = RemoteSocket::RecvFile(filename);
00195 else
00196 status = RemoteSocket::RecvFile(destfile);
00197 return status;
00198 }
00199
00200 #endif // _DATACLIENT_RECV_H_
00201