ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
group.c
Go to the documentation of this file.
1 
11 #include "group.h"
12 #include "protocol.h"
13 #include "debug.h"
14 
15 #define C_authChanId 1
16 
17 /*
18 Receptor *_makeTokenAuthProtocolReceptor() {
19  Receptor *r;
20  r = _r_new(TEST_RECEPTOR);
21  Symbol token_auth = _r_define_symbol(r,PROTOCOL_DEF,"authorizing");
22  Symbol token = _r_define_symbol(r,INTEGER,"token");
23  Symbol authenticator = _r_define_symbol(r,RECEPTOR_ADDRESS,"authenticator");
24  Symbol authenticatee = _r_define_symbol(r,RECEPTOR_ADDRESS,"authenticatee");
25  Symbol verifier = _r_define_symbol(r,RECEPTOR_ADDRESS,"verifier");
26 
27  e1 = {
28  let t = new_token;
29  associate t with authenticatee in scape;
30  return t;}
31  e2 = {
32  if authenticatee associated with token
33  send action to verifier;
34  else return error;
35  }
36  T *t_d = _o_new(r,authenticate,
37  ROLE,authenticator,
38  ROLE,authenticatee,
39  ROLE,verifier,
40  USAGE,token,
41  USAGE,message,
42  CONVERSATION,"bind",
43  authenticator,authenticatee,e1,
44  CONVERSATION,"notarize",
45  authenticatee,authenticator, {
46 
47  }
48  verifier,authenticator, {
49  send message
50  }
51  NULL_SYMBOL
52  );
53 
54  return r;
55 
56 }
57 
58 //Akoff scale:
59 // data-bits/information-structure/knowledge-semantics/wisdom
60 
61 _o_new(r,authoring,"authoring"
62  ROLE,author,
63  ROLE,medium,
64  ROLE,reader,
65  ROLE,editor,
66  USAGE,resource,
67  CONVERSATION "create",
68  medium,author,{store resource;return post id;}
69  CONVERSATION "read",
70  medium,reader,{return resource by id; } // we should also add author and editor to the source list
71  CONVERSATION "update",
72  medium,author,{set resource by id;} // we should also add editor to the source list
73  CONVERSATION "delete",
74  medium,author,{delete resource by id;}
75  )
76 
77 _o_new(r,follow,"follow" //watching tuning-into listening
78  ROLE,channel,
79  ROLE,subscriber_subscriptions_channel, //stand in for scapes
80  ROLE,subscriber,
81  ROLE,poster,
82  USAGE,post,
83 
84  CONVERSATION,"view",
85  channel,subscriber,
86  WRAPPING,requesting,
87  ROLE,subscriber,requester,
88  ROLE,channel,responder,
89  SYMBOL,request,VIEW(from_id,to_id),
90  SYMBOL,response,posts,
91  PROCESS,request_handler,{
92  RESPOND with read from channel posts based on constraints in the VIEW structure
93  }
94  CONVERSATION,"subscribe",
95  channel,subscriber,
96  WRAPPING,requesting,
97  ROLE,subscriber,requester,
98  ROLE,channel,responder,
99  SYMBOL,request,subscribe,
100  SYMBOL,response,subscription_result,
101  PROCESS,request_handler,{
102  create in subscriber_subscriptions_channel (channel_id,message_id=0)
103  }
104  WRAPPING,authoring,
105  RECEPTOR,channel,medium,
106  RECEPTOR,poster,author,
107  RECEPTOR,subscriber,reader,
108  SYMBOL,post,resource,
109  )
110 
111 _o_make_protocol_def(sem,"talk",
112  ROLE,group,
113  ROLE,proxy,
114  ROLE,member,
115  CONVERSATION,"membership",
116  group_addr,member,e_join,
117  CONVERSATION,"subscribe",
118  channel_addr,proxy_addr,e_sub,
119  CONVERSATION,"crud",
120  proxy_addr,member,e_crud,
121  CONVERSATION,"act",
122  member,proxy_addr,e_act,
123  NULL_SYMBOL
124 
125  WRAPPING,follow,
126  RECEPTOR,proxy,subscriber,
127  RECEPTOR,proxy,poster,
128 
129  WRAPPING,authenticate,
130  RECEPTOR,group,authenticator,
131  RECEPTOR,member,authenticatee,
132  RECEPTOR,channel,verifier,
133 
134 );
135 */
136 
137 
138 Receptor *makeGroup(VMHost *v,char *label) {
139  SemTable *sem = v->r->sem;
140  Symbol group = _d_define_receptor(sem,label,__r_make_definitions(),DEV_COMPOSITORY_CONTEXT);
141  Receptor *r = _r_new(sem,group);
142  Xaddr groupx = _v_new_receptor(v,v->r,group,r);
143  _v_activate(v,groupx);
144  //debug_enable(D_PROTOCOL);
145  _o_express_role(r,group1,GROUP,DEFAULT_ASPECT,NULL);
146  debug_disable(D_PROTOCOL);
147  /* Symbol channel_addr = _r_define_symbol(r,RECEPTOR_ADDRESS,"channel"); */
148  /* Symbol member = _r_define_symbol(r,RECEPTOR_ADDRESS,"member"); */
149  /* Symbol group_addr = _r_define_symbol(r,RECEPTOR_ADDRESS,"group"); */
150  /* Symbol proxy_addr = _r_define_symbol(r,RECEPTOR_ADDRESS,"proxy"); */
151  /* // Symbol create = _r_define_symbol(r,NULL_STRUCTURE,"create"); */
152  /* Symbol join = _r_define_symbol(r,NULL_STRUCTURE,"talking join"); */
153  /* Symbol read = _r_define_symbol(r,NULL_STRUCTURE,"talking read"); */
154  /* Symbol post_id = _r_define_symbol(r,INTEGER,"post_id"); */
155 
156  /* T *e_join,*e_sub,*e_crud,*e_act; */
157  /* T *g_d = _o_make_protocol_def(sem,"talking", */
158  /* ROLE,channel_addr, */
159  /* ROLE,group_addr, */
160  /* ROLE,proxy_addr, */
161  /* ROLE,member, */
162  /* CONVERSATION,"membership", */
163  /* group_addr,member,e_join, */
164  /* CONVERSATION,"subscribe", */
165  /* channel_addr,proxy_addr,e_sub, */
166  /* CONVERSATION,"crud", */
167  /* proxy_addr,member,e_crud, */
168  /* CONVERSATION,"act", */
169  /* member,proxy_addr,e_act, */
170  /* NULL_SYMBOL); */
171  /* _r_define_protocol(r,) */
172  /* T *proc = _t_new_root(IF); */
173  /* T *t = _t_newr(proc,SAY); */
174  /* __r_make_addr(t,TO_ADDRESS,C_authChanId); // @todo find the right address value to use by convention for the auth channel */
175  /* _t_news(t,ASPECT_IDENT,DEFAULT_ASPECT); // @todo, generalize to allow groups on different aspects */
176  /* _t_news(t,CARRIER,talking); */
177  /* T *w = _t_newr(t,read); */
178  /* int pt[] = {SignalEnvelopeIdx,EnvelopeFromIdx,TREE_PATH_TERMINATOR}; // the senders address */
179  /* _t_new(w,SIGNAL_REF,pt,sizeof(int)*4); */
180 
181  /* t = _t_newr(proc,RESPOND); */
182  /* _t_news(t,RESPONSE_CARRIER,talking); */
183 
184  // T *e = __r_build_expectation(join,join_stx,join_process,0,0,NULL,NULL);
185 
186 
187  /* group { */
188  /* role { */
189  /* channel; */
190  /* proxy; */
191  /* group; */
192  /* } */
193  /* conversations { */
194  /* membership { */
195  /* group expects join from ! { */
196  /* if (read auth_channel for !) { */
197  /* create token; */
198  /* send to proxy for ! token; */
199  /* respond with token; */
200  /* } */
201  /* else { */
202  /* respond with err; */
203  /* } */
204  /* } */
205  /* } */
206  /* subscribe { */
207  /* channel expects sub from proxy { */
208  /* }*/
209  /* } */
210  /* crud post from proxy to channel (some channels have side-effects); */
211  /* act from ! to proxy; */
212  /* } */
213  /* } */
214 
215 
216 
217 
218  return r;
219 }
220 
group communication receptors header file
SemanticID _d_define_receptor(SemTable *sem, char *label, T *definitions, Context c)
Definition: def.c:457
protocol helpers header file
void _v_activate(VMHost *v, Xaddr x)
Definition: vmhost.c:172
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
Definition: receptor.c:88
Definition: vmhost.h:40
SemTable * sem
pointer back to the genotype table for this receptor's vmhost instance
Definition: ceptr_types.h:242
void _o_express_role(Receptor *r, Protocol protocol, Symbol role, Aspect aspect, T *bindings)
Definition: protocol.c:409
Receptor * r
Receptor data for this vm host.
Definition: vmhost.h:43