Salome HOME
Updated copyright comment
[samples/component.git] / src / SyrComponent / SyrComponent_Impl.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SuperVisionTest SyrComponent : example of component performing some mathinatical operations
24 //  File   : SyrComponent_Impl.cxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SuperVisionTest
27 //
28 #include <stdio.h>
29 #ifndef WIN32
30 #include <unistd.h>
31 #else
32 #include <process.h>
33 #endif
34 #include <fstream>
35 #include <sstream>
36 #include <string>
37
38 #include "COMPONENT_version.h"
39 #include "SyrComponent_Impl.hxx"
40 #include "Adder_Impl.hxx"
41
42 using namespace std;
43
44 SyrComponent_Impl::SyrComponent_Impl( CORBA::ORB_ptr orb ,
45                                       PortableServer::POA_ptr poa ,
46                                       PortableServer::ObjectId * contId , 
47                                       const char *instanceName ,
48                                       const char *interfaceName ,
49                                       const bool kactivate , bool withRegistry ) :
50   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true/*notif is true here for message*/,withRegistry) {
51   MESSAGE("SyrComponent_Impl::SyrComponent_Impl this " << hex << this << dec
52           << "activate object instanceName("
53           << instanceName << ") interfaceName(" << interfaceName << ")" );
54   if ( kactivate ) {
55     _thisObj = this ;
56     _id = _poa->activate_object(_thisObj);
57   }
58 }
59
60 SyrComponent_Impl::SyrComponent_Impl() {
61 }
62
63 SyrComponent_Impl::~SyrComponent_Impl() {
64 }
65
66 char* SyrComponent_Impl::getVersion()
67 {
68 #if COMPONENT_DEVELOPMENT
69   return CORBA::string_dup(COMPONENT_VERSION_STR"dev");
70 #else
71   return CORBA::string_dup(COMPONENT_VERSION_STR);
72 #endif
73 }
74
75 CORBA::Long SyrComponent_Impl::C_ISEVEN( CORBA::Long anInteger ) {
76   bool RetVal ;
77   beginService( " SyrComponent_Impl::C_ISEVEN" );
78   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_ISEVEN is Computing");
79 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
80   int S = 1 ;
81 #ifndef WIN32
82   while ( S ) {
83     S = sleep( S ) ;
84   }
85 #else
86   Sleep(S*1000);
87 #endif
88   RetVal = ( anInteger & 1 ) == 0 ;
89   endService( " SyrComponent_Impl::C_ISEVEN"  );
90   return RetVal ;
91 }
92
93 CORBA::Long SyrComponent_Impl::C_ISONE( CORBA::Long anOddInteger ) {
94   bool RetVal ;
95   beginService( " SyrComponent_Impl::C_ISONE" );
96   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_ISONE is Computing");
97 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
98   int S = 1 ;
99 #ifndef WIN32
100   while ( S ) {
101     S = sleep( S ) ;
102   }
103 #else
104   Sleep(S*1000);
105 #endif
106   RetVal = ( anOddInteger == 1 ) ;
107   endService( " SyrComponent_Impl::C_ISONE"  );
108   return RetVal ;
109 }
110
111 CORBA::Long SyrComponent_Impl::C_M3( CORBA::Long anOddInteger ) {
112   beginService( " SyrComponent_Impl::C_M3" );
113   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_M3 is Computing");
114 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
115   int S = 1 ;
116 #ifndef WIN32
117   while ( S ) {
118     S = sleep( S ) ;
119   }
120 #else
121   Sleep(S*1000);
122 #endif  endService( " SyrComponent_Impl::C_M3"  );
123   if ( C_ISEVEN( anOddInteger ) )
124     return 0 ;
125   return ( 3*anOddInteger ) ;
126 }
127
128 CORBA::Long SyrComponent_Impl::C_M3P1( CORBA::Long anOddInteger ) {
129   beginService( " SyrComponent_Impl::C_M3P1" );
130   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_M3P1 is Computing");
131 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
132   int S = 1 ;
133 #ifndef WIN32
134   while ( S ) {
135     S = sleep( S ) ;
136   }
137 #else
138   Sleep(S*1000);
139 #endif
140   endService( " SyrComponent_Impl::C_M3P1"  );
141   if ( C_ISEVEN( anOddInteger ) )
142     return 0 ;
143   return ( 3*anOddInteger + 1 ) ;
144 }
145
146 CORBA::Long SyrComponent_Impl::C_DIV2( CORBA::Long anEvenInteger ) {
147   beginService( " SyrComponent_Impl::C_DIV2" );
148   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_DIV2 is Computing");
149 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
150   int S = 1 ;
151 #ifndef WIN32
152   while ( S ) {
153     S = sleep( S ) ;
154   }
155 #else
156   Sleep(S*1000);
157 #endif
158   endService( " SyrComponent_Impl::C_DIV2"  );
159   if ( !C_ISEVEN( anEvenInteger ) )
160     return 0 ;
161   return ( anEvenInteger >> 1 ) ;
162 }
163
164 CORBA::Long SyrComponent_Impl::C_INCR( CORBA::Long aCount ) {
165   beginService( " SyrComponent_Impl::C_INCR" );
166   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_INCR is Computing");
167 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
168   int S = 1 ;
169 #ifndef WIN32
170   while ( S ) {
171     S = sleep( S ) ;
172   }
173 #else
174   Sleep(S*1000);
175 #endif
176   endService( " SyrComponent_Impl::C_INCR"  );
177   return ( aCount + 1 ) ;
178 }
179
180 void SyrComponent_Impl::CPP_SETLONG( CORBA::Long aCount ) {
181   beginService( " SyrComponent_Impl::CPP_SETLONG" );
182   sendMessage(NOTIF_STEP, "SyrComponent_Impl::CPP_SETLONG is Computing");
183 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
184   int S = 1 ;
185 #ifndef WIN32
186   while ( S ) {
187     S = sleep( S ) ;
188   }
189 #else
190   Sleep(S*1000);
191 #endif
192   _Count = aCount ;
193   endService( " SyrComponent_Impl::CPP_SETLONG"  );
194   return ;
195 }
196
197 CORBA::Long SyrComponent_Impl::CPP_ADDTOLONG( CORBA::Long anIncr ) {
198   beginService( " SyrComponent_Impl::CPP_ADDTOLONG" );
199   sendMessage(NOTIF_STEP, "SyrComponent_Impl::CPP_ADDTOLONG is Computing");
200 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
201   int S = 1 ;
202 #ifndef WIN32
203   while ( S ) {
204     S = sleep( S ) ;
205   }
206 #else
207   Sleep(S*1000);
208 #endif
209   endService( " SyrComponent_Impl::CPP_ADDTOLONG"  );
210   return ( _Count + anIncr ) ;
211 }
212
213 CORBA::Long SyrComponent_Impl::C_MIN( CORBA::Long aMinVal , CORBA::Long anInteger ) {
214   beginService( " SyrComponent_Impl::C_MIN" );
215   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_MIN is Computing");
216 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
217   int S = 1 ;
218 #ifndef WIN32
219   while ( S ) {
220     S = sleep( S ) ;
221   }
222 #else
223   Sleep(S*1000);
224 #endif
225   int min = aMinVal ;
226   if ( anInteger < min || aMinVal == 0 ) {
227     min = anInteger ;
228   }
229   string trace = "SyrComponent_Impl::C_MIN : " ;
230   char cmin[ 30 ] ;
231   sprintf( cmin , "%d" , min ) ;
232   trace += cmin ;
233   sendMessage(NOTIF_TRACE, trace.c_str() );
234   endService( " SyrComponent_Impl::C_MIN"  );
235   return min ;
236 }
237
238 CORBA::Long SyrComponent_Impl::C_MAX( CORBA::Long aMaxVal , CORBA::Long anInteger ) {
239   beginService( " SyrComponent_Impl::C_MAX" );
240   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_MAX is Computing");
241 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
242   int S = 1 ;
243 #ifndef WIN32
244   while ( S ) {
245     S = sleep( S ) ;
246   }
247 #else
248   Sleep(S*1000);
249 #endif
250   int max = aMaxVal ;
251   if ( anInteger > max ) {
252     max = anInteger ;
253   }
254   string trace = "SyrComponent_Impl::C_MAX : " ;
255   char cmax[ 30 ] ;
256   sprintf( cmax , "%d" , max ) ;
257   trace += cmax ;
258   sendMessage(NOTIF_TRACE, trace.c_str() );
259   endService( " SyrComponent_Impl::C_MAX"  );
260   return max ;
261 }
262
263 SuperVisionTest::ListOfSyr_ptr SyrComponent_Impl::C_LISTOFSYR() {
264   beginService( " SyrComponent_Impl::C_LISTOFSYR" );
265   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_LISTOFSYR is Computing");
266 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
267   int S = 1 ;
268 #ifndef WIN32
269   while ( S ) {
270     S = sleep( S ) ;
271   }
272 #else
273   Sleep(S*1000);
274 #endif
275   ListOfSyr_Impl * aNewListOfSyr = nullptr;
276   Engines::Container_var cont = this->GetContainerRef();
277   if( cont->is_SSL_mode() )
278   {
279     aNewListOfSyr = new ListOfSyr_Impl_SSL( _orb , _poa, _contId,
280                         instanceName() , interfaceName() ,
281                         graphName() , nodeName() ) ;
282   }
283   else
284   {
285     aNewListOfSyr = new ListOfSyr_Impl_No_SSL( _orb , _poa, _contId,
286                         instanceName() , interfaceName() ,
287                         graphName() , nodeName() ) ;
288   }
289   SuperVisionTest::ListOfSyr_var iobject = (SuperVisionTest::ListOfSyr_var ) NULL ;
290   PortableServer::ObjectId * id = aNewListOfSyr->getId() ;
291   CORBA::Object_var obj = _poa->id_to_reference(*id);
292   iobject = SuperVisionTest::ListOfSyr::_narrow(obj) ;
293   endService( " SyrComponent_Impl::C_LISTOFSYR"  );
294   return SuperVisionTest::ListOfSyr::_duplicate( iobject ) ;
295 //  return ( aNewListOfSyr._retn() ) ;
296 }
297
298 SuperVisionTest::ListOfSyr_ptr SyrComponent_Impl::C_AVERAGE(
299                        SuperVisionTest::ListOfSyr_ptr aListOfSyr ,
300                        CORBA::Long anInteger ,
301                        CORBA::Long aCount ,
302                        CORBA::Double & anAverage ) {
303   beginService( " SyrComponent_Impl::C_AVERAGE" );
304   sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_AVERAGE is Computing");
305 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
306   int S = 1 ;
307 #ifndef WIN32
308   while ( S ) {
309     S = sleep( S ) ;
310   }
311 #else
312   Sleep(S*1000);
313 #endif
314   SuperVisionTest::SeqOfSyr * aSeqOfSyr = aListOfSyr->GetSeqOfSyr() ;
315   int len = aSeqOfSyr->length() ;
316   aSeqOfSyr->length( len + 1 ) ;
317   (*aSeqOfSyr)[ len ] = anInteger ;
318   aListOfSyr->SetSeqOfSyr( *aSeqOfSyr ) ;
319   anAverage = 0 ;
320   int i ;
321   for ( i = 0 ; i < len + 1 ; i++ ) {
322     anAverage += (*aSeqOfSyr)[ i ] ;
323   }
324   anAverage = anAverage / ( len + 1 ) ;
325   string end = " SyrComponent_Impl::C_AVERAGE " ;
326   char caverage[ 30 ] ;
327   sprintf( caverage , "%fd" , anAverage ) ;
328   end += caverage ;
329   endService( end.c_str() );
330   return SuperVisionTest::ListOfSyr::_duplicate( aListOfSyr ) ;
331 }
332
333 SuperVisionTest::Syr_ptr SyrComponent_Impl::Init( CORBA::Long anOddInteger ) {
334   beginService( "SyrComponent_Impl::Init" );
335   sendMessage(NOTIF_STEP, "SyrComponent_Impl creates Syr_Impl");
336 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
337   int S = 1 ;
338 #ifndef WIN32
339   while ( S ) {
340     S = sleep( S ) ;
341   }
342 #else
343   Sleep(S*1000);
344 #endif
345   Syr_Impl * mySyr = nullptr;
346   if ( this->isSSLMode() )
347   {
348     mySyr = new Syr_Impl_SSL( _orb , _poa, _contId,
349                         instanceName() , interfaceName() ,
350                         graphName() , nodeName() , anOddInteger ) ;
351   }
352   else
353   {
354     mySyr = new Syr_Impl_No_SSL( _orb , _poa, _contId,
355                         instanceName() , interfaceName() ,
356                         graphName() , nodeName() , anOddInteger ) ;
357   }
358   SuperVisionTest::Syr_var iobject = (SuperVisionTest::Syr_var ) NULL ;
359   PortableServer::ObjectId * id = mySyr->getId() ;
360   CORBA::Object_var obj = _poa->id_to_reference(*id);
361   iobject = SuperVisionTest::Syr::_narrow(obj) ;
362   endService( "SyrComponent_Impl::Init" );
363   return SuperVisionTest::Syr::_duplicate(iobject) ;
364 }
365
366 ListOfSyr_Impl::ListOfSyr_Impl( CORBA::ORB_ptr orb ,
367                     PortableServer::POA_ptr poa ,
368                     PortableServer::ObjectId * contId , 
369                     const char * instanceName ,
370                     const char * interfaceName , 
371                     const char * graphName ,
372                     const char * nodeName, bool withRegistry) :
373   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,withRegistry) {
374   Names( graphName , nodeName ) ;
375   MESSAGE("ListOfSyr_Impl::ListOfSyr_Impl activate object instanceName("
376           << instanceName << ") interfaceName(" << interfaceName << ") --> "
377           << hex << (void *) this << dec );
378   beginService( "ListOfSyr_Impl::ListOfSyr_Impl" );
379   _thisObj = this ;
380   _id = _poa->activate_object(_thisObj);
381   sendMessage(NOTIF_STEP, "ListOfSyr_Impl is Created");
382   endService( "ListOfSyr_Impl::ListOfSyr_Impl" );
383 }
384
385 ListOfSyr_Impl::ListOfSyr_Impl() {
386 }
387
388 ListOfSyr_Impl::~ListOfSyr_Impl() {
389   beginService( "ListOfSyr_Impl::~ListOfSyr_Impl" );
390   endService( "ListOfSyr_Impl::~ListOfSyr_Impl" );
391 }
392
393 char* ListOfSyr_Impl::getVersion()
394 {
395 #if COMPONENT_DEVELOPMENT
396   return CORBA::string_dup(COMPONENT_VERSION_STR"dev");
397 #else
398   return CORBA::string_dup(COMPONENT_VERSION_STR);
399 #endif
400 }
401
402 SuperVisionTest::SeqOfSyr * ListOfSyr_Impl::GetSeqOfSyr() {
403   SuperVisionTest::SeqOfSyr_var aSeqOfSyr = new SuperVisionTest::SeqOfSyr( _SeqOfSyr ) ;
404   return ( aSeqOfSyr._retn() ) ;
405 }
406
407 void ListOfSyr_Impl::SetSeqOfSyr( const SuperVisionTest::SeqOfSyr & aSeqOfSyr ) {
408   _SeqOfSyr = aSeqOfSyr ;
409   return ;
410 }
411
412 extern "C"
413 {
414   PortableServer::ObjectId * SyrComponentEngine_factory
415      (CORBA::ORB_ptr orb,
416       PortableServer::POA_ptr poa, 
417       PortableServer::ObjectId * contId,
418       const char *instanceName,
419       const char *interfaceName)
420   {
421 #ifndef WIN32
422     MESSAGE("SyrComponentEngine_factory SyrComponentEngine ("
423             << instanceName << "," << interfaceName << "," << getpid() << ")");
424 #else
425     MESSAGE("SyrComponentEngine_factory SyrComponentEngine ("
426             << instanceName << "," << interfaceName << "," << _getpid() << ")");
427 #endif
428     SyrComponent_Impl * mySyrComponent = nullptr;
429     CORBA::Object_var o = poa->id_to_reference(*contId);
430     Engines::Container_var cont = Engines::Container::_narrow(o);
431     if(cont->is_SSL_mode())
432     {
433       mySyrComponent = new SyrComponent_Impl_SSL(orb, poa, contId, instanceName, interfaceName);
434     }
435     else
436     {
437       mySyrComponent = new SyrComponent_Impl_No_SSL(orb, poa, contId, instanceName, interfaceName);
438     }
439     return mySyrComponent->getId() ;
440   }
441 }
442
443 Syr_Impl::Syr_Impl( CORBA::ORB_ptr orb ,
444                     PortableServer::POA_ptr poa ,
445                     PortableServer::ObjectId * contId , 
446                     const char * instanceName ,
447                     const char * interfaceName , 
448                     const char * graphName ,
449                     const char * nodeName ,
450                     const CORBA::Long anOddInteger, bool withRegistry) :
451   SyrComponent_Impl(orb, poa, contId, instanceName, interfaceName,false,withRegistry) {
452   Names( graphName , nodeName ) ;
453   MESSAGE("Syr_Impl::Syr_Impl activate object instanceName("
454           << instanceName << ") interfaceName(" << interfaceName << ") --> "
455           << hex << (void *) this << dec );
456   beginService( "Syr_Impl::Syr_Impl" );
457   _thisObj = this ;
458   _id = _poa->activate_object(_thisObj);
459   _InitialInteger = anOddInteger ;
460   _CurrentInteger = anOddInteger ;
461   _Count = 0 ;
462   sendMessage(NOTIF_STEP, "Syr_Impl is Created");
463   endService( "Syr_Impl::Syr_Impl" );
464 }
465
466 Syr_Impl::Syr_Impl() {
467 }
468
469 Syr_Impl::~Syr_Impl() {
470   beginService( "Syr_Impl::~Syr_Impl" );
471   endService( "Syr_Impl::~Syr_Impl" );
472 }
473
474 CORBA::Long Syr_Impl::Initial() {
475   beginService( " Syr_Impl::Initial" );
476   sendMessage(NOTIF_STEP, "Syr_Impl::Initial is Computing");
477 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
478   int S = 1 ;
479 #ifndef WIN32
480   while ( S ) {
481     S = sleep( S ) ;
482   }
483 #else
484   Sleep(S*1000);
485 #endif
486   endService( " Syr_Impl::Initial"  );
487   return _InitialInteger ;
488 }
489
490 CORBA::Long Syr_Impl::Current() {
491   beginService( " Syr_Impl::Current" );
492   sendMessage(NOTIF_STEP, "Syr_Impl::Current is Computing");
493 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
494   int S = 1 ;
495 #ifndef WIN32
496   while ( S ) {
497     S = sleep( S ) ;
498   }
499 #else
500   Sleep(S*1000);
501 #endif
502   endService( " Syr_Impl::Current"  );
503   return _CurrentInteger ;
504 }
505
506 CORBA::Long Syr_Impl::IsEven() {
507   bool RetVal ;
508   beginService( " Syr_Impl::IsEven" );
509   sendMessage(NOTIF_STEP, "Syr_Impl::IsEven is Computing");
510 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
511   int S = 1 ;
512 #ifndef WIN32
513   while ( S ) {
514     S = sleep( S ) ;
515   }
516 #else
517   Sleep(S*1000);
518 #endif
519   RetVal = ( _CurrentInteger & 1 ) == 0 ;
520   MESSAGE( " Syr_Impl::IsEven " << _CurrentInteger << " " << RetVal );
521   endService( " Syr_Impl::IsEven"  );
522   return RetVal ;
523 }
524
525 CORBA::Long Syr_Impl::IsOne() {
526   bool RetVal ;
527   beginService( " Syr_Impl::IsOne" );
528   sendMessage(NOTIF_STEP, "Syr_Impl::IsOne is Computing");
529 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
530   int S = 1 ;
531 #ifndef WIN32
532   while ( S ) {
533     S = sleep( S ) ;
534   }
535 #else
536   Sleep(S*1000);
537 #endif
538   RetVal = ( _CurrentInteger == 1 ) ;
539   MESSAGE( " Syr_Impl::IsOne " << _CurrentInteger << " " << RetVal );
540   endService( " Syr_Impl::IsOne"  );
541   return RetVal ;
542 }
543
544 CORBA::Long Syr_Impl::Count() {
545   beginService( " Syr_Impl::Count" );
546   sendMessage(NOTIF_STEP, "Syr_Impl::Count is Computing");
547 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
548   int S = 1 ;
549 #ifndef WIN32
550   while ( S ) {
551     S = sleep( S ) ;
552   }
553 #else
554   Sleep(S*1000);
555 #endif
556   MESSAGE( " Syr_Impl::Count " << _Count );
557   endService( " Syr_Impl::Count"  );
558   return _Count ;
559 }
560
561 void Syr_Impl::M3p1() {
562   beginService( " Syr_Impl::M3p1" );
563   sendMessage(NOTIF_STEP, "Syr_Impl::M3p1 is Computing");
564 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
565   int S = 1 ;
566 #ifndef WIN32
567   while ( S ) {
568     S = sleep( S ) ;
569   }
570 #else
571   Sleep(S*1000);
572 #endif
573   if ( IsEven() )
574     _CurrentInteger = 0 ;
575   else
576     _CurrentInteger = 3*_CurrentInteger + 1 ;
577   MESSAGE( " Syr_Impl::M3p1 " << _CurrentInteger );
578   endService( " Syr_Impl::M3p1"  );
579 }
580
581 void Syr_Impl::Div2() {
582   beginService( " Syr_Impl::Div2" );
583   sendMessage(NOTIF_STEP, "Syr_Impl::Div2 is Computing");
584 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
585   int S = 1 ;
586 #ifndef WIN32
587   while ( S ) {
588     S = sleep( S ) ;
589   }
590 #else
591   Sleep(S*1000);
592 #endif
593   if ( !IsEven() )
594     _CurrentInteger = 0 ;
595   else
596     _CurrentInteger = ( _CurrentInteger >> 1 ) ;
597   MESSAGE( " Syr_Impl::Div2 " << _CurrentInteger );
598   endService( " Syr_Impl::Div2"  );
599 }
600
601 void Syr_Impl::Incr() {
602   beginService( " Syr_Impl::Incr" );
603   sendMessage(NOTIF_STEP, "Syr_Impl::Incr is Computing");
604 //  int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0));
605   int S = 1 ;
606 #ifndef WIN32
607   while ( S ) {
608     S = sleep( S ) ;
609   }
610 #else
611   Sleep(S*1000);
612 #endif
613   _Count = _Count + 1 ;
614   MESSAGE( " Syr_Impl::Incr " << _Count );
615   endService( " Syr_Impl::Incr"  );
616 }
617
618
619