00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <string.h>
00022 #include "flgrCoreErrors.h"
00023 #include "flgrCoreTypes.h"
00024 #include "flgrCoreDispatch.h"
00025
00026
00032
00033
00037
00038 FLGR_Ret flgr_is_vector_type_valid(FLGR_Type type) {
00039
00040
00041 if(type==FLGR_UINT8) {
00042 return FLGR_RET_OK;
00043 }else if(type==FLGR_UINT16) {
00044 return FLGR_RET_OK;
00045 }else if(type==FLGR_UINT32) {
00046 return FLGR_RET_OK;
00047 }else if(type==FLGR_UINT64) {
00048 return FLGR_RET_OK;
00049 }else if(type==FLGR_INT8) {
00050 return FLGR_RET_OK;
00051 }else if(type==FLGR_INT16) {
00052 return FLGR_RET_OK;
00053 }else if(type==FLGR_INT32) {
00054 return FLGR_RET_OK;
00055 }else if(type==FLGR_INT64) {
00056 return FLGR_RET_OK;
00057 }else if(type==FLGR_FLOAT32) {
00058 return FLGR_RET_OK;
00059 }else if(type==FLGR_FLOAT64) {
00060 return FLGR_RET_OK;
00061 }else if(type==FLGR_BIT) {
00062 return FLGR_RET_OK;
00063 }else return FLGR_RET_TYPE_UNKNOWN;
00064 }
00065
00067
00071
00072 FLGR_Ret flgr_is_data_type_valid(FLGR_Type type) {
00073
00074
00075 if(type==FLGR_UINT8) {
00076 return FLGR_RET_OK;
00077 }else if(type==FLGR_UINT16) {
00078 return FLGR_RET_OK;
00079 }else if(type==FLGR_UINT32) {
00080 return FLGR_RET_OK;
00081 }else if(type==FLGR_INT8) {
00082 return FLGR_RET_OK;
00083 }else if(type==FLGR_INT16) {
00084 return FLGR_RET_OK;
00085 }else if(type==FLGR_INT32) {
00086 return FLGR_RET_OK;
00087 }else if(type==FLGR_FLOAT32) {
00088 return FLGR_RET_OK;
00089 }else if(type==FLGR_FLOAT64) {
00090 return FLGR_RET_OK;
00091 }else if(type==FLGR_BIT) {
00092 return FLGR_RET_OK;
00093 }else return FLGR_RET_TYPE_UNKNOWN;
00094 }
00095
00097
00101
00102 int flgr_get_bps_from_type(FLGR_Type type) {
00103
00104
00105 switch(type) {
00106 case FLGR_BIT : return 1;
00107 case FLGR_UINT8 : return (sizeof(fgUINT8))<<3;
00108 case FLGR_UINT16 : return (sizeof(fgUINT16))<<3;
00109 case FLGR_UINT32 : return (sizeof(fgUINT32))<<3;
00110 case FLGR_UINT64 : return (sizeof(fgUINT64))<<3;
00111 case FLGR_INT8 : return (sizeof(fgINT8))<<3;
00112 case FLGR_INT16 : return (sizeof(fgINT16))<<3;
00113 case FLGR_INT32 : return (sizeof(fgINT32))<<3;
00114 case FLGR_INT64 : return (sizeof(fgINT64))<<3;
00115 case FLGR_FLOAT32 : return (sizeof(fgFLOAT32))<<3;
00116 case FLGR_FLOAT64 : return (sizeof(fgFLOAT64))<<3;
00117 default:
00118 return FLGR_RET_TYPE_UNKNOWN;
00119 }
00120
00121 }
00122
00124
00128
00129 int flgr_get_sizeof(FLGR_Type type) {
00130
00131
00132 switch(type) {
00133 case FLGR_BIT : return sizeof(fgBIT);
00134 case FLGR_UINT8 : return sizeof(fgUINT8);
00135 case FLGR_UINT16 : return sizeof(fgUINT16);
00136 case FLGR_UINT32 : return sizeof(fgUINT32);
00137 case FLGR_UINT64 : return sizeof(fgUINT64);
00138 case FLGR_INT8 : return sizeof(fgINT8);
00139 case FLGR_INT16 : return sizeof(fgINT16);
00140 case FLGR_INT32 : return sizeof(fgINT32);
00141 case FLGR_INT64 : return sizeof(fgINT64);
00142 case FLGR_FLOAT32 : return sizeof(fgFLOAT32);
00143 case FLGR_FLOAT64 : return sizeof(fgFLOAT64);
00144 default:
00145 return FLGR_RET_TYPE_UNKNOWN;
00146 }
00147 }
00148
00150
00154
00155 char *flgr_get_type_string(FLGR_Type type) {
00156
00157
00158 switch(type) {
00159 case FLGR_BIT : return "fgBIT";
00160 case FLGR_UINT8 : return "fgUINT8";
00161 case FLGR_UINT16 : return "fgUINT16";
00162 case FLGR_UINT32 : return "fgINT32";
00163 case FLGR_UINT64 : return "fgINT64";
00164 case FLGR_INT8 : return "fgINT8";
00165 case FLGR_INT16 : return "fgINT16";
00166 case FLGR_INT32 : return "fgINT32";
00167 case FLGR_INT64 : return "fgINT64";
00168 case FLGR_FLOAT32 : return "fgFLOAT32";
00169 case FLGR_FLOAT64 : return "fgFLOAT64";
00170 default:
00171 return "UNKNOWN_TYPE";
00172 }
00173 }
00174
00176
00180
00181 char *flgr_get_shape_string(FLGR_Shape shape) {
00182
00183
00184 switch(shape) {
00185 case FLGR_LINE : return "LINE";
00186 case FLGR_RECT : return "RECT";
00187 case FLGR_HEX : return "HEX";
00188 case FLGR_DISC : return "DISC";
00189 case FLGR_CROSS : return "CROSS";
00190 case FLGR_CROSSX : return "CROSSX";
00191 case FLGR_SLASH : return "SLASH";
00192 case FLGR_BSLASH : return "BSLASH";
00193 case FLGR_DIAMOND : return "DIAMOND";
00194 case FLGR_OCTAGON : return "OCTAGON";
00195 case FLGR_USER_SHAPE : return "USER_SHAPE";
00196 case FLGR_NO_SHAPE : return "NO_SHAPE";
00197 default:
00198 return "UNKNOWN_SHAPE";
00199 }
00200 }
00201
00203
00207
00208 FLGR_Type flgr_get_type_from_string(char *type) {
00209
00210
00211 if(strcmp(type,"fgBIT")==0) return FLGR_BIT;
00212 if(strcmp(type,"fgUINT8")==0) return FLGR_UINT8;
00213 if(strcmp(type,"fgUINT16")==0) return FLGR_UINT16;
00214 if(strcmp(type,"fgUINT32")==0) return FLGR_UINT32;
00215 if(strcmp(type,"fgUINT64")==0) return FLGR_UINT64;
00216 if(strcmp(type,"fgINT8")==0) return FLGR_INT8;
00217 if(strcmp(type,"fgINT16")==0) return FLGR_INT16;
00218 if(strcmp(type,"fgINT32")==0) return FLGR_INT32;
00219 if(strcmp(type,"fgINT64")==0) return FLGR_INT64;
00220 if(strcmp(type,"fgFLOAT32")==0) return FLGR_FLOAT32;
00221 if(strcmp(type,"fgFLOAT64")==0) return FLGR_FLOAT64;
00222
00223 POST_ERROR("Unknown type %s\n",type);
00224 return FLGR_UINT8;
00225 }
00226
00227
00228
00229