TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

tsp_group.c

Go to the documentation of this file.
00001 
00038 #include "tsp_sys_headers.h"
00039 
00040 #include "tsp_group_data.h"
00041 #include "tsp_group.h"
00042 
00043 #include "tsp_data_receiver.h"
00044 
00045 
00046 void TSP_group_delete_group_table(TSP_groups_t groups)
00047 {
00048 
00049    TSP_group_table_t* table = (TSP_group_table_t*)groups;
00050 
00051    STRACE_IO(("-->IN"));
00052    
00053    if(table)
00054      {
00055        free(table->items_table);table->items_table = 0;
00056        free(table->groups);table->groups = 0;
00057        free(table);
00058      }
00059 
00060    STRACE_IO(("-->OUT"));
00061 }
00062 
00063 
00064 TSP_groups_t
00065 TSP_group_create_group_table(const TSP_sample_symbol_info_list_t* symbols, int group_number)
00066 {
00067     
00068   int group_id, old_group_id;
00069   int i;
00070     
00071   TSP_group_table_t* table = 0;
00072   TSP_group_item_t* items_table = 0;
00073 
00074     
00075   STRACE_IO(("-->IN"));
00076 
00077   assert(symbols);
00078     
00079   table = (TSP_group_table_t*)calloc(1, sizeof(TSP_group_table_t));
00080   TSP_CHECK_ALLOC(table, 0);
00081     
00082   /* Get total number of groups */
00083   table->table_len = group_number;
00084     
00085   /*Allocate room for all groups */
00086   table->groups = (TSP_group_t*)calloc(table->table_len, sizeof(TSP_group_t));
00087   TSP_CHECK_ALLOC(table->groups, 0);
00088     
00089     /*Allocate room for all group items*/
00090   table->groups_summed_size = symbols->TSP_sample_symbol_info_list_t_len;
00091   table->items_table = (TSP_group_item_t*)calloc(table->groups_summed_size, sizeof(TSP_group_item_t));
00092   items_table = table->items_table;
00093   TSP_CHECK_ALLOC(items_table, 0);
00094         
00095   /*Initialize groups items*/
00096   /* And make them point at the right place in the item list */
00097   i = 0;
00098   table->max_group_len = 0;
00099   for(group_id = 0; group_id < group_number; group_id++) 
00100     {
00101      
00102       /* Rank for the symbol in a group*/
00103       int rank = 0;
00104      
00105       /* Correct items pointer */
00106       table->groups[group_id].items = items_table;
00107         
00108       while(i < symbols->TSP_sample_symbol_info_list_t_len)
00109         {
00110     
00111           if(group_id == symbols->TSP_sample_symbol_info_list_t_val[i].provider_group_index)
00112             {
00113               
00114               table->groups[group_id].items[rank].provider_global_index = symbols->TSP_sample_symbol_info_list_t_val[i].provider_global_index;
00115 
00116               /* FIXME : en fonction du type, appeler la bonne fonction */
00117               table->groups[group_id].items[rank].data_decoder = TSP_data_receiver_get_double_decoder();
00118               table->groups[group_id].items[rank].sizeof_encoded_item = TSP_data_receiver_get_double_encoded_size();
00119               table->groups[group_id].sizeof_encoded_group += table->groups[group_id].items[rank].sizeof_encoded_item;
00120               
00121               STRACE_DEBUG(("Added to group table Id=%d, Gr=%d, Rank=%d", 
00122                             table->groups[group_id].items[rank].provider_global_index,
00123                             group_id,
00124                             rank));
00125               rank++; 
00126               i++;
00127             }  
00128           else
00129             {
00130               break;
00131             }
00132         
00133             
00134         }
00135       /* set group size */
00136       table->groups[group_id].group_len = rank;
00137 
00138       /* step thrue table */
00139       items_table += rank;
00140       
00141       /* calculate max group size*/
00142       if( table->groups[group_id].group_len > table->max_group_len)
00143         {
00144           table->max_group_len = table->groups[group_id].group_len;
00145         
00146         }
00147 
00148     }
00149             
00150      
00151   STRACE_IO(("-->OUT"));
00152 
00153   return table;
00154 }
00155                                                              
Framework Home Page.

Beware !! TSP wave is coming...