Changeset 579 for trunk/zoo-project/zoo-kernel/service.h
- Timestamp:
- Feb 12, 2015, 5:01:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service.h
r576 r579 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 60 60 } 61 61 #else 62 /** 63 * The crossplatform strdup alias 64 */ 62 65 #define zStrdup strdup 66 /** 67 * The crossplatform mkdir alias 68 */ 63 69 #define zMkdir mkdir 70 /** 71 * The crossplatform open alias 72 */ 64 73 #define zOpen open 74 /** 75 * The crossplatform write alias 76 */ 65 77 #define zWrite write 78 /** 79 * The crossplatform sleep alias 80 */ 66 81 #define zSleep sleep 82 /** 83 * The crossplatform gettimeofday alias 84 */ 67 85 #define zGettimeofday gettimeofday 86 /** 87 * The crossplatform timeval alias 88 */ 68 89 #define ztimeval timeval 69 90 #endif … … 87 108 #endif 88 109 #ifndef true 110 /** 111 * Local true definition 112 */ 89 113 #define true 1 114 /** 115 * Local false definition 116 */ 90 117 #define false -1 91 118 #endif 92 119 #endif 93 120 121 /** 122 * The global accepted status for a service 123 */ 94 124 #define SERVICE_ACCEPTED 0 125 /** 126 * The global started status for a service 127 */ 95 128 #define SERVICE_STARTED 1 129 /** 130 * The global paused status for a service 131 */ 96 132 #define SERVICE_PAUSED 2 133 /** 134 * The global succeeded status for a service 135 */ 97 136 #define SERVICE_SUCCEEDED 3 137 /** 138 * The global failed status for a service 139 */ 98 140 #define SERVICE_FAILED 4 99 141 142 /** 143 * The memory size to create an elements 144 */ 100 145 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+sizeof(elements*)) 146 /** 147 * The memory size to create a map 148 */ 101 149 #define MAP_SIZE (2*sizeof(char*))+sizeof(NULL) 150 /** 151 * The memory size to create an iotype 152 */ 102 153 #define IOTYPE_SIZE MAP_SIZE+sizeof(NULL) 154 /** 155 * The memory size to create a maps 156 */ 103 157 #define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+MAP_SIZE 158 /** 159 * The memory size to create a service 160 */ 104 161 #define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*) 105 162 … … 116 173 117 174 /** 118 * \struct map 119 * \brief KVP linked list 175 * KVP linked list 120 176 * 121 177 * Deal with WPS KVP (name,value). … … 138 194 139 195 /** 140 * \struct maps 141 * \brief linked list of map pointer 196 * linked list of map pointer 142 197 * 143 198 * Small object to store WPS KVP set. … … 154 209 155 210 /** 156 * \brief Dump a map on stderr 211 * Dump a map on stderr 212 * 213 * @param t the map to dump 157 214 */ 158 215 static void _dumpMap(map* t){ … … 166 223 } 167 224 225 /** 226 * Dump a map on stderr, see _dumpMap() 227 * 228 * @param t the map to dump 229 */ 168 230 static void dumpMap(map* t){ 169 231 map* tmp=t; … … 174 236 } 175 237 238 /** 239 * Dump a map to a file 240 * 241 * @param t the map to dump to file 242 * @param file the file to store the map 243 */ 176 244 static void dumpMapToFile(map* t,FILE* file){ 177 245 map* tmp=t; … … 185 253 } 186 254 255 /** 256 * Dump a maps on stderr, see dumpMap(). 257 * 258 * @param m the map to dump 259 */ 187 260 static void dumpMaps(maps* m){ 188 261 maps* tmp=m; … … 194 267 } 195 268 269 /** 270 * Dump a maps to a file, see dumpMapToFile(). 271 * 272 * @param m the map to dump 273 * @param file_path the full path to the file name to store the map 274 */ 196 275 static void dumpMapsToFile(maps* m,char* file_path){ 197 276 FILE* file=fopen(file_path,"w"); … … 205 284 } 206 285 286 /** 287 * Create a new map 288 * 289 * @param name the key to add to the map 290 * @param value the corresponding value to add to the map 291 * @return the allocated map 292 */ 207 293 static map* createMap(const char* name,const char* value){ 208 294 map* tmp=(map *)malloc(MAP_SIZE); … … 213 299 } 214 300 301 /** 302 * Count number of map in a map 303 * 304 * @param m the maps to count 305 * @return number of map in a map 306 */ 215 307 static int count(map* m){ 216 308 map* tmp=m; … … 223 315 } 224 316 317 /** 318 * Verify if a key exist in a map 319 * 320 * @param m the map to search for the key 321 * @param key the key to search in the map 322 * @return true if the key wwas found, false in other case 323 */ 225 324 static bool hasKey(map* m,const char *key){ 226 325 map* tmp=m; … … 236 335 } 237 336 337 /** 338 * Access a specific maps 339 * 340 * @param m the maps to search for the key 341 * @param key the key to search in the maps 342 * @return a pointer on the maps found or NULL if not found 343 */ 238 344 static maps* getMaps(maps* m,const char *key){ 239 345 maps* tmp=m; … … 247 353 } 248 354 355 /** 356 * Access a specific map 357 * 358 * @param m the map to search for the key 359 * @param key the key to search in the map 360 * @return a pointer on the map found or NULL if not found 361 */ 249 362 static map* getMap(map* m,const char *key){ 250 363 map* tmp=m; … … 259 372 260 373 374 /** 375 * Access the last map 376 * 377 * @param m the map to search for the lastest map 378 * @return a pointer on the lastest map found or NULL if not found 379 */ 261 380 static map* getLastMap(map* m){ 262 381 map* tmp=m; … … 270 389 } 271 390 391 /** 392 * Access a specific map from a maps 393 * 394 * @param m the maps to search for the key 395 * @param key the key to search in the maps 396 * @param subkey the key to search in the map (found for the key, if any) 397 * @return a pointer on the map found or NULL if not found 398 */ 272 399 static map* getMapFromMaps(maps* m,const char* key,const char* subkey){ 273 400 maps* _tmpm=getMaps(m,key); … … 279 406 } 280 407 281 408 /** 409 * Free allocated memory of a map. 410 * Require to call free on mo after calling this function. 411 * 412 * @param mo the map to free 413 */ 282 414 static void freeMap(map** mo){ 283 415 map* _cursor=*mo; … … 295 427 } 296 428 429 /** 430 * Free allocated memory of a maps. 431 * Require to call free on mo after calling this function. 432 * 433 * @param mo the maps to free 434 */ 297 435 static void freeMaps(maps** mo){ 298 436 maps* _cursor=*mo; … … 314 452 315 453 /** 316 * \briefNot named linked list454 * Not named linked list 317 455 * 318 456 * Used to store informations about formats, such as mimeType, encoding ... … … 328 466 329 467 /** 330 * \briefMetadata information about input or output.468 * Metadata information about input or output. 331 469 * 332 470 * The elements are used to store metadata informations defined in the ZCFG. 333 471 * 334 * An elements is defined as 472 * An elements is defined as: 335 473 * - a name, 336 474 * - a content map, … … 351 489 } elements; 352 490 491 /** 492 * Metadata informations about a full Service. 493 * 494 * An element is defined as: 495 * - a name, 496 * - a content map, 497 * - a metadata map, 498 * - an inputs elements 499 * - an outputs elements 500 */ 353 501 typedef struct service{ 354 502 char* name; … … 359 507 } service; 360 508 509 /** 510 * Multiple services chained list. 511 */ 361 512 typedef struct services{ 362 513 struct service* content; … … 364 515 } services; 365 516 517 /** 518 * Verify if an elements contains a name equal to the given key. 519 * 520 * @param e the elements to search for the key 521 * @param key the elements name to search 522 * @return true if the elements contains the name, false in other cases. 523 */ 366 524 static bool hasElement(elements* e,const char* key){ 367 525 elements* tmp=e; … … 374 532 } 375 533 534 /** 535 * Access a specific elements named key. 536 * 537 * @param m the elements to search 538 * @param key the elements name to search 539 * @return a pointer to the specific element if found, NULL in other case. 540 */ 376 541 static elements* getElements(elements* m,char *key){ 377 542 elements* tmp=m; … … 384 549 } 385 550 386 551 /** 552 * Free allocated memory of an iotype. 553 * Require to call free on i after calling this function. 554 * 555 * @param i the iotype to free 556 */ 387 557 static void freeIOType(iotype** i){ 388 558 iotype* _cursor=*i; … … 397 567 } 398 568 569 /** 570 * Free allocated memory of an elements. 571 * Require to call free on e after calling this function. 572 * 573 * @param e the iotype to free 574 */ 399 575 static void freeElements(elements** e){ 400 576 elements* tmp=*e; … … 423 599 } 424 600 601 /** 602 * Free allocated memory of a service. 603 * Require to call free on e after calling this function. 604 * 605 * @param s the service to free 606 */ 425 607 static void freeService(service** s){ 426 608 service* tmp=*s; … … 443 625 } 444 626 627 /** 628 * Add key value pair to an existing map. 629 * 630 * @param m the map to add the KVP 631 * @param n the key to add 632 * @param v the corresponding value to add 633 */ 445 634 static void addToMap(map* m,const char* n,const char* v){ 446 635 if(hasKey(m,n)==false){ … … 459 648 } 460 649 650 /** 651 * Add a key and a binary value to an existing map. 652 * 653 * @param m the map to add the KVP 654 * @param n the key to add 655 * @param v the corresponding value to add 656 * @param size the size of the given value 657 */ 461 658 static void addToMapWithSize(map* m,const char* n,const char* v,int size){ 462 659 if(hasKey(m,n)==false){ … … 479 676 } 480 677 678 /** 679 * Add a map at the end of another map. 680 * 681 * @param mo the map to add mi 682 * @param mi the map to add to mo 683 */ 481 684 static void addMapToMap(map** mo,map* mi){ 482 685 map* tmp=mi; … … 511 714 } 512 715 716 /** 717 * Add a map to iotype. 718 * 719 * @param io the iotype to add the map 720 * @param mi the map to add to io 721 */ 513 722 static void addMapToIoType(iotype** io,map* mi){ 514 723 iotype* tmp=*io; … … 522 731 } 523 732 733 /** 734 * Access a specific map or set its value. 735 * 736 * @param m the map to search for the key 737 * @param key the key to search/add in the map 738 * @param value the value to add if the key does not exist 739 * @return a pointer on the map found or NULL if not found 740 */ 524 741 static map* getMapOrFill(map** m,const char *key,const char* value){ 525 742 map* tmp=*m; … … 536 753 } 537 754 755 /** 756 * Verify if a map is contained in another map. 757 * 758 * @param m the map to search for i 759 * @param i the map to search in m 760 * @return true if i was found in m, false in other case 761 */ 538 762 static bool contains(map* m,map* i){ 539 763 while(i!=NULL){ … … 552 776 } 553 777 778 /** 779 * Access a specific iotype from an elements. 780 * 781 * @param e the elements to search for the name 782 * @param name the name to search in the elements e 783 * @param values the map to verify it was contained in the defaults or 784 * supported content of the elements e 785 * @return a pointer on the iotype found or NULL if not found 786 */ 554 787 static iotype* getIoTypeFromElement(elements* e,char *name, map* values){ 555 788 elements* cursor=e; … … 572 805 } 573 806 807 /** 808 * Load binary values from a map (in) and add them to another map (out) 809 * 810 * @param out the map to add binaries values 811 * @param in the map containing the binary values to add ti out 812 * @param pos index of the binary in an array (in case of "MapArray") 813 */ 574 814 static void loadMapBinary(map** out,map* in,int pos){ 575 815 map* size=getMap(in,"size"); … … 598 838 } 599 839 840 /** 841 * Load binary values from a map (in) and add them to another map (out). 842 * This function will take care of MapArray. 843 * @see loadMapBinary 844 * 845 * @param out the map to add binaries values 846 * @param in the map containing the binary values to add ti out 847 */ 600 848 static void loadMapBinaries(map** out,map* in){ 601 849 map* size=getMap(in,"size"); … … 613 861 } 614 862 863 /** 864 * Duplicate a Maps 865 * 866 * @param mo the maps to clone 867 * @return the allocated maps containing a copy of the mo maps 868 */ 615 869 static maps* dupMaps(maps** mo){ 616 870 maps* _cursor=*mo; … … 631 885 } 632 886 887 /** 888 * Add a maps at the end of another maps. 889 * 890 * @see addMapToMap, dupMaps, getMaps 891 * @param mo the maps to add mi 892 * @param mi the maps to add to mo 893 */ 633 894 static void addMapsToMaps(maps** mo,maps* mi){ 634 895 maps* tmp=mi; … … 652 913 } 653 914 915 /** 916 * Access a specific map array element 917 * 918 * @param m the map to search for the key 919 * @param key the key to search in the map 920 * @param index of the MapArray 921 * @return a pointer on the map found or NULL if not found 922 */ 654 923 static map* getMapArray(map* m,const char* key,int index){ 655 924 char tmp[1024]; … … 670 939 671 940 941 /** 942 * Add a key value in a MapArray for a specific index 943 * 944 * @param m the map to search for the key 945 * @param key the key to search in the map 946 * @param index the index of the MapArray 947 * @param value the value to set in the MapArray 948 * @return a pointer on the map found or NULL if not found 949 */ 672 950 static void setMapArray(map* m,const char* key,int index,const char* value){ 673 951 char tmp[1024]; … … 697 975 } 698 976 977 /** 978 * Access the map "type" 979 * 980 * @param mt the map 981 * @return a pointer on the map for mimeType/dataType/CRS if found, NULL in 982 * other case 983 */ 699 984 static map* getMapType(map* mt){ 700 985 map* tmap=getMap(mt,(char *)"mimeType"); … … 711 996 } 712 997 998 /** 999 * Add a Maps containing a MapArray to a Maps 1000 * 1001 * @see getMapType 1002 * @param mo the maps 1003 * @param mi the maps 1004 * @param typ the map "type" 1005 * @return 1006 */ 713 1007 static int addMapsArrayToMaps(maps** mo,maps* mi,char* typ){ 714 1008 maps* tmp=mi; … … 759 1053 } 760 1054 1055 /** 1056 * Set a key value pair to a map contained in a Maps 1057 * 1058 * @param m the maps 1059 * @param key the maps name 1060 * @param subkey the map name included in the maps corresponding to key 1061 * @param value the corresponding value to add in the map 1062 */ 761 1063 static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){ 762 1064 maps* _tmpm=getMaps(m,key); … … 787 1089 } 788 1090 789 1091 /** 1092 * Dump an elements on stderr 1093 * 1094 * @param e the elements to dump 1095 */ 790 1096 static void dumpElements(elements* e){ 791 1097 elements* tmp=e; … … 818 1124 } 819 1125 1126 /** 1127 * Dump an elements on stderr using the YAML syntaxe 1128 * 1129 * @param e the elements to dump 1130 */ 820 1131 static void dumpElementsAsYAML(elements* e){ 821 1132 elements* tmp=e; … … 889 1200 } 890 1201 891 1202 /** 1203 * Duplicate an elements 1204 * 1205 * @param e the elements to clone 1206 * @return the allocated elements containing a copy of the elements e 1207 */ 892 1208 static elements* dupElements(elements* e){ 893 1209 elements* cursor=e; … … 939 1255 } 940 1256 1257 /** 1258 * Add an elements to another elements. 1259 * 1260 * @see dupElements 1261 * @param m the elements to add the e 1262 * @param e the elements to be added to m 1263 */ 941 1264 static void addToElements(elements** m,elements* e){ 942 1265 elements* tmp=e; … … 948 1271 } 949 1272 1273 /** 1274 * Dump a service on stderr 1275 * 1276 * @param s the service to dump 1277 */ 950 1278 static void dumpService(service* s){ 951 1279 fprintf(stderr,"++++++++++++++++++\nSERVICE [%s]\n++++++++++++++++++\n",s->name); … … 967 1295 } 968 1296 1297 /** 1298 * Dump a service on stderr using the YAML syntaxe 1299 * 1300 * @param s the service to dump 1301 */ 969 1302 static void dumpServiceAsYAML(service* s){ 970 1303 int i; … … 994 1327 } 995 1328 1329 /** 1330 * Convert a maps to a char*** (only used for Fortran support) 1331 * 1332 * @param m the maps to convert 1333 * @param c the resulting array 1334 */ 996 1335 static void mapsToCharXXX(maps* m,char*** c){ 997 1336 maps* tm=m; … … 1024 1363 } 1025 1364 1365 /** 1366 * Convert a char*** to a maps (only used for Fortran support) 1367 * 1368 * @param c the array to convert 1369 * @param m the resulting maps 1370 */ 1026 1371 static void charxxxToMaps(char*** c,maps**m){ 1027 1372 maps* trorf=*m;
Note: See TracChangeset
for help on using the changeset viewer.