]> rtime.felk.cvut.cz Git - frescor/forb.git/blob - tests-idl/example_server.c
forb_request_send() moved to iop.c
[frescor/forb.git] / tests-idl / example_server.c
1 #include <forb.h>
2 #include "myinterface.h"  /* IDL compiler generated prototypes etc. */
3
4 /* Internal data of our object implementing myinterface */
5 struct example_data {
6         int last_a, last_b;
7 };
8
9 /* Implementation of add method */
10 CORBA_long example_add(myinterface obj, const CORBA_long a,
11                        const CORBA_long b, CORBA_Environment *ev)
12 {
13         struct example_data *ed = forb_instance_data(obj);
14         ed->last_a = a;
15         ed->last_b = b;
16         return a + b;
17 }
18
19 /* Implementation of get_last method */
20 void example_get_last(myinterface obj, CORBA_long* a,
21                       CORBA_long* b, CORBA_Environment *ev)
22 {
23         struct example_data *ed = forb_instance_data(obj);
24         *a = ed->last_a;
25         *b = ed->last_b;
26 }
27
28 /* Table of implemented methods */
29 struct forb_myinterface_impl example_implementation = {
30         .add = example_add,
31         .get_last = example_get_last,
32 };
33
34 int main(int argc, char *argv[])
35 {
36         forb_orb orb;
37         myinterface example;
38         struct example_data example_data;
39         
40         orb = forb_init(&argc, &argv, NULL); /* FORB initialization */
41         /* Cration of an object implementing myinterface */
42         example = forb_myinterface_new(orb, &example_implementation,
43                                        &example_data);
44         /* We can register our object under a name, so that other
45          * processes can use it. */
46         forb_register_reference(example, "example");
47
48         /* Process incomming requests to this object */
49         forb_execute_object(example);
50         
51         return 0;               /* Never returns */
52 }