]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - fwp/lib/mngt/fwp_contract_table.h
7b58d5552bff735a77a90523ae6091d699cbf6d7
[frescor/fwp.git] / fwp / lib / mngt / fwp_contract_table.h
1 #ifndef _FWP_CONTRACT_TABLE_H
2 #define _FWP_CONTRACT_TABLE_H
3
4 #include "fwp_contract.h"
5 #include "fwp_vres.h"
6
7 #include "ul_list.h"
8 #include "ul_gavl.h"
9 #include "ul_gavlcust.h"
10
11 #include <string.h>
12
13 /**
14  * FWP vres parameters 
15  * It is internal representation of the contract used inside 
16  * protocol.
17  * 
18  */
19 typedef 
20 struct fwp_contract_data {
21         fwp_contract_id_t               id;     
22         /**< contract specified by user */
23         fwp_contract_t                  contract;
24         /**< parameters from contract negotiated for vres */
25         fwp_vres_params_t               vres_params;
26         /**< the address of agent from that the contract comes */
27         /*fwp_transaction_id_t          trans_id;*/     
28         /* pointer to fwp_vres or fwp_participant */
29         /*void                          *priv; */
30         fwp_vres_d_t                    vresd;
31         fwp_contract_status_t           status;
32
33         ul_list_node_t                  list_node;
34         gavl_node_t                     tree_node;      
35 } fwp_contract_data_t;
36
37 /**
38  * List of contract_data structures
39  *
40  */
41 typedef
42 struct fwp_contract_list {
43         ul_list_head_t                  head;
44 } fwp_contract_list_t;
45
46 UL_LIST_CUST_DEC(fwp_contract_list, fwp_contract_list_t, fwp_contract_data_t,
47                 head, list_node);
48
49 /**
50  * Table of contract_data structures
51  *
52  */
53 typedef 
54 struct fwp_contract_table {
55         unsigned int                    nr_contracts;
56         pthread_mutex_t                 lock;
57         /*gavl_cust_root_field_t        contract_tree;*/
58         unsigned int                    id_counter;
59         /*ul_list_head_t                cont_list;*/
60         gavl_node_t                     *contract_tree;
61 } fwp_contract_table_t;
62
63
64 void fwp_contract_table_init(fwp_contract_table_t *tbl);
65 int fwp_contract_table_insert(fwp_contract_table_t *tbl, 
66                               fwp_contract_data_t *contdata);
67 fwp_contract_data_t* 
68 fwp_contract_table_find(fwp_contract_table_t *tbl, unsigned int id);
69
70 int fwp_contract_table_delete(fwp_contract_table_t *tbl,
71                           fwp_contract_data_t *contdata);
72
73 #endif /* _FWP_CONTRACT_TABLE_H */