]> rtime.felk.cvut.cz Git - frescor/frsh.git/blob - fres/contract/fres_contract.h
Modieief frsh_forb/frsh_api/Makefile.omk
[frescor/frsh.git] / fres / contract / fres_contract.h
1 #ifndef FRES_CONTRACT_H
2 #define FRES_CONTRACT_H
3
4 #include <fres_blocks.h>
5 #include <fres_container.h>
6 #include <ul_gavl.h>
7 #include <fres_contract_type.h>
8 #include <fres_contract_idl.h>
9 #include <forb/server_id.h>
10
11 struct fres_contract {
12         fres_contract_id_t id;
13         struct fres_container *container;       /**< Pointer to the container (opaque type). */
14 };
15
16 static inline int fres_contract_id_cmp(const fres_contract_id_t *a,
17                                        const fres_contract_id_t *b)
18 {
19         return forb_server_id_cmp((forb_server_id*)a,
20                                   (forb_server_id*)b);
21 }
22
23 struct fres_contract *fres_contract_new(void);
24 void fres_contract_destroy(struct fres_contract *contract);
25 struct fres_contract *fres_contract_duplicate(struct fres_contract *src);
26
27 #define FRES_CONTRACT_ACCESSOR(type)                                    \
28         static inline int                                               \
29         fres_contract_add_##type(struct fres_contract *contract,        \
30                                  fres_block_##type *block)              \
31         {                                                               \
32                 return fres_container_add_##type(contract->container,   \
33                                                  block);                \
34         }                                                               \
35         static inline fres_block_##type *                               \
36         fres_contract_get_##type(struct fres_contract *contract)        \
37         {                                                               \
38                 return fres_container_get_##type(contract->container);  \
39         }                                                               \
40         static inline void                                              \
41         fres_contract_del_##type(struct fres_contract *contract)        \
42         {                                                               \
43                 fres_container_del_##type(contract->container);         \
44         }
45
46 FRES_CONTRACT_ACCESSOR(label)
47 FRES_CONTRACT_ACCESSOR(resource)
48 FRES_CONTRACT_ACCESSOR(basic)
49 FRES_CONTRACT_ACCESSOR(timing_reqs)
50 FRES_CONTRACT_ACCESSOR(spare_capacity)
51
52 #endif