GCS  0.2.3
gcs_comp_msg.h
1 /*
2  * Copyright (C) 2008-2013 Codership Oy <info@codership.com>
3  *
4  * $Id: gcs_comp_msg.h 3259 2013-09-01 22:35:30Z alex $
5  */
6 /*
7  * Interface to component messages
8  *
9  */
10 
11 #ifndef _gcs_component_h_
12 #define _gcs_component_h_
13 
14 #include <string.h>
15 #include <stdbool.h>
16 
17 // should accommodate human readable UUID (without trailing \0)
18 #define GCS_COMP_MEMB_ID_MAX_LEN GU_UUID_STR_LEN
19 
21 typedef uint8_t gcs_segment_t;
22 
23 typedef struct gcs_comp_memb
24 {
25  char id[GCS_COMP_MEMB_ID_MAX_LEN + 1];
26  gcs_segment_t segment;
27 }
29 
30 #ifdef GCS_COMP_MSG_ACCESS
31 typedef struct gcs_comp_msg
32 {
33  int my_idx;
34  int memb_num;
35  bool primary;
36  bool bootstrap;
37  gcs_comp_memb_t memb[1];
38 }
39 gcs_comp_msg_t;
40 
41 #else
42 typedef struct gcs_comp_msg gcs_comp_msg_t;
43 #endif
44 
52 extern gcs_comp_msg_t*
53 gcs_comp_msg_new (bool prim, bool bootstrap, int my_idx, int memb_num);
54 
56 extern gcs_comp_msg_t*
57 gcs_comp_msg_leave ();
58 
60 extern void
61 gcs_comp_msg_delete (gcs_comp_msg_t* comp);
62 
68 extern int
69 gcs_comp_msg_add (gcs_comp_msg_t* comp, const char* id,
70  gcs_segment_t segment);
71 
73 extern int
74 gcs_comp_msg_size (const gcs_comp_msg_t* comp);
75 
77 extern gcs_comp_msg_t*
78 gcs_comp_msg_copy (const gcs_comp_msg_t* comp);
79 
81 extern const gcs_comp_memb_t*
82 gcs_comp_msg_member (const gcs_comp_msg_t* comp, int idx);
83 
85 extern int
86 gcs_comp_msg_idx (const gcs_comp_msg_t* comp, const char* id);
87 
89 extern bool
90 gcs_comp_msg_primary (const gcs_comp_msg_t* comp);
91 
93 extern bool
94 gcs_comp_msg_bootstrap(const gcs_comp_msg_t* comp);
95 
97 extern int
98 gcs_comp_msg_self (const gcs_comp_msg_t* comp);
99 
101 extern int
102 gcs_comp_msg_num (const gcs_comp_msg_t* comp);
103 
104 #endif /* _gcs_component_h_ */
gcs_segment_t segment
ID assigned by the backend.
Definition: gcs_comp_msg.h:26
Definition: gcs_comp_msg.h:23