Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00016 #include "CollisionDetector_impl.h"
00017
00018 #ifdef _WIN32
00019 #include "winbase.h"
00020 #else
00021 #include <unistd.h>
00022 #endif
00023
00024 #include <iostream>
00025
00026 using namespace std;
00027
00035 int main(int argc, char* argv[]) {
00036 CORBA::ORB_var orb;
00037 try {
00038 orb = CORBA::ORB_init(argc, argv);
00039
00040
00041
00042 CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
00043 PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);
00044
00045
00046
00047
00048 PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
00049
00050
00051 CORBA_Object_var ns;
00052 try {
00053 ns = orb -> resolve_initial_references("NameService");
00054 } catch (const CORBA_ORB::InvalidName&) {
00055 cerr << argv[0] << ": can't resolve `NameService'" << endl;
00056 return 1;
00057 }
00058 if(CORBA_is_nil(ns)) {
00059 cerr << argv[0]
00060 << ": `NameService' is a nil object reference"
00061 << endl;
00062 return 1;
00063 }
00064
00065
00066 CosNaming_NamingContext_var rootnc = CosNaming_NamingContext::_narrow(ns);
00067 if(CORBA_is_nil(rootnc)) {
00068 cerr << argv[0]
00069 << ": `NameService' is not a NamingContext object reference"
00070 << endl;
00071 return 1;
00072 }
00073
00074 CORBA_Object_var cdFactory;
00075 CollisionDetectorFactory_impl* cdFactoryImpl = new CollisionDetectorFactory_impl(orb);
00076 cdFactory = cdFactoryImpl -> _this();
00077 CosNaming_Name nc;
00078 nc.length(1);
00079 nc[0].id = CORBA_string_dup("CollisionDetectorFactory");
00080 nc[0].kind = CORBA_string_dup("");
00081 rootnc -> rebind(nc, cdFactory);
00082
00083
00084 manager -> activate();
00085 cout << "ready" << endl;
00086
00087 orb -> run();
00088 } catch (CORBA_SystemException& ex) {
00089 cerr << ex._rep_id() << endl;
00090 orb->destroy();
00091 return 1;
00092 }
00093 orb->destroy();
00094 return 0;
00095 }