Le blog à Fred - Mot-clé - CBlog about programming and few other hobbies
Mon blog sur la programmation et autres petits trucs2024-03-28T14:34:24+01:00Fredurn:md5:aa8fdbf61072948b94b6b73fbda45c54DotclearSpreading bullshitsurn:md5:39ed85e55315b72939f0efbcbc5751772013-03-24T22:32:00+01:002017-03-06T15:42:24+01:00FredDéveloppementAdaCCORBA<p>I decided today to write a small cute tutorial to create the best of the best for <q>scalability</q>, for <q>highly distributed</q> and <q>high reliability</q> while being multi-platform, multi-language and potentially multi-paradigm... Well, the two first ones, ok but for the last, I don't really know and finally, I don't give a damn :D<br />
At this point, with the number of <em>buzzwords</em> I used, your trollmeter should explode !! :D<br />
But, from now, I won't tell you anything else, you'll have to read what follows !!</p> <p>What would be better to do the whole thing than <em>web services</em> ?<br />
Well, it's simple, something else than <em>web service</em> <img src="/themes/default/smilies/smile.png" alt=":)" class="smiley" /><br />
This other thing is an old stuff nobody wants to use anymore because it's too complicated, too heavy to set up and to code, here is <em><a href="http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture" hreflang="en" title="CORBA">CORBA</a></em> !!<br />
<br />
Well, after thinking about it, it's not a real <em>CORBA</em> tutorial because there are a lot on Internet but it's more a documented example for a small app done with <em><a href="http://libre.adacore.com/tools/polyorb" hreflang="en" title="PolyORB">PolyORB</a></em> for server-side and <em><a href="http://omniorb.sourceforge.net/" hreflang="en" title="OmniORB">OmniORB</a></em> for the C++ client-side.<br />
<br /></p>
<h4>The dispenser</h4>
<p>It's as good as a movie title but what are we distributing ?<br />
As I didn't want to build a whole app to distribute, I decided to use an existing application helping everyone on an almost daily basis. Here is the <em><a href="http://cbsg.sourceforge.net/cgi-bin/live" hreflang="en" title="CBSG">Corporate Bullshit Generator</a></em> from my Ada friend Gautier.<br />
For those who don't know already, this application provides excellent sentences to use in every good meeting with commercials, strategy managers and so on.<br />
Let's go on <a href="http://sourceforge.net/projects/cbsg/" hreflang="en" title="CBSG">the project page</a> in order to download the source code<sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/24/Spreading-bullshits#pnote-633-1" id="rev-pnote-633-1">1</a>]</sup>.<br />
<br /></p>
<h3>Small analysis of <q>bullshits</q></h3>
<p>To do some <em>CORBA</em>, we have to know what to distribute. The central package in <em>CBSG</em> is <em>Corporate_Bullshit</em>. It's a generic package to define the end of line characters and the sentence to use to simulate a dialog<sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/24/Spreading-bullshits#pnote-633-2" id="rev-pnote-633-2">2</a>]</sup>.<br />
So, what do we see ?<br /></p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">function</span> Sentence <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Workshop <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Short_Workshop <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Financial_Report <span style="color: #00007f;">return</span> String;</pre>
<p>Four functions allowing to create a string containing the set of <q>bullshits</q>. Let's be crazy, we will provide an interface for all of them.<br />
In <em>CORBA</em>, it's quite simple, we will get the following <em><a href="http://www.omg.org/gettingstarted/omg_idl.htm" hreflang="en" title="IDL">IDL</a></em> file :</p>
<pre class="cpp cpp" style="font-family:inherit">module CorbaCBSG <span style="color: #008000;">{</span>
interface CBSG<span style="color: #008000;">{</span>
string createSentence<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createWorkshop<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createShortWorkshop<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createFinancialReport<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span><span style="color: #008080;">;</span></pre>
<p>Here, I preferred to use writing conventions in use for C++, Java and others rather than the ones used in Ada in order not to scare the coder that would prefer to write the client with one of these languages <img src="/themes/default/smilies/wink.png" alt=";)" class="smiley" /><br />
Well, finally, it's piece of cake ! :D<br />
<br />
But this is only a first example...<br />
<br /></p>
<h3>Generation</h3>
<p>Let's go for the generation and implementation for server-side part.<br />
For this reason, I recommand to create a directory <em>corba</em> containing a directory <em>idl</em> and directories <em>Ada</em> and <em>C++</em>. The whole thing should be placed inside a directory <em>cbsg</em>. The file <em>cbsg.idl</em> defined will fit inside the <em>idl</em> directory.<br />
Let's make serious things :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ iac -i ../idl/cbsg.idl
</pre>
<p>Eleven files are created. Only <em>corbacbsg-cbsg-impl.ads</em> and <em>corbacbsg-cbsg-impl.adb</em> will be interesting, the others are only <em>CORBA</em> plumbing. One important point though, the <em>i</em> option will overwrite your implementation if it exists already and also the spec if it contains specific fields.<br />
In the spec file (<em>ads</em> file), there's nothing to change. In fact, our <em>CORBA</em> object doesn't hold a specific state as the <em>CBSG</em> does.<br />
But, it's interesting to read this file as the reader will notice that generated methods does not use the standard <em>String</em> type we can find in <em>Ada</em> but a <em>CORBA</em> specific type. Our <em>CORBA</em> object will do the translation.<br />
As you're really smart, I'll only give the implementation for <em>createSentence</em> function and how to declare the generic package <em>Corporate_Bullshit</em>, you'll manage to generalize on your own :</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">package</span> Simple_Generator <span style="color: #00007f;">is</span> <span style="color: #46aa03; font-weight:bold;">new</span> Corporate_Bullshit<span style="color: #66cc66;">(</span>Paragraph => <span style="color: #7f007f;">""</span>,
Dialog_Mark => <span style="color: #7f007f;">""</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">--------------------</span>
<span style="color: #adadad; font-style: italic;">-- createSentence --</span>
<span style="color: #adadad; font-style: italic;">--------------------</span>
<span style="color: #46aa03; font-weight:bold;">function</span> createSentence
<span style="color: #66cc66;">(</span>Self : <span style="color: #0000ff;">not</span> <span style="color: #46aa03; font-weight:bold;">null</span> <span style="color: #46aa03; font-weight:bold;">access</span> Object<span style="color: #66cc66;">)</span>
<span style="color: #00007f;">return</span> CORBA.<span style="color: #202020;">String</span>
<span style="color: #00007f;">is</span>
Generated_Sentence : String := Simple_Generator.<span style="color: #202020;">Sentence</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #00007f;">return</span> CORBA.<span style="color: #202020;">To_CORBA_String</span><span style="color: #66cc66;">(</span>Generated_Sentence<span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span> createSentence;</pre>
<p>Now that we've defined the behaviour of our object, it's time to statup the <em>CORBA</em> bus and expose an instance of our brand new class.<br />
For now, we won't use one of the most used <em>CORBA</em> service, the <em>Name Service</em>. Our server will only expose an <em><a href="http://en.wikipedia.org/wiki/Interoperable_Object_Reference" hreflang="en" title="IOR">IOR</a></em>, reference to our object.<br />
For this server, the <em>echo</em> example provided with <em>PolyORB</em> will be enough :</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Exceptions</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Text_IO</span>; <span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">Impl</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">Object</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">ORB</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Helper</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PortableServer.<span style="color: #202020;">POAManager</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Impl</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">CORBA_P</span>.<span style="color: #202020;">CORBALOC</span>;
<span style="color: #adadad; font-style: italic;">-- Allow to specify to PolyORB how to behave from a tasking point of view</span>
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">No_Tasking_Server</span>;
<span style="color: #46aa03; font-weight:bold;">pragma</span> Warnings <span style="color: #66cc66;">(</span>Off, PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">No_Tasking_Server</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">procedure</span> Server <span style="color: #00007f;">is</span>
<span style="color: #00007f;">begin</span>
<span style="color: #00007f;">declare</span>
<span style="color: #adadad; font-style: italic;">-- Allows to get the paramters such as those defined in the CORBA standard like InitialRef</span>
Argv : CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Arg_List</span> := CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Command_Line_Arguments</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #adadad; font-style: italic;">-- Initiliaze our bus under the name ORB</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Init</span> <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB"</span><span style="color: #66cc66;">)</span>, Argv<span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">declare</span>
<span style="color: #adadad; font-style: italic;">-- The PortableObjectAdapter is where we register our objects</span>
Root_POA : PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Local_Ref</span>;
<span style="color: #adadad; font-style: italic;">-- We declare a reference for our object</span>
Ref : CORBA.<span style="color: #202020;">Object</span>.<span style="color: #202020;">Ref</span>;
<span style="color: #adadad; font-style: italic;">-- And its implementation</span>
Obj : <span style="color: #46aa03; font-weight:bold;">constant</span> CORBA.<span style="color: #202020;">Impl</span>.<span style="color: #202020;">Object_Ptr</span> := <span style="color: #46aa03; font-weight:bold;">new</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Impl</span>.<span style="color: #202020;">Object</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #adadad; font-style: italic;">-- We get the Root POA</span>
Root_POA := PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Helper</span>.<span style="color: #202020;">To_Local_Ref</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Resolve_Initial_References</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"RootPOA"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- We start it up</span>
PortableServer.<span style="color: #202020;">POAManager</span>.<span style="color: #202020;">Activate</span>
<span style="color: #66cc66;">(</span>PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Get_The_POAManager</span> <span style="color: #66cc66;">(</span>Root_POA<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- We create a reference in order to expose it</span>
Ref := PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Servant_To_Reference</span>
<span style="color: #66cc66;">(</span>Root_POA, PortableServer.<span style="color: #202020;">Servant</span> <span style="color: #66cc66;">(</span>Obj<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- We display the IOR</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"'"</span>
& CORBA.<span style="color: #202020;">To_Standard_String</span> <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Object</span>.<span style="color: #202020;">Object_To_String</span> <span style="color: #66cc66;">(</span>Ref<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
& <span style="color: #7f007f;">"'"</span><span style="color: #66cc66;">)</span>;
New_Line;
<span style="color: #adadad; font-style: italic;">-- and a corbaloc</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"'"</span>
& CORBA.<span style="color: #202020;">To_Standard_String</span>
<span style="color: #66cc66;">(</span>PolyORB.<span style="color: #202020;">CORBA_P</span>.<span style="color: #202020;">CORBALOC</span>.<span style="color: #202020;">Object_To_Corbaloc</span> <span style="color: #66cc66;">(</span>Ref<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
& <span style="color: #7f007f;">"'"</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- Launch the server. CORBA.ORB.Run is supposed to never return,</span>
<span style="color: #adadad; font-style: italic;">-- print a message if it does.</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Run</span>;
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB main loop terminated!"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">exception</span>
<span style="color: #46aa03; font-weight:bold;">when</span> E : <span style="color: #46aa03; font-weight:bold;">others</span> =>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"CBSG server raised "</span> & Ada.<span style="color: #202020;">Exceptions</span>.<span style="color: #202020;">Exception_Information</span> <span style="color: #66cc66;">(</span>E<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">raise</span>;
<span style="color: #00007f;">end</span> Server;</pre>
<p>Even if this code seems complex, it's always the same each time we will expose an object in the bus.<br />
We just have to compile :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ mkdir obj
fred@coruscant :~/cbsg/corba/Ada $ gnatmake server.adb -D obj -aI../.. `polyorb-config`
</pre>
<p>If everything went well, we just have to start the server</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ ./server
'IOR:010000001700000049444c3a436f726261434253472f434253473a312e30000002000000000000005c000000010102000a0000003132372e302e302e3100f1761b0000002f30303030303030313154643637306239663031326565316538300001000000010000001c0000000100000001000100000000000001010002000000010101000201010003004f503c000000010100000c0000003139322e3136382e332e32007a3300001b0000002f30303030303030313154643637306239663031326565316538300000000000'
'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
</pre>
<p>if you want the server to listen on another address than 127.0.0.1, we just have to put it in <em>polyorb.conf</em> which must be at the place from which you run the server.<br /></p>
<h3>Waiter, please</h3>
<p>Now that our server is waiting for a client, let's code it. First, a small simple <em>Ada</em> client as everything is ready for it. Once again, the <em>echo</em> example will be enough to create our client</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Command_Line</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">ORB</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">Client</span>;
<span style="color: #46aa03; font-weight:bold;">pragma</span> Warnings <span style="color: #66cc66;">(</span>Off, PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">Client</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">procedure</span> Client <span style="color: #00007f;">is</span>
<span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Command_Line</span>;
<span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">use</span> <span style="color: #46aa03; font-weight:bold;">type</span> CORBA.<span style="color: #202020;">String</span>;
Rcvd_Bullshits : CORBA.<span style="color: #202020;">String</span>;
Bullshit_Generator : CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Ref</span>;
<span style="color: #00007f;">begin</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Initialize</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">if</span> Argument_Count <span style="color: #0000ff;">not</span> <span style="color: #46aa03; font-weight:bold;">in</span> <span style="color: #ff0000;">1</span> .. <span style="color: #ff0000;">2</span> <span style="color: #00007f;">then</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"usage: client <IOR_string_from_server>"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">return</span>;
<span style="color: #00007f;">end</span> <span style="color: #00007f;">if</span>;
<span style="color: #adadad; font-style: italic;">-- Get a reference on the distributed object through its IOR or corbaloc</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">String_To_Object</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span>Ada.<span style="color: #202020;">Command_Line</span>.<span style="color: #202020;">Argument</span> <span style="color: #66cc66;">(</span><span style="color: #ff0000;">1</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>, Bullshit_Generator<span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- check that the reference is correct</span>
<span style="color: #00007f;">if</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Is_Nil</span><span style="color: #66cc66;">(</span>Bullshit_Generator<span style="color: #66cc66;">)</span> <span style="color: #00007f;">then</span>
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"main : cannot invoke on a nil reference"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">return</span>;
<span style="color: #00007f;">end</span> <span style="color: #00007f;">if</span>;
Rcvd_Bullshits := CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">createSentence</span><span style="color: #66cc66;">(</span>Bullshit_Generator<span style="color: #66cc66;">)</span>;
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"The generator said : "</span> & CORBA.<span style="color: #202020;">To_Standard_String</span> <span style="color: #66cc66;">(</span>Rcvd_Bullshits<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">exception</span>
<span style="color: #46aa03; font-weight:bold;">when</span> E : CORBA.<span style="color: #202020;">Transient</span> =>
<span style="color: #00007f;">declare</span>
Memb : CORBA.<span style="color: #202020;">System_Exception_Members</span>;
<span style="color: #00007f;">begin</span>
CORBA.<span style="color: #202020;">Get_Members</span> <span style="color: #66cc66;">(</span>E, Memb<span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"received exception transient, minor"</span><span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Unsigned_Long</span>'Image <span style="color: #66cc66;">(</span>Memb.<span style="color: #202020;">Minor</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span><span style="color: #7f007f;">", completion status: "</span><span style="color: #66cc66;">)</span>;
Put_Line <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Completion_Status</span>'Image <span style="color: #66cc66;">(</span>Memb.<span style="color: #202020;">Completed</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">end</span> Client;</pre>
<p>As usual, compilation :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ gnatmake client -D obj -aI../.. `polyorb-config `
fred@coruscant :~/cbsg/corba/Ada $ ./client 'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
The generator said : The business leaders embrace a growing execution by thinking outside of the box, whereas the steering committee delivers a top-down interoperability.
</pre>
<p>What to say other than <strong>superb</strong> !!<br />
<br />
Ok, I promised a C++ client with <em>OmniORB</em>. As I always deliver the goods, here it is...<br />
In the C++ directory, we begin by generating the needed files with the <em>OmniORB</em> IDL compiler.</p>
<pre>
fred@coruscant :~/cbsg/corba/C++ $ omniidl -bcxx ../idl/cbsg.idl
</pre>
<p><em>cbsg.hh</em> and <em>cbsg.cc</em> get created. They contain at the same time <em>stubs</em> and <em>skeletons</em>. For the client-side, we will only use the <em>stub</em> part.<br />
We create the client by taking ideas from the provided examples with <em>OmniORB</em> :<br /></p>
<pre class="cpp cpp" style="font-family:inherit"><span style="color: #339900;">#include <cbsg.hh></span>
<span style="color: #339900;">#ifdef HAVE_STD </span>
<span style="color: #339900;">#include <iostream> </span>
<span style="color: #339900;">#include <fstream> </span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
<span style="color: #339900;">#else </span>
<span style="color: #339900;">#include <iostream.h></span>
<span style="color: #339900;">#endif </span>
<span style="color: #666666;">////////////////////////////////////////////////////////////////////// </span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span><span style="color: #000040;">**</span> argv<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000ff;">try</span>
<span style="color: #008000;">{</span>
<span style="color: #666666;">//ORB Initialisation</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">ORB_var</span> orb <span style="color: #000080;">=</span> CORBA<span style="color: #008080;">::</span><span style="color: #007788;">ORB_init</span><span style="color: #008000;">(</span>argc, argv<span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">if</span><span style="color: #008000;">(</span> argc <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span> <span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"usage: client <object reference>"</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #666666;">//We create the CORBA object from the provided string</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">Object_var</span> obj <span style="color: #000080;">=</span> orb<span style="color: #000040;">-</span><span style="color: #000080;">></span>string_to_object<span style="color: #008000;">(</span>argv<span style="color: #008000;">[</span><span style="color: #0000dd;">1</span><span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//We cast it to CBSG</span>
CorbaCBSG<span style="color: #008080;">::</span><span style="color: #007788;">CBSG_var</span> cbsgRef <span style="color: #000080;">=</span> CorbaCBSG<span style="color: #008080;">::</span><span style="color: #007788;">CBSG</span><span style="color: #008080;">::</span>_narrow<span style="color: #008000;">(</span>obj<span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//We check that the object exists</span>
<span style="color: #0000ff;">if</span><span style="color: #008000;">(</span> CORBA<span style="color: #008080;">::</span><span style="color: #007788;">is_nil</span><span style="color: #008000;">(</span>cbsgRef<span style="color: #008000;">)</span> <span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Can't narrow reference to type CBSG (or it was nil)."</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #666666;">//And go, we call it</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">String_var</span> bullshit <span style="color: #000080;">=</span> cbsgRef<span style="color: #000040;">-</span><span style="color: #000080;">></span>createSentence<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"The generator said : "</span> <span style="color: #000080;"><<</span> bullshit <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #666666;">//We stop the ORB</span>
orb<span style="color: #000040;">-</span><span style="color: #000080;">></span>destroy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">TRANSIENT</span><span style="color: #000040;">&</span><span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught system exception TRANSIENT -- unable to contact the "</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"server."</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">SystemException</span><span style="color: #000040;">&</span> ex<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught a CORBA::"</span> <span style="color: #000080;"><<</span> ex._name<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">Exception</span><span style="color: #000040;">&</span> ex<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught CORBA::Exception: "</span> <span style="color: #000080;"><<</span> ex._name<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>omniORB<span style="color: #008080;">::</span><span style="color: #007788;">fatalException</span><span style="color: #000040;">&</span> fe<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught omniORB::fatalException:"</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" file: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">file</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" line: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">line</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" mesg: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">errmsg</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span></pre>
<p>We compile and test :</p>
<pre>
fred@coruscant :~/cbsg/corba/C++ $ g++ -o client client.cpp cbsgSK.cc -I. -lomniORB4
fred@coruscant :~/cbsg/corba/C++ $ ./client 'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
The generator said : The granular low hanging fruit incentivises the steering committee.
</pre>
<p>Depending on the version of <em>OmniORB</em>, it could be necessary to include <q>-lomnithread</q> on the compilation command line.<br />
And that's it !<br />
Well, I promised high availability and <em>tutti quanti</em> but finally, I will keep it for the next time <img src="/themes/default/smilies/smile.png" alt=":)" class="smiley" /><br />
Hope it pleased you.</p>
<div class="footnotes"><h4>Notes</h4>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/24/Spreading-bullshits#rev-pnote-633-1" id="pnote-633-1">1</a>] But just read interfaces, you would get a <q>bullshit</q> overdose</p>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/24/Spreading-bullshits#rev-pnote-633-2" id="pnote-633-2">2</a>] This second parameter quite obscur is not used by Gautier, so caution :D</p></div>
http://frederic.praca.free.fr/index.php?post/2013/03/24/Spreading-bullshits#comment-formhttp://frederic.praca.free.fr/index.php?feed/atom/comments/633Distribution de conneriesurn:md5:7fca88b3bb2430353a9bc718b17f0a132013-03-22T16:31:00+01:002013-03-26T17:54:59+01:00FredDéveloppementAdaCCORBA<p>J'ai décidé aujourd'hui de faire un petit tuto sympa pour réaliser le top du top en matière de <q>scalabilité</q><sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#pnote-632-1" id="rev-pnote-632-1">1</a>]</sup>, de haute distribution ainsi que haute <q>reliabilité</q><sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#pnote-632-2" id="rev-pnote-632-2">2</a>]</sup> tout en restant multi-plateforme, multi-langage et potentiellement multi-paradigme... Enfin, les deux premiers, c'est sûr, le troisième, j'en sais rien et je m'en tape :D<br />
Normalement, là, avec le nombre de <em>buzzwords</em> utilisés, vous devriez déjà avoir le trollomètre au taquet !! :D<br />
Mais je ne vous en dirai pas plus, il faut aller voir, LA SUITE !!!</p>
<div class="footnotes"><h4>Notes</h4>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#rev-pnote-632-1" id="pnote-632-1">1</a>] J'adore cet anglicisme tellement il est foireux</p>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#rev-pnote-632-2" id="pnote-632-2">2</a>] Bien aussi, celui-là</p></div>
<p>Quoi de mieux pour réaliser tout ça que les <em>web services</em> ?<br />
Et bien, c'est simple, autre chose que des <em>web services</em> !! <img src="/themes/default/smilies/smile.png" alt=":)" class="smiley" /><br />
Cette autre chose est un vieux truc que plus personne ne veut utiliser car trop compliqué, trop lourd à mettre en place et à coder, j'ai nommé <em><a href="http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture" hreflang="en" title="CORBA">CORBA</a></em><sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#pnote-632-1" id="rev-pnote-632-1">1</a>]</sup> !!<br />
<br />
Bon, après réflexion, ce ne sera pas un vrai tutoriel <em>CORBA</em>, car il y en a déjà sur Internet, mais plutôt un exemple documenté d'une petite application faite avec <em><a href="http://libre.adacore.com/tools/polyorb" hreflang="en" title="PolyORB">PolyORB</a></em> pour ce qui est du serveur et <em> <a href="http://omniorb.sourceforge.net/" hreflang="en" title="OmniORB">OmniORB</a></em> pour la partie C++ cliente.<br />
<br /></p>
<h4>Le distributeur</h4>
<p>C'est beau comme un titre de films mais que distribuons-nous ?<br />
N'ayant pas envie de recoder toute une application pour la distribuer, j'ai décidé de repartir d'une application existante et rendant régulièrement service. J'ai nommé le <em><a href="http://cbsg.sourceforge.net/cgi-bin/live" hreflang="en" title="CBSG">Corporate Bullshit Generator</a></em> de mon ami adaïste Gautier.<br />
Pour ceux qui ne connaîtraient pas encore, cette application fournit d'excellentes phrases à placer dans toute bonne réunion se déroulant en présence de commerciaux, grands statéguères etc.<br />
Rendez-vous donc sur <a href="http://sourceforge.net/projects/cbsg/" hreflang="en" title="CBSG">la page du projet</a> afin de télécharger le code source<sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#pnote-632-2" id="rev-pnote-632-2">2</a>]</sup>.<br />
<br /></p>
<h3>Petite analyse des <q>bullshits</q></h3>
<p>Pour faire du <em>CORBA</em>, il faut d'abord savoir ce que l'on va distribuer. Le paquetage central du <em>CSBG</em> est le <em>Corporate_Bullshit</em>. Il s'agit d'un paquetage générique dont le but est de définir les caractères de saut de lignes ainsi que la phrase à utiliser pour simuler un dialogue<sup>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#pnote-632-3" id="rev-pnote-632-3">3</a>]</sup>.<br />
Quoi qu'on voit ?<br /></p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">function</span> Sentence <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Workshop <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Short_Workshop <span style="color: #00007f;">return</span> String;
<span style="color: #46aa03; font-weight:bold;">function</span> Financial_Report <span style="color: #00007f;">return</span> String;</pre>
<p>Quatre fonctions permettant de créer une chaîne de caractères contenant l'ensemble des <q>bullshits</q>. Soyons fous, nous fournirons donc une interface vers les quatre.<br />
En <em>CORBA</em>, c'est assez simple, cela donnera un fichier <em><a href="http://www.eecg.toronto.edu/~jacobsen/courses/mw/IDL.htm" hreflang="fr" title="IDL">IDL</a></em> comme montrer ci-dessous :</p>
<pre class="cpp cpp" style="font-family:inherit">module CorbaCBSG <span style="color: #008000;">{</span>
interface CBSG<span style="color: #008000;">{</span>
string createSentence<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createWorkshop<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createShortWorkshop<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
string createFinancialReport<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span><span style="color: #008080;">;</span></pre>
<p>Ici, j'ai préféré respecter les conventions d'écriture en vigueur en C++, Java et consorts en lieu et place de celles d'Ada pour ne pas effrayer le programmeur qui voudrait écrire un client dans ces langages <img src="/themes/default/smilies/wink.png" alt=";)" class="smiley" /><br />
Au final, c'est bête comme chou ! :D<br />
<br />
Mais ce n'est qu'un premier exemple...<br />
<br /></p>
<h3>Génération</h3>
<p>Passons maintenant à la génération et à l'implémentation de la partie serveur.<br />
Pour cela, je conseille la création d'un répertoire <em>corba</em> contenant un répertoire <em>idl</em> ainsi que des répertoires <em>Ada</em> et <em>C++</em>, le tout dans le répertoire du <em>cbsg</em>. Le fichier <em>cbsg.idl</em> définit au-dessus trouvera aisément sa place dans le répertoire <em>idl</em>.<br />
Passons aux choses sérieuses :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ iac -i ../idl/cbsg.idl
</pre>
<p>Onze fichiers sont normalement créés. Seul les fichiers <em>corbacbsg-cbsg-impl.ads</em> et <em>corbacbsg-cbsg-impl.adb</em> vont nous intéresser, le reste étant de la tuyauterie <em>CORBA</em>. Un point toutefois important, l'option <em>i</em> écrasera votre implémentation si celle-ci existe déjà ainsi que sa spécification si elle contient des champs spécifiques.<br />
Dans la spécification (fichier <em>ads</em>), il n'y a rien à changer. En effet, notre objet <em>CORBA</em> n'a pas d'état en soi tout comme le <em>CBSG</em>.<br />
Par contre, il est intéressant de lire ce fichier car le lecteur attentif aura remarqué que les méthodes générées n'utilisent pas le type <em>String</em> standard d<em>'Ada</em> mais un type propre à <em>CORBA</em>. Notre objet <em>CORBA</em> fera donc la translation.<br />
Comme vous êtes très forts, je ne donnerai que l'implémentation de la fonction <em>createSentence</em> ainsi que la déclaration du paquetage générique <em>Corporate_Bullshit</em> , vous généraliserez par vous-mêmes :</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">package</span> Simple_Generator <span style="color: #00007f;">is</span> <span style="color: #46aa03; font-weight:bold;">new</span> Corporate_Bullshit<span style="color: #66cc66;">(</span>Paragraph => <span style="color: #7f007f;">""</span>,
Dialog_Mark => <span style="color: #7f007f;">""</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">--------------------</span>
<span style="color: #adadad; font-style: italic;">-- createSentence --</span>
<span style="color: #adadad; font-style: italic;">--------------------</span>
<span style="color: #46aa03; font-weight:bold;">function</span> createSentence
<span style="color: #66cc66;">(</span>Self : <span style="color: #0000ff;">not</span> <span style="color: #46aa03; font-weight:bold;">null</span> <span style="color: #46aa03; font-weight:bold;">access</span> Object<span style="color: #66cc66;">)</span>
<span style="color: #00007f;">return</span> CORBA.<span style="color: #202020;">String</span>
<span style="color: #00007f;">is</span>
Generated_Sentence : String := Simple_Generator.<span style="color: #202020;">Sentence</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #00007f;">return</span> CORBA.<span style="color: #202020;">To_CORBA_String</span><span style="color: #66cc66;">(</span>Generated_Sentence<span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span> createSentence;</pre>
<p>Maintenant que nous avons défini le comportement de notre objet, il nous faut démarrer le bus <em>CORBA</em> et exposer une instance de notre toute nouvelle classe.<br />
Pour le moment, nous n'utiliserons pas l'un des services primordiaux de <em>CORBA</em>, à savoir le <em>Name Service</em>. Notre serveur exposera donc seulement une <em><a href="http://en.wikipedia.org/wiki/Interoperable_Object_Reference" hreflang="en" title="IOR">IOR</a></em>, référence vers notre objet.<br />
Pour ce serveur, l'exemple <em>echo</em> fournit avec <em>PolyORB</em> suffit amplement :</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Exceptions</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Text_IO</span>; <span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">Impl</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">Object</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">ORB</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Helper</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PortableServer.<span style="color: #202020;">POAManager</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Impl</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">CORBA_P</span>.<span style="color: #202020;">CORBALOC</span>;
<span style="color: #adadad; font-style: italic;">-- Permet de spécifier à PolyORB son type de fonctionnement</span>
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">No_Tasking_Server</span>;
<span style="color: #46aa03; font-weight:bold;">pragma</span> Warnings <span style="color: #66cc66;">(</span>Off, PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">No_Tasking_Server</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">procedure</span> Server <span style="color: #00007f;">is</span>
<span style="color: #00007f;">begin</span>
<span style="color: #00007f;">declare</span>
<span style="color: #adadad; font-style: italic;">-- Permet de récupérer les paramètres tels que définis dans le norme CORBA comme InitialRef</span>
Argv : CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Arg_List</span> := CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Command_Line_Arguments</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #adadad; font-style: italic;">-- Initialisation de notre bus sous le nom ORB</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Init</span> <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB"</span><span style="color: #66cc66;">)</span>, Argv<span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">declare</span>
<span style="color: #adadad; font-style: italic;">-- Le PortableObjectAdapter est l'endroit où sont stockés nons objets</span>
Root_POA : PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Local_Ref</span>;
<span style="color: #adadad; font-style: italic;">-- On déclare une référence pour notre objet</span>
Ref : CORBA.<span style="color: #202020;">Object</span>.<span style="color: #202020;">Ref</span>;
<span style="color: #adadad; font-style: italic;">-- Et son implémentation</span>
Obj : <span style="color: #46aa03; font-weight:bold;">constant</span> CORBA.<span style="color: #202020;">Impl</span>.<span style="color: #202020;">Object_Ptr</span> := <span style="color: #46aa03; font-weight:bold;">new</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Impl</span>.<span style="color: #202020;">Object</span>;
<span style="color: #00007f;">begin</span>
<span style="color: #adadad; font-style: italic;">-- Récupération du POA racine du bus</span>
<span style="color: #adadad; font-style: italic;">-- Il s'agit d'une interface CORBA et utilise donc des chaines de caractères CORBA</span>
<span style="color: #adadad; font-style: italic;">-- que l'on traduit en référence d'objet</span>
Root_POA := PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Helper</span>.<span style="color: #202020;">To_Local_Ref</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Resolve_Initial_References</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"RootPOA"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- On démarre notre POA</span>
PortableServer.<span style="color: #202020;">POAManager</span>.<span style="color: #202020;">Activate</span>
<span style="color: #66cc66;">(</span>PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Get_The_POAManager</span> <span style="color: #66cc66;">(</span>Root_POA<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- On crée une référence sur notre objet pour l'exposer</span>
Ref := PortableServer.<span style="color: #202020;">POA</span>.<span style="color: #202020;">Servant_To_Reference</span>
<span style="color: #66cc66;">(</span>Root_POA, PortableServer.<span style="color: #202020;">Servant</span> <span style="color: #66cc66;">(</span>Obj<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- Et on affiche un IOR</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"'"</span>
& CORBA.<span style="color: #202020;">To_Standard_String</span> <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Object</span>.<span style="color: #202020;">Object_To_String</span> <span style="color: #66cc66;">(</span>Ref<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
& <span style="color: #7f007f;">"'"</span><span style="color: #66cc66;">)</span>;
New_Line;
<span style="color: #adadad; font-style: italic;">-- et une corbaloc</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"'"</span>
& CORBA.<span style="color: #202020;">To_Standard_String</span>
<span style="color: #66cc66;">(</span>PolyORB.<span style="color: #202020;">CORBA_P</span>.<span style="color: #202020;">CORBALOC</span>.<span style="color: #202020;">Object_To_Corbaloc</span> <span style="color: #66cc66;">(</span>Ref<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
& <span style="color: #7f007f;">"'"</span><span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- Launch the server. CORBA.ORB.Run is supposed to never return,</span>
<span style="color: #adadad; font-style: italic;">-- print a message if it does.</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Run</span>;
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB main loop terminated!"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">exception</span>
<span style="color: #46aa03; font-weight:bold;">when</span> E : <span style="color: #46aa03; font-weight:bold;">others</span> =>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"CBSG server raised "</span> & Ada.<span style="color: #202020;">Exceptions</span>.<span style="color: #202020;">Exception_Information</span> <span style="color: #66cc66;">(</span>E<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">raise</span>;
<span style="color: #00007f;">end</span> Server;</pre>
<p>Même si ce code a l'air complexe, il est quasi identique pour toutes les fois où l'on doit exposer un objet sur le bus.<br />
Il ne reste plus que la compilation :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ mkdir obj
fred@coruscant :~/cbsg/corba/Ada $ gnatmake server.adb -D obj -aI../.. `polyorb-config`
</pre>
<p>Si tout c'est bien passé, il ne reste qu'à lancer notre serveur</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ ./server
'IOR:010000001700000049444c3a436f726261434253472f434253473a312e30000002000000000000005c000000010102000a0000003132372e302e302e3100f1761b0000002f30303030303030313154643637306239663031326565316538300001000000010000001c0000000100000001000100000000000001010002000000010101000201010003004f503c000000010100000c0000003139322e3136382e332e32007a3300001b0000002f30303030303030313154643637306239663031326565316538300000000000'
'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
</pre>
<p>vous voulez que le serveur écoute sur autre chose que 127.0.0.1, il suffit de le préciser dans le fichier <em>polyorb.conf</em> qui devra se trouver à l'endroit d'où vous lancez le serveur.<br /></p>
<h3>Serveur, s'il vous plaît</h3>
<p>Maintenant que notre serveur attend le client, codons-le. D'abord un petit client tout simple en <em>Ada</em> vu que tout est prêt pour cela. Encore une fois, l'exemple <em>echo</em> fourni nous suffira pour créer notre client</p>
<pre class="ada ada" style="font-family:inherit"><span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Command_Line</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CORBA.<span style="color: #202020;">ORB</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>;
<span style="color: #46aa03; font-weight:bold;">with</span> PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">Client</span>;
<span style="color: #46aa03; font-weight:bold;">pragma</span> Warnings <span style="color: #66cc66;">(</span>Off, PolyORB.<span style="color: #202020;">Setup</span>.<span style="color: #202020;">Client</span><span style="color: #66cc66;">)</span>;
<span style="color: #46aa03; font-weight:bold;">procedure</span> Client <span style="color: #00007f;">is</span>
<span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Command_Line</span>;
<span style="color: #46aa03; font-weight:bold;">use</span> Ada.<span style="color: #202020;">Text_IO</span>;
<span style="color: #46aa03; font-weight:bold;">use</span> <span style="color: #46aa03; font-weight:bold;">type</span> CORBA.<span style="color: #202020;">String</span>;
Rcvd_Bullshits : CORBA.<span style="color: #202020;">String</span>;
Bullshit_Generator : CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Ref</span>;
<span style="color: #00007f;">begin</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">Initialize</span> <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"ORB"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">if</span> Argument_Count <span style="color: #0000ff;">not</span> <span style="color: #46aa03; font-weight:bold;">in</span> <span style="color: #ff0000;">1</span> .. <span style="color: #ff0000;">2</span> <span style="color: #00007f;">then</span>
Put_Line
<span style="color: #66cc66;">(</span><span style="color: #7f007f;">"usage: client <IOR_string_from_server>"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">return</span>;
<span style="color: #00007f;">end</span> <span style="color: #00007f;">if</span>;
<span style="color: #adadad; font-style: italic;">-- Récupération d'une référence sur l'objet distribué par son IOR ou corbaloc</span>
CORBA.<span style="color: #202020;">ORB</span>.<span style="color: #202020;">String_To_Object</span>
<span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">To_CORBA_String</span> <span style="color: #66cc66;">(</span>Ada.<span style="color: #202020;">Command_Line</span>.<span style="color: #202020;">Argument</span> <span style="color: #66cc66;">(</span><span style="color: #ff0000;">1</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>, Bullshit_Generator<span style="color: #66cc66;">)</span>;
<span style="color: #adadad; font-style: italic;">-- On vérifie que la référence est correcte</span>
<span style="color: #00007f;">if</span> CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">Is_Nil</span><span style="color: #66cc66;">(</span>Bullshit_Generator<span style="color: #66cc66;">)</span> <span style="color: #00007f;">then</span>
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"main : cannot invoke on a nil reference"</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">return</span>;
<span style="color: #00007f;">end</span> <span style="color: #00007f;">if</span>;
Rcvd_Bullshits := CorbaCBSG.<span style="color: #202020;">CBSG</span>.<span style="color: #202020;">createSentence</span><span style="color: #66cc66;">(</span>Bullshit_Generator<span style="color: #66cc66;">)</span>;
Put_Line <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"The generator said : "</span> & CORBA.<span style="color: #202020;">To_Standard_String</span> <span style="color: #66cc66;">(</span>Rcvd_Bullshits<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">exception</span>
<span style="color: #46aa03; font-weight:bold;">when</span> E : CORBA.<span style="color: #202020;">Transient</span> =>
<span style="color: #00007f;">declare</span>
Memb : CORBA.<span style="color: #202020;">System_Exception_Members</span>;
<span style="color: #00007f;">begin</span>
CORBA.<span style="color: #202020;">Get_Members</span> <span style="color: #66cc66;">(</span>E, Memb<span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span><span style="color: #7f007f;">"received exception transient, minor"</span><span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Unsigned_Long</span>'Image <span style="color: #66cc66;">(</span>Memb.<span style="color: #202020;">Minor</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
Put <span style="color: #66cc66;">(</span><span style="color: #7f007f;">", completion status: "</span><span style="color: #66cc66;">)</span>;
Put_Line <span style="color: #66cc66;">(</span>CORBA.<span style="color: #202020;">Completion_Status</span>'Image <span style="color: #66cc66;">(</span>Memb.<span style="color: #202020;">Completed</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
<span style="color: #00007f;">end</span>;
<span style="color: #00007f;">end</span> Client;</pre>
<p>Comme d'habitude, compilation :</p>
<pre>
fred@coruscant :~/cbsg/corba/Ada $ gnatmake client -D obj -aI../.. `polyorb-config `
fred@coruscant :~/cbsg/corba/Ada $ ./client 'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
The generator said : The business leaders embrace a growing execution by thinking outside of the box, whereas the steering committee delivers a top-down interoperability.
</pre>
<p>Que dire de plus que <strong>magnifique</strong> !!<br />
<br />
Ok, j'avais promis un client C++ avec <em>OmniORB</em>. Comme je tiens toujours mes promesses, le voici...<br />
Dans le répertoire C++, on commence donc par générer les fichiers nécessaires avec le compilateur d'IDL d<em>'OmniORB</em>.</p>
<pre>
fred@coruscant :~/cbsg/corba/C++ $ omniidl -bcxx ../idl/cbsg.idl
</pre>
<p>Les fichiers <em>cbsg.hh</em> et <em>cbsg.cc</em> sont créés. Ils contiennent à la fois les <em>stubs</em> et les <em>skeletons</em>. Dans le cadre du client, on n'utilisera que la partie <em>stub</em>.<br />
on crée donc le client en s'inspirant des exemples fournis avec <em>OmniORB</em> :<br /></p>
<pre class="cpp cpp" style="font-family:inherit"><span style="color: #339900;">#include <cbsg.hh></span>
<span style="color: #339900;">#ifdef HAVE_STD </span>
<span style="color: #339900;">#include <iostream> </span>
<span style="color: #339900;">#include <fstream> </span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
<span style="color: #339900;">#else </span>
<span style="color: #339900;">#include <iostream.h></span>
<span style="color: #339900;">#endif </span>
<span style="color: #666666;">////////////////////////////////////////////////////////////////////// </span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span><span style="color: #000040;">**</span> argv<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000ff;">try</span>
<span style="color: #008000;">{</span>
<span style="color: #666666;">//Initialisation de l'ORB</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">ORB_var</span> orb <span style="color: #000080;">=</span> CORBA<span style="color: #008080;">::</span><span style="color: #007788;">ORB_init</span><span style="color: #008000;">(</span>argc, argv<span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">if</span><span style="color: #008000;">(</span> argc <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span> <span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"usage: client <object reference>"</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #666666;">//On crée un objet CORBA à partir de la chaine fournie</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">Object_var</span> obj <span style="color: #000080;">=</span> orb<span style="color: #000040;">-</span><span style="color: #000080;">></span>string_to_object<span style="color: #008000;">(</span>argv<span style="color: #008000;">[</span><span style="color: #0000dd;">1</span><span style="color: #008000;">]</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//Et le castons en CBSG</span>
CorbaCBSG<span style="color: #008080;">::</span><span style="color: #007788;">CBSG_var</span> cbsgRef <span style="color: #000080;">=</span> CorbaCBSG<span style="color: #008080;">::</span><span style="color: #007788;">CBSG</span><span style="color: #008080;">::</span>_narrow<span style="color: #008000;">(</span>obj<span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//On vérifie que l'objet existe</span>
<span style="color: #0000ff;">if</span><span style="color: #008000;">(</span> CORBA<span style="color: #008080;">::</span><span style="color: #007788;">is_nil</span><span style="color: #008000;">(</span>cbsgRef<span style="color: #008000;">)</span> <span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Can't narrow reference to type CBSG (or it was nil)."</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #666666;">//Et hop, on appelle</span>
CORBA<span style="color: #008080;">::</span><span style="color: #007788;">String_var</span> bullshit <span style="color: #000080;">=</span> cbsgRef<span style="color: #000040;">-</span><span style="color: #000080;">></span>createSentence<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"The generator said : "</span> <span style="color: #000080;"><<</span> bullshit <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #666666;">//On arrête l'ORB</span>
orb<span style="color: #000040;">-</span><span style="color: #000080;">></span>destroy<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">TRANSIENT</span><span style="color: #000040;">&</span><span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught system exception TRANSIENT -- unable to contact the "</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"server."</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">SystemException</span><span style="color: #000040;">&</span> ex<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught a CORBA::"</span> <span style="color: #000080;"><<</span> ex._name<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>CORBA<span style="color: #008080;">::</span><span style="color: #007788;">Exception</span><span style="color: #000040;">&</span> ex<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught CORBA::Exception: "</span> <span style="color: #000080;"><<</span> ex._name<span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">catch</span><span style="color: #008000;">(</span>omniORB<span style="color: #008080;">::</span><span style="color: #007788;">fatalException</span><span style="color: #000040;">&</span> fe<span style="color: #008000;">)</span>
<span style="color: #008000;">{</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">"Caught omniORB::fatalException:"</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" file: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">file</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" line: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">line</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cerr</span> <span style="color: #000080;"><<</span> <span style="color: #FF0000;">" mesg: "</span> <span style="color: #000080;"><<</span> fe.<span style="color: #007788;">errmsg</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #000080;"><<</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">}</span>
<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">}</span></pre>
<p>On compile et on teste</p>
<pre>
fred@coruscant :~/cbsg/corba/C++ $ g++ -o client client.cpp cbsgSK.cc -I. -lomniORB4
fred@coruscant :~/cbsg/corba/C++ $ ./client 'corbaloc:iiop:1.2@127.0.0.1:30449//000000011Td670b9f012ee1e80'
The generator said : The granular low hanging fruit incentivises the steering committee.
</pre>
<p>Suivant la version d<em>'OmniORB</em>, il peut être nécessaire de compléter la ligne de compilation avec <q>-lomnithread</q>.<br />
Et voilà !<br />
Bon, j'avais promis de la haute disponibilité et <em>tutti quanti</em> mais finalement, on va garder ça pour la prochaine fois <img src="/themes/default/smilies/smile.png" alt=":)" class="smiley" /><br />
En espérant que cela vous a plu.</p>
<div class="footnotes"><h4>Notes</h4>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#rev-pnote-632-1" id="pnote-632-1">1</a>] Désolé mais la page en français est beaucoup trop incomplête <img src="/themes/default/smilies/sad.png" alt=":(" class="smiley" /></p>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#rev-pnote-632-2" id="pnote-632-2">2</a>] Mais ne lisez que les interfaces, vous risqueriez de choper une overdose de <q>bullshits</q></p>
<p>[<a href="http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#rev-pnote-632-3" id="pnote-632-3">3</a>] Ce second paramètre assez obscure n'est pas utilisé par Gautier donc prudence :D</p></div>
http://frederic.praca.free.fr/index.php?post/2013/03/22/Distribution-de-conneries#comment-formhttp://frederic.praca.free.fr/index.php?feed/atom/comments/632Traitement d'images astrourn:md5:120ab6066aa7a289796dcc64848d8e082008-06-20T11:11:00+02:002008-06-20T10:11:26+02:00FredAstronomieCFreeBSDLinux <p>Hier soir, en regardant <a href="http://frederic.praca.free.fr/index.php?ds_gallery/2008/06/01/La-lune-vue-au-travers-du-Konus/dsg_template/default" hreflang="fr">les images de la Lune</a> que j'avais faites il y a quelques temps avec mon téléscope Konus, j'ai trouvé des images assez proches les unes des autres pour tenter mon petit jeu du moment à savoir l'alignement et l'amélioration des images astro. Le résultat se trouve donc dans <a href="http://frederic.praca.free.fr/index.php?ds_gallery/2008/06/19/Un-compositage/dsg_template/default" hreflang="fr">la galerie</a>.<br />
Okay, c'est petit et de qualité médicore mais bon, c'était histoire de dire.<br />
<br />
Emporté par mon élan sur la Toile, j'ai surfé sur les sites d'astro pour arriver sur la page d'<a href="http://www.lin4astro.org/" hreflang="fr">une distribution Linux orientée Astro</a>.<br />
J'ai alors trouvé le site <a href="http://dulle.free.fr/alidade/" hreflang="fr">Alidade</a> avec un soft que je cherchais depuis un moment, un équivalent d'Iris, <a href="http://dulle.free.fr/alidade/siril.php" hreflang="fr">Siril</a>. Le développement a l'air d'être abandonné mais rien ne m'arrêtera et je testerai quand même le truc dès que possible.<br />
Et dire qu'en plus, l'auteur est français et le soft libre ! Que demander de plus pour utiliser et chercher des infos sur le dit soft ?<br />
Bon, il ne reste plus qu'à le porter sur l'OS du bien (TM) mais ça devrait être <em>piece of cake</em> vu que c'est du <a href="http://fr.wikipedia.org/wiki/C_(langage)#Normalisations" hreflang="fr">C ANSI</a>.</p>http://frederic.praca.free.fr/index.php?post/2008/06/20/Traitement-dimages-astro#comment-formhttp://frederic.praca.free.fr/index.php?feed/atom/comments/88Un blog sympaurn:md5:2303b31dff5d8a63c4b29443eaaaf3f72008-05-21T11:24:00+02:002008-05-21T10:27:07+02:00FredDéveloppementAdaCJavaLispObjectiveCPascal <p>Certains le savent, d'autres s'en seront rendus compte, j'ai l'immense plaisir d'être <em>ingénieur informaticien</em>.<br />
Ce status d'être supérieur capable de <a href="http://www.copinedegeek.com/roman_geek/1.html" hreflang="fr">murmurer aux oreilles des PC (et autres ordinateurs)</a> me permet d'être beau, mais avec de moins en moins de cheveux de plus en plus gris, intelligent et d'avoir le poil brillant et la truffe chaude.<br />
<br />
Bon, tout ça pour vous raconter une partie de ma vie passionnante d'informatichien (à sa mémère off course). Dans les langages que j'ai pu étudier, il y a par ordre chronologique :<br /></p>
<ul>
<li>Le <a href="http://fr.wikipedia.org/wiki/Pascal_%28langage%29" hreflang="fr">Pascal</a> (mais <a href="http://fr.wikipedia.org/wiki/Turbo_Pascal" hreflang="fr">Turbo</a>, ça a plus de reprise),</li>
<li>Le <a href="http://fr.wikipedia.org/wiki/C_%28langage%29" hreflang="fr">C</a> (histoire de créer un générateur de fichier core non-aléatoire),</li>
<li>Le <a href="http://fr.wikipedia.org/wiki/C%2B%2B" hreflang="fr">C++</a> (Hum, comme une femme, plus on la connaît, plus c'est compliqué),</li>
<li>Le <a href="http://fr.wikipedia.org/wiki/Lisp" hreflang="fr">Lisp</a> (un bon langage pour extra-terrestres autistes),</li>
<li>Le <a href="http://fr.wikipedia.org/wiki/Java_%28langage%29" hreflang="fr">Java</a> (En version 1.0, s'il vous plaît),</li>
<li>L'<a href="http://fr.wikipedia.org/wiki/Objective_C" hreflang="fr">ObjectiveC</a> (apprentissage perso suite à un article de LinuxMag) et récemment,</li>
<li>L'<a href="http://fr.wikipedia.org/wiki/Ada_%28langage%29" hreflang="fr">Ada</a>.<br /></li>
</ul>
<p><br />
Les gens qui connaissent auront remarqué à quel point tout cela ne suit absolument aucune logique, surtout pour les deux derniers qui ne m'ont pas été imposés et qui sont carrément antagonistes d'un point de vue typage.<br />
Et bien, depuis bientôt trois ans, c'est Ada qui capte mon attention et tout ce qui gravite autour, ce qui m'amène enfin à vous parler de <a href="http://touisteur.info/dotclear/index.php" hreflang="fr">ce blog</a> en <a href="http://emporteunevache.blogspot.com/" hreflang="fr">deux parties</a>, plus très vivant mais avec des infos sympas sur le langage sus-cité.<br />
<br />
Voilà, vous pouvez retourner à vos occupations, merci de m'avoir lu.<br /></p>http://frederic.praca.free.fr/index.php?post/2008/05/21/Un-blog-sympa#comment-formhttp://frederic.praca.free.fr/index.php?feed/atom/comments/22