Any better example?



Hello all,

I have taken the interesting path of first playing around with Corba
with the ORBit-bindings to Ruby and Perl, giving me small and simple
applications. Then, because of third-party software dependecies, I
had to do a little Corba in Java (and I still haven't got ORBit-
clients to be able to communicate flawlessly with Java-servers even
as the opposite works, but that is another thread). Finally, I have
had to fiddle with it in C, in order to be able to instruct a 
colleague, who need to use C for some visualisation software. Looking 
back, I kind of wish I had travelled in the other direction. It would 
have been more enjoyable, since I then would have discovered simpler
and simpler interfaces all the time, instead of more and more complex 
ones. ;-)

That said, I am thinking about trying to summarize my experiences on
the web, with a simple idl realised with clients and servers in all 
languges. However, I have a question regarding ORBit-servers in C:
do one really need to generate the *-skelimpl.c, alter it to contain
the object functionality, and then include it in the top-level
server source? I do not like that at all, the same way I do not like
the CORBA-methods in Perl that begin with an underscore.

I include my current C-versions below, save the altered row

  retval = "Insert your string here" 

in MyObject-skelimpl.c. Feel free to suggest improvments and
simplifications to them.

Best Regards /Selander
-- 
Anders Selander   Centre for Parallel Computers   selander@pdc.kth.se
Programmer        Royal Institute of Technology   +46 (0)8  790 72 11
                  SE-100 44  STOCKHOLM, SWEDEN    +46 (0)70 266 29 67
module my_module {

	interface MyObject {

		string name();
	};
};
/*
 * OK, a simple C CORBA-sercer.
 * Selander <selander@pdc.kth.se>
 * Tue Apr 16 16:27:10 CEST 2002
 */

#include <stdio.h>

#include "MyObject-skelimpl.c"

int main(int argc, char **argv)
{
        CORBA_ORB                 orb;
        CORBA_Environment         ev;
        PortableServer_POA        root_poa;
        my_module_MyObject        myobject;
        CORBA_char                *objref;
        PortableServer_POAManager pm;

        CORBA_exception_init(&ev);

        orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

        root_poa = (PortableServer_POA)
            CORBA_ORB_resolve_initial_references(orb, "RootPOA", &ev);

        myobject = impl_my_module_MyObject__create(root_poa, &ev);

        objref = CORBA_ORB_object_to_string(orb, myobject, &ev);

        fprintf(stderr, "%s\n", objref);

        pm = PortableServer_POA__get_the_POAManager(root_poa, &ev);

        PortableServer_POAManager_activate(pm, &ev);

        CORBA_ORB_run(orb, &ev);

        exit(0);
}
/*
 * OK, let's build a C ORBit client.
 * Selander <selander@pdc.kth.se>
 * Wed Apr 10 11:07:46 CEST 2002
 */

#include <orbit-1.0/orb/orbit.h>
#include <stdio.h>
#include "MyObject.h"

int main(int argc, char **argv)
{
        CORBA_Environment ev;
        CORBA_ORB         orb;
        my_module_MyObject MyObject_client;

        CORBA_exception_init(&ev);
        orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

        MyObject_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);

        if (!MyObject_client) {

                printf("Cannot bind to %s\n", argv[1]);

                return 1;
        }

        fprintf(stdout,"Name is %s\n", 
                my_module_MyObject_name(MyObject_client, &ev));

        CORBA_Object_release(MyObject_client, &ev);
        CORBA_Object_release((CORBA_Object)orb, &ev);

        exit(0);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]