CORBA::ORB �ӿ�

��������ǰ���������д��������У��ڳ���Ŀ�ͷ���������������� 2 �� 3 �У�

/* ����������Ŀ������һЩ���� */
/* ����, obj ������һ����ʵ�Ķ��� */
    

����������ʵ�Ĵ���������ǵ�ʱ���ˡ�������������ħ���� ORB ����������Щħ�������ֿܲ⡣

module CORBA {

typedef string ORBid;
typedef sequence <string> arg_list;
ORB ORB_init (inout arg_list argv, in  ORBid orb_identifier);

interface ORB {
        string object_to_string (in Object obj);
        Object string_to_object (in string str);
};
};

��ʼ��

����Ҫ��������֮һ�dz�ʼ�� ORB�� CORBA_ORB_init �������������κ����������������á����ж���һ���� ORB �������еĻ����� ORBit �IJ�������Ψһ�ı�ʶһ�� ORB�����ǽ�ʹ�õ��� "orbit-local-orb"������ַ����ض���ÿ�� ORB ʵ�֡��ٸ����ӣ�������ʾ���ʹ�����������

#include <orb/orbit.h>

int main (int argc, char **argv) 
{
        CORBA_Object orb;
        CORBA_Environment ev;

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

};
      

���ǣ������Ե����Dz��ܹ����ģ�ԭ���� ev ������û�г�ʼ������Ҫ�� CORBA_exception_init(CORBA_Environment *ev) ��������ʼ������������ض��� C ӳ�䡣���ڱ��º�ͷ�����⴦�����ֽ��͡��ܵ���˵����һϵ�е�������ȫ��ħ����һֱ������������û�ж������ò��Ҳ��ܴ��κνӿڵ��÷���������Ǵ��ڲ���Ҫ�κζ�������� CORBA_ORB_init ������ԭ�����ǡ����� ORB ��һ������(bootstrap)��������

�������ô��л�: IOR �ַ���

һ�� ORB ����ʼ���ˣ����ǽ�Ҫ�õ����ǵĶ����������������ķ�����Ϊ�ˣ��п���ʹ���ڵ�3���н��ܵ� CORBA ��������CORBA ���������ÿ��ע��Ķ�������(associate)��һ���ɱ����Ķ����ַ�����������һ�����򵥵Ļ���: IOR �ַ���(�Ҳ��ŷ� IOR �ַ����Ǽ򵥵ģ���... �����Ǹ������ġ��϶�����һЩ����)��

����д����������ʱ��������� ORB ��ע������������� ORB ���������ڿͻ���ʹ�õĶ������á�����������ð������ʶ�������Ҫ��������Ϣ������λ�ã��ȵ�...  ORB �ṩһ�֡����л�����Щ�������õķ�ʽ�����ַ�ʽ�ǣ�����������ķ�������ʱ�������� ORB ע��������ORB �����ظ�����һ����Ч�Ķ������ã����������԰ѱ����л���������������һ���ļ��У��ͻ����Դ�����ļ��������ûض������á�

����ͨ��ʹ������ CORBA::ORB ������ɵã�object_to_string �� string_to_object������������ object_to_string���ͻ�����  string_to_object����Щ�ַ������� IOR �ַ����������ǵĽṹ��������ʹ�õ�Э�顢���������.... ����ͨ���dz���(һ�ٶ���ַ�)��

������һ�����ɴ��л��ļ��ļ򵥵ķ��������룺

#include <orb/orbit.h>

int main (int argc, char **argv) 
{
        CORBA_ORB orb;
        CORBA_Environment ev;
        CORBA_Object obj;
        FILE *file;

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

        /* ע�᲻ͬ�ķ����Ĵ��� */
        /* �������Ľ���ǵõ�һ�� CORBA_Object��  
         * obj, ����������� */

        if (!file = fopen ("object.ior", "w")) {
                fprintf (stderr, "error: could not open serializing file\n);
                exit (1);
        }

        fprintf (file, "%s", CORBA_ORB_object_to_string (orb, obj, &ev));

        fclose (file);

        return 0;
}

�����ǿͻ������е�����̣�

int main (int argc, char **argv) 
{
        CORBA_ORB orb;
        CORBA_Environment ev;
        CORBA_Object obj;
        FILE *file;
        /* һ���dz������ַ���: �������������е���Ҫ :) */
        char buffer[10000]; 
        char *ior;

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

        if (!file = fopen ("object.ior", "r")) {
                fprintf (stderr, "error: could not open serializing file\n);
                exit (1);
        }

        fgets (buffer, 10000, file);
        ior = g_strdup (buffer); /* �õ�ԭʼ���ַ��� */

        /* ����, ��������ӵ������ !! */
        obj = CORBA_ORB_string_to_object (orb, ior, &ev);
        /* ����, ����ʹ���������������������һЩ������
         */
        fclose (file);

        return 0;
}

����������Եļٶ��ͻ��ͷ���������ͬһ̨������ͬһ��Ŀ¼�������ġ����ǽ����Ժ�������ͬ��������򽻵��������Ͳ����漰 IOR �ַ����ˡ�