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