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