Salome HOME
Modify the version number of SALOME: 2.2.0.
[samples/component.git] / src / DataStreamComponent / DataStreamComponent_Impl.cxx
1 //  SuperVisionTest DataStreamComponent : example
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataStreamComponent_Impl.cxx
25 //  Author : Jean Rahuel
26 //  Module : SuperVisionTest
27
28 using namespace std;
29 #include <stdio.h>
30 #include <unistd.h>
31 #include <fstream>
32 #include <sstream>
33 #include <string>
34
35 #include "DataStreamComponent_Impl.hxx"
36
37 DataStreamFactory_Impl::DataStreamFactory_Impl( CORBA::ORB_ptr orb,
38                                                 PortableServer::POA_ptr poa,
39                                                 PortableServer::ObjectId * contId, 
40                                                 const char *instanceName,
41                                                 const char *interfaceName) :
42   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) {
43   MESSAGE("DataStreamFactory_Impl::DataStreamFactory_Impl this " << hex << this << dec
44           << "activate object instanceName("
45           << instanceName << ") interfaceName(" << interfaceName << ")" )
46   _thisObj = this ;
47   _id = _poa->activate_object(_thisObj);
48 }
49
50 DataStreamFactory_Impl::DataStreamFactory_Impl() {
51 }
52
53 DataStreamFactory_Impl::~DataStreamFactory_Impl() {
54 }
55
56 void DataStreamFactory_Impl::Setxy( const long x , const long y ) {
57   _x = x ;
58   _y = y ;
59 }
60
61 void DataStreamFactory_Impl::Getxy( long & x , long & y ) {
62   x = _x ;
63   y = _y ;
64 }
65
66 void DataStreamFactory_Impl::Add( const long x , const long y , long & z ) {
67   z = x+y ;
68 }
69 void DataStreamFactory_Impl::Sub( const long x , const long y , long & z ) {
70   z = x-y ;
71 }
72 void DataStreamFactory_Impl::Mul( const long x , const long y , long & z ) {
73   z = x*y ;
74 }
75 void DataStreamFactory_Impl::Div( const long x , const long y , long & z ) {
76   z = x/y ;
77 }
78
79 DataStreamComponent::DataStream_ptr DataStreamFactory_Impl::NewDataStream() {
80   beginService( "DataStreamFactory_Impl::NewDataStream" );
81   sendMessage(NOTIF_STEP, "DataStreamFactory_Impl creates DataStream_Impl");
82   DataStream_Impl * myDataStream ;
83   myDataStream = new DataStream_Impl( _orb , _poa, _contId,
84                                       instanceName() , interfaceName() ,
85                                       graphName() , nodeName() ) ;
86   DataStreamComponent::DataStream_var iobject ;
87   PortableServer::ObjectId * id = myDataStream->getId() ;
88   CORBA::Object_var obj = _poa->id_to_reference(*id);
89   iobject = DataStreamComponent::DataStream::_narrow(obj) ;
90   endService( "DataStreamFactory_Impl::NewDataStream" );
91   return DataStreamComponent::DataStream::_duplicate(iobject) ;
92 }
93
94 extern "C"
95 {
96   PortableServer::ObjectId * DataStreamFactoryEngine_factory
97      (CORBA::ORB_ptr orb,
98       PortableServer::POA_ptr poa, 
99       PortableServer::ObjectId * contId,
100       const char *instanceName,
101       const char *interfaceName)
102   {
103     MESSAGE("DataStreamFactoryEngine_factory DataStreamFactoryEngine ("
104             << instanceName << "," << interfaceName << "," << getpid() << ")");
105     DataStreamFactory_Impl * myDataStreamFactory 
106       = new DataStreamFactory_Impl(orb, poa, contId, instanceName, interfaceName);
107     return myDataStreamFactory->getId() ;
108   }
109 }
110
111 DataStream_Impl::DataStream_Impl( CORBA::ORB_ptr orb ,
112                                   PortableServer::POA_ptr poa ,
113                                   PortableServer::ObjectId * contId , 
114                                   const char * instanceName ,
115                                   const char * interfaceName , 
116                                   const char * graphName ,
117                                   const char * nodeName ) :
118   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) {
119   Names( graphName , nodeName ) ;
120   MESSAGE("DataStream_Impl::DataStream_Impl activate object instanceName("
121           << instanceName << ") interfaceName(" << interfaceName << ") --> "
122           << hex << (void *) this << dec )
123   beginService( "DataStream_Impl::DataStream_Impl" );
124   _thisObj = this ;
125   _id = _poa->activate_object(_thisObj);
126   sendMessage(NOTIF_STEP, "DataStream_Impl is Created");
127   endService( "DataStream_Impl::DataStream_Impl" );
128 }
129
130 DataStream_Impl::DataStream_Impl() {
131 }
132
133 DataStream_Impl::~DataStream_Impl() {
134   beginService( "DataStream_Impl::~DataStream_Impl" );
135   endService( "DataStream_Impl::~DataStream_Impl" );
136 }
137
138 void DataStream_Impl::StreamSetxy( const long x , const long y ) {
139   _x = x ;
140   _y = y ;
141 }
142
143 void DataStream_Impl::StreamGetxy( long & x , long & y ) {
144   x = _x ;
145   y = _y ;
146 }
147
148 void DataStream_Impl::StreamAdd( const long x , const long y , long & z ) {
149   z = x+y ;
150 }
151 void DataStream_Impl::StreamSub( const long x , const long y , long & z ) {
152   z = x-y ;
153 }
154 void DataStream_Impl::StreamMul( const long x , const long y , long & z ) {
155   z = x*y ;
156 }
157 void DataStream_Impl::StreamDiv( const long x , const long y , long & z ) {
158   z = x/y ;
159 }
160