VISIGENIC


Program 1

fact.idl
interface factory {
void create_obj(in string name);
};

client.cpp

#include <fact_c.hh>
int main(int argc, char * const *argv)
{
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
factory_var fact;
fact = factory::_bind();
fact->create_obj((const char *)"hell");
}

server.cpp

#include <linklist.h>
#include <fact_s.hh>
class Factory: public _sk_factory
{
public:
void create_obj(const char * name) {
cout << "Creating object " << name << endl;
}
};
int main(int argc, char * const *argv)
{
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
CORBA::BOA_ptr boa = orb->BOA_init(argc, argv);
Factory fact;
boa->obj_is_ready(&fact);
boa->impl_is_ready();
}

Program 2
client.cpp

#include "sub_s.hh"
#include "pub_c.hh"
class ccc: public _sk_Subscriber
{
public:
void receive_update() {
cout << "hello\n" << endl;
}
};
int main(int argc, char *const *argv)
{
CORBA_ORB *o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
CORBA_BOA::scope(CORBA_BOA::SCOPE_LOCAL); 
ccc c;
b->obj_is_ready(&c);
Publisher *p = Publisher::_bind();
p->add_subscriber(&c);
b->impl_is_ready();   
return 0;
}

server.cpp
#include <windows.h>
#include "pub_s.hh"
int j;
class sss: public _sk_Publisher
{
public:
Subscriber  *u;
void add_subscriber(Subscriber *s) {
j=1;
u = Subscriber::_duplicate(s);
}
void    publish()
{
if ( j == 1)
u->receive_update();
}
};
int main(int argc, char *const *argv)
{
CORBA_ORB * o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
sss s;
b->obj_is_ready(&s);
for(long i=1;; i++) 
s.publish();
return 0;
}

pub.idl

#include "sub.idl"
interface Publisher
{
void add_subscriber(in Subscriber s);
};

sub.idl
interface Subscriber
{
void receive_update();
};

z.bat
orbeline  -v _c -m _s -c cpp sub.idl
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c sub_c.CPP
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c sub_s.CPP
orbeline  -v _c -m _s -c cpp pub.idl
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c pub_c.CPP
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c client.CPP
CL -DWIN32  /GX  /MT /O2 -o client.exe client.obj sub_s.obj  sub_c.obj pub_c.obj  ..\..\lib\orb_r.lib wsock32.lib kernel32.lib
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c pub_s.CPP
CL -DWIN32  /GX  /MT /O2 -I. -I..\..\include  -c server.CPP
CL -DWIN32  /GX  /MT /O2 -o server.exe server.obj pub_s.obj pub_c.obj sub_s.obj  sub_c.obj  ..\..\lib\orb_r.lib wsock32.lib kernel32.lib


Program 3
receiver.cpp
#include "ttcp_s.hh"
class rrr: public _sk_ttcp
{
public:
void receive()
{
cout << "ttcp::receive called" << endl;
}
};
int main(int argc, char *const *argv)
{
CORBA_ORB *o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
rrr r;
b->obj_is_ready(&r);
b->impl_is_ready();
}
          
sender.cpp
#include <ntutils.h>
#include "ttcp_c.hh"
int main(int argc, char *const *argv)
{
CORBA_ORB *o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
ttcp * obj;
obj = ttcp::_bind();
obj->receive();
}

ttcp.idl
interface ttcp
{
oneway void receive();
}; 

Program 4
receiver.cpp

#include "ttcp_s.hh"
class rrr: public _sk_ttcp
{
public:
void receive()
{
cout << "ttcp::receive called" << endl;
}
};
int main(int argc, char *const *argv)
{
CORBA_ORB *o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
rrr r;
b->obj_is_ready(&r);
b->impl_is_ready();
}
          
sender.cpp
#include <ntutils.h>
#include "ttcp_c.hh"
int main(int argc, char *const *argv)
{
CORBA_ORB *o = CORBA::ORB_init(argc, argv);
CORBA_BOA *b = o->BOA_init(argc, argv);
ttcp * obj;
obj = ttcp::_bind();
obj->receive();
}

evrecv.cpp

#include <pmcext.h>
#include "ttcp_s.hh"
class rrr: public _sk_ttcp, public PMC_EXT::ImplEventHandler
{
public:
void receive() {cout << "hi\n";}
void bind(const PMC_EXT::ConnectionInfo& info, CORBA::Principal_ptr,
CORBA::Object_ptr) {
cout << "Bind request by:" << info << endl;
}
};
int main(int argc, char *const *argv)
{
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
CORBA::BOA_ptr boa = orb->BOA_init(argc, argv);
rrr r;
PMC_EXT::HandlerRegistry *y = PMC_EXT::HandlerRegistry::instance();
y->reg_obj_impl_handler(&r, &r);
boa->obj_is_ready(&r);
boa->impl_is_ready();
}

evsend.cpp
#include <pmcext.h>
#include <ntutils.h>
#include "ttcp_c.hh"
class EventHandler: public PMC_EXT::ClientEventHandler
{
public:
void bind_succeeded(CORBA::Object_ptr, const PMC_EXT::ConnectionInfo& info){
cout << "Bound to the following receiver: " <<  info << endl;
}
};
int main(int argc, char *const *argv)
{
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
CORBA::BOA_ptr boa = orb->BOA_init(argc, argv);
EventHandler handler;
PMC_EXT::HandlerRegistry *y = PMC_EXT::HandlerRegistry::instance();
y->reg_glob_client_handler(&handler);
ttcp *obj;
obj = ttcp::_bind();
obj->receive();
}

ttcp.idl
interface ttcp
{
oneway void receive();
}; 


We will put up the explanations as soon as possible. Please visit us again . If you have any suggestions, comments, ideas, cracked code, feedback, feel free to get in touch with us.

Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.


Vijay Mukhi's Computer Institute
VMCI, B-13, Everest Building, Tardeo, Bombay 400 034, India
E-mail:vmukhi@giasbm01.vsnl.net.in Tel : 91-22-496 4335 /6/7/8/9 Fax : 91-22-307 28 59
http://www.vijaymukhi.com