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