Salome HOME
daf7394c5f2249cac0d422c13322f8279fd72512
[samples/component.git] / src / TypesCheck / TypesCheck_Impl.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, 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.
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   : TypesCheck_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 "TypesCheck_Impl.hxx"
35
36 using namespace std;
37
38 TypesCheck_Impl::TypesCheck_Impl( CORBA::ORB_ptr orb ,
39                                   PortableServer::POA_ptr poa ,
40                                   PortableServer::ObjectId * contId , 
41                                   const char *instanceName ,
42                                   const char *interfaceName ,
43                                   const bool kactivate ) :
44   Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) {
45   MESSAGE("TypesCheck_Impl::TypesCheck_Impl this " << hex << this << dec
46           << "activate object instanceName("
47           << instanceName << ") interfaceName(" << interfaceName << ")" )
48   if ( kactivate ) {
49     _thisObj = this ;
50     _id = _poa->activate_object(_thisObj);
51   }
52 }
53
54 TypesCheck_Impl::TypesCheck_Impl() {
55   beginService( "TypesCheck_Impl::TypesCheck_Impl" );
56   endService( "TypesCheck_Impl::TypesCheck_Impl" );
57 }
58
59 TypesCheck_Impl::~TypesCheck_Impl() {
60   beginService( "TypesCheck_Impl::~TypesCheck_Impl" );
61   endService( "TypesCheck_Impl::~TypesCheck_Impl" );
62 }
63
64 void TypesCheck_Impl::StringCheck( const char * InString , _CORBA_String_out OutString ) {
65   beginService( "TypesCheck_Impl::StringCheck" );
66   OutString = CORBA::string_dup( InString ) ;
67   endService( "TypesCheck_Impl::StringCheck" );
68 }
69
70 void TypesCheck_Impl::BoolCheck( bool InBool , bool & OutBool ) {
71   beginService( "TypesCheck_Impl::BoolCheck" );
72   OutBool = InBool ;
73   endService( "TypesCheck_Impl::BoolCheck" );
74 }
75
76 void TypesCheck_Impl::CharCheck( unsigned char InChar , unsigned char & OutChar ) {
77   beginService( "TypesCheck_Impl::CharCheck" );
78   OutChar = InChar ;
79   endService( "TypesCheck_Impl::CharCheck" );
80 }
81
82 void TypesCheck_Impl::ShortCheck( short InShort , short & OutShort ) {
83   beginService( "TypesCheck_Impl::ShortCheck" );
84   OutShort = InShort ;
85   endService( "TypesCheck_Impl::ShortCheck" );
86 }
87
88 void TypesCheck_Impl::IntCheck( int InInt , int & OutInt ) {
89   beginService( "TypesCheck_Impl::IntCheck" );
90   OutInt = InInt ;
91   endService( "TypesCheck_Impl::IntCheck" );
92 }
93
94 void TypesCheck_Impl::LongCheck( CORBA::Long InLong , CORBA::Long & OutLong ) {
95   beginService( "TypesCheck_Impl::LongCheck" );
96   int inInt = InLong ;
97   int outInt = OutLong ;
98   IntCheck( inInt , outInt ) ;
99   OutLong = outInt ;
100   endService( "TypesCheck_Impl::LongCheck" );
101 }
102
103 void TypesCheck_Impl::FloatCheck( float InFloat , float & OutFloat ) {
104   beginService( "TypesCheck_Impl::FloatCheck" );
105   OutFloat = InFloat ;
106   endService( "TypesCheck_Impl::FloatCheck" );
107 }
108
109 void TypesCheck_Impl::DoubleCheck( double InDouble , double & OutDouble ) {
110   beginService( "TypesCheck_Impl::DoubleCheck" );
111   OutDouble = InDouble ;
112   endService( "TypesCheck_Impl::DoubleCheck" );
113 }
114
115 void TypesCheck_Impl::ObjRefCheck( SuperVisionTest::Adder_ptr InObjRef , SuperVisionTest::Adder_out OutObjRef ) {
116   beginService( "TypesCheck_Impl::ObjRefCheck" );
117   OutObjRef = SuperVisionTest::Adder::_duplicate( InObjRef ) ;
118   endService( "TypesCheck_Impl::ObjRefCheck" );
119 }
120
121 void TypesCheck_Impl::MiscTypes( const char * InString , bool InBool , unsigned char InChar , short InShort , CORBA::Long InLong , float InFloat , double InDouble , SuperVisionTest::Adder_ptr InObjRef , _CORBA_String_out OutString ,bool & OutBool , unsigned char & OutChar , short & OutShort , CORBA::Long & OutLong , float & OutFloat , double & OutDouble , SuperVisionTest::Adder_out OutObjRef ) {
122   beginService( "TypesCheck_Impl::MiscTypes" );
123   OutString = CORBA::string_dup( InString ) ;
124   OutBool = InBool ;
125   OutChar = InChar ;
126   OutShort = InShort ;
127   OutLong = InLong ;
128   OutFloat = InFloat ;
129   OutDouble = InDouble ;
130   OutObjRef = SuperVisionTest::Adder::_duplicate( InObjRef ) ;
131   endService( "TypesCheck_Impl::MiscTypes" );
132 }
133
134 extern "C"
135 {
136   PortableServer::ObjectId * TypesCheckEngine_factory( CORBA::ORB_ptr orb ,
137                                                        PortableServer::POA_ptr poa , 
138                                                        PortableServer::ObjectId * contId ,
139                                                        const char *instanceName ,
140                                                        const char *interfaceName ) {
141     MESSAGE("TypesCheckEngine_factory TypesCheckEngine ("
142             << instanceName << "," << interfaceName << "," << getpid() << ")");
143     TypesCheck_Impl * myTypesCheck  = new TypesCheck_Impl(orb, poa, contId, instanceName, interfaceName);
144     return myTypesCheck->getId() ;
145   }
146 }
147