1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
\r
5 <meta http-equiv="Content-Type"
\r
6 content="text/html; charset=iso-8859-1">
\r
8 <meta name="GENERATOR"
\r
9 content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">
\r
10 <title>Main Page</title>
\r
12 <link href="doxygen.css" rel="stylesheet" type="text/css">
\r
20 <td><a href="http://www.opencascade.com"><img
\r
21 src="sources/logocorp.gif" border="0" height="46" width="122">
\r
24 <div align="right"><a href="http://www.opencascade.org/SALOME/"><img
\r
25 src="sources/application.gif" border="0" height="46" width="108">
\r
34 <h1><a name="page2">Examples</a> </h1>
\r
35 <font color="#3333ff">//There is a CXX example of LifeCycleCORBA using<br>
\r
37 #include CORBA_CLIENT_HEADER(TestComponent)<br>
\r
38 #include "SALOME_NamingService.hxx"<br>
\r
39 #include "SALOME_LifeCycleCORBA.hxx"<br>
\r
41 int main (int argc, char * argv[]){<br>
\r
43 <font color="#3333ff"> // Initializing omniORB<br>
\r
44 </font> CORBA::ORB_var orb = CORBA::ORB_init(argc,
\r
46 <br>
\r
47 <font color="#3333ff"> // Obtain a reference
\r
49 </font> CORBA::Object_var obj = orb->resolve_initial_references("RootPOA")
\r
51 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj)
\r
53 <br>
\r
54 SALOME_NamingService _NS(orb) ;<br>
\r
56 SALOME_LifeCycleCORBA _LCC(&_NS) ;<br>
\r
58 Engines::Component_var myComponent = _LCC.FindOrLoad_Component("FactoryServerPy","TestComponentPy");<br>
\r
59 if(!CORBA::is_nil(myComponent)){<br>
\r
60 Engines::TestComponent_var
\r
61 myConcreateComponent = TestComponent::_narrow(myComponent);<br>
\r
62 <font color="#3333ff"> //do something
\r
63 what you like with the interface<br>
\r
64 ...<br>
\r
65 </font> return 0;<br>
\r
66 }<br>
\r
67 }<br>
\r
68 catch(CORBA::COMM_FAILURE& ex){<br>
\r
69 cout<<"Caught system exception COMM_FAILURE
\r
70 -- unable to contact the object.\n";<br>
\r
71 }catch(CORBA::SystemException&){<br>
\r
72 cout<<"Caught a CORBA::SystemException.\n";<br>
\r
73 }catch(CORBA::Exception&){<br>
\r
74 cout<<"Caught CORBA::Exception.\n";<br>
\r
75 }catch(...){<br>
\r
76 cout<<"Caught unknown exception.\n";<br>
\r
78 return 1;<br>
\r
81 <font color="#3333ff">#The example may be rewritten on Python like this:<br>
\r
83 from omniORB import CORBA<br>
\r
84 from SALOME_TestComponent import *<br>
\r
85 from SALOME_NamingServicePy import *<br>
\r
86 from LifeCycleCORBA import *<br>
\r
89 orb = CORBA.ORB_init(sys.argv,CORBA.ORB_ID)<br>
\r
90 _NS = SALOME_NamingService(orb)<br>
\r
91 _LCC = SALOME_LifeCycleCORBA(orb)<br>
\r
93 myComponent = _LCC.FindOrLoadComponent("FactoryServerPy","TestComponentPy");<br>
\r
94 myConcreatComponent = myComponent._narrow(TestComponent)<br>
\r
95 if myConcreatComponent is not None :<font
\r
96 color="#3333ff"><br>
\r
97 //do something what you like with the
\r
99 ...<br>
\r
100 </font> return 0<br>
\r
101 }<br>
\r
102 except CosNaming.NamingContext.NotFound, e :<br>
\r
103 print "Caught exception: Naming Service can't found Logger"<br>
\r
104 except CORBA.COMM_FAILURE, e:<br>
\r
105 print "Caught CORBA::SystemException CommFailure"<br>
\r
106 except CORBA.SystemException, e:<br>
\r
107 print "Caught CORBA::SystemException."<br>
\r
108 except CORBA.Exception, e:<br>
\r
109 print "Caught CORBA::Exception."<br>
\r
110 except Exception, e:<br>
\r
111 print "Caught unknown exception."<br>
\r