sources:
Aufgabe2.cpp (7.7k)
Aufgabe2.h (2.9k)
Client.cpp (1.8k)
Helper.h (741 bytes)
Server.cpp (3.7k)
aufgabe2.idl (85 bytes)


website:
more info here
studies/corba/Corba-Code3/Aufgabe2.cpp
download file

  1 /* * MICO --- an Open Source CORBA implementation * Copyright (c) 1997-2001 by The Mico Team * * This file was automatically generated. DO NOT EDIT! */
  2
  3 #include "aufgabe2.h"
  4
  5
  6 using namespace std;
  7
  8 //--------------------------------------------------------
  9 // Implementation of stubs
 10 //--------------------------------------------------------
 11
 12 /* * Base interface for class Server */
 13
 14 Aufgabe2::Server::~Server()
 15 {
 16 }
 17
 18 void *
 19 Aufgabe2::Server::_narrow_helper( const char *_repoid )
 20 {
 21   if( strcmp( _repoid, "IDL:Aufgabe2/Server:1.0" ) == 0 )
 22     return (void *)this;
 23   return NULL;
 24 }
 25
 26 Aufgabe2::Server_ptr
 27 Aufgabe2::Server::_narrow( CORBA::Object_ptr _obj )
 28 {
 29   Aufgabe2::Server_ptr _o;
 30   if( !CORBA::is_nil( _obj ) ) {
 31     void *_p;
 32     if( (_p = _obj->_narrow_helper( "IDL:Aufgabe2/Server:1.0" )))
 33       return _duplicate( (Aufgabe2::Server_ptr) _p );
 34     if (!strcmp (_obj->_repoid(), "IDL:Aufgabe2/Server:1.0") || _obj->_is_a_remote ("IDL:Aufgabe2/Server:1.0")) {
 35       _o = new Aufgabe2::Server_stub;
 36       _o->MICO_SCOPE(CORBA,Object::operator=)( *_obj );
 37       return _o;
 38     }
 39   }
 40   return _nil();
 41 }
 42
 43 Aufgabe2::Server_ptr
 44 Aufgabe2::Server::_narrow( CORBA::AbstractBase_ptr _obj )
 45 {
 46   return _narrow (_obj->_to_object());
 47 }
 48
 49 class _Marshaller_Aufgabe2_Server : public CORBA::StaticTypeInfo {
 50     typedef Aufgabe2::Server_ptr _MICO_T;
 51   public:
 52     StaticValueType create () const;
 53     void assign (StaticValueType dst, const StaticValueType src) const;
 54     void free (StaticValueType) const;
 55     void release (StaticValueType) const;
 56     CORBA::Boolean demarshal (CORBA::DataDecoder&, StaticValueType) const;
 57     void marshal (CORBA::DataEncoder &, StaticValueType) const;
 58 };
 59
 60
 61 CORBA::StaticValueType _Marshaller_Aufgabe2_Server::create() const
 62 {
 63   return (StaticValueType) new _MICO_T( 0 );
 64 }
 65
 66 void _Marshaller_Aufgabe2_Server::assign( StaticValueType d, const StaticValueType s ) const
 67 {
 68   *(_MICO_T*) d = ::Aufgabe2::Server::_duplicate( *(_MICO_T*) s );
 69 }
 70
 71 void _Marshaller_Aufgabe2_Server::free( StaticValueType v ) const
 72 {
 73   CORBA::release( *(_MICO_T *) v );
 74   delete (_MICO_T*) v;
 75 }
 76
 77 void _Marshaller_Aufgabe2_Server::release( StaticValueType v ) const
 78 {
 79   CORBA::release( *(_MICO_T *) v );
 80 }
 81
 82 CORBA::Boolean _Marshaller_Aufgabe2_Server::demarshal( CORBA::DataDecoder &dc, StaticValueType v ) const
 83 {
 84   CORBA::Object_ptr obj;
 85   if (!CORBA::_stc_Object->demarshal(dc, &obj))
 86     return FALSE;
 87   *(_MICO_T *) v = ::Aufgabe2::Server::_narrow( obj );
 88   CORBA::Boolean ret = CORBA::is_nil (obj) || !CORBA::is_nil (*(_MICO_T *)v);
 89   CORBA::release (obj);
 90   return ret;
 91 }
 92
 93 void _Marshaller_Aufgabe2_Server::marshal( CORBA::DataEncoder &ec, StaticValueType v ) const
 94 {
 95   CORBA::Object_ptr obj = *(_MICO_T *) v;
 96   CORBA::_stc_Object->marshal( ec, &obj );
 97 }
 98
 99 CORBA::StaticTypeInfo *_marshaller_Aufgabe2_Server;
100
101
102 /* * Stub interface for class Server */
103
104 Aufgabe2::Server_stub::~Server_stub()
105 {
106 }
107
108 #ifndef MICO_CONF_NO_POA
109
110 void *
111 POA_Aufgabe2::Server::_narrow_helper (const char * repoid)
112 {
113   if (strcmp (repoid, "IDL:Aufgabe2/Server:1.0") == 0) {
114     return (void *) this;
115   }
116   return NULL;
117 }
118
119 POA_Aufgabe2::Server *
120 POA_Aufgabe2::Server::_narrow (PortableServer::Servant serv)
121 {
122   void * p;
123   if ((p = serv->_narrow_helper ("IDL:Aufgabe2/Server:1.0")) != NULL) {
124     serv->_add_ref ();
125     return (POA_Aufgabe2::Server *) p;
126   }
127   return NULL;
128 }
129
130 Aufgabe2::Server_stub_clp::Server_stub_clp ()
131 {
132 }
133
134 Aufgabe2::Server_stub_clp::Server_stub_clp (PortableServer::POA_ptr poa, CORBA::Object_ptr obj)
135   : MICO_SCOPE(PortableServer,StubBase) (poa), MICO_SCOPE(CORBA,Object) (*obj)
136 {
137 }
138
139 Aufgabe2::Server_stub_clp::~Server_stub_clp ()
140 {
141 }
142
143 #endif // MICO_CONF_NO_POA
144
145 char* Aufgabe2::Server_stub::reverse( const char* _par_message )
146 {
147   CORBA::StaticAny _sa_message( CORBA::_stc_string, &_par_message );
148   char* _res;
149   CORBA::StaticAny __res( CORBA::_stc_string, &_res );
150
151   CORBA::StaticRequest __req( this, "reverse" );
152   __req.add_in_arg( &_sa_message );
153   __req.set_result( &__res );
154
155   __req.invoke();
156
157   mico_sii_throw( &__req,
158     0)
;
159   return _res;
160 }
161
162
163 #ifndef MICO_CONF_NO_POA
164
165 char*
166 Aufgabe2::Server_stub_clp::reverse( const char* _par_message )
167 {
168   PortableServer::Servant _serv = _preinvoke ();
169   if (_serv) {
170     POA_Aufgabe2::Server * _myserv = POA_Aufgabe2::Server::_narrow (_serv);
171     if (_myserv) {
172       char* __res;
173
174       #ifdef HAVE_EXCEPTIONS
175       try {
176       #endif
177         __res = _myserv->reverse(_par_message);
178       #ifdef HAVE_EXCEPTIONS
179       }
180       catch (...) {
181         _myserv->_remove_ref();
182         _postinvoke();
183         throw;
184       }
185       #endif
186
187       _myserv->_remove_ref();
188       _postinvoke ();
189       return __res;
190     }
191     _postinvoke ();
192   }
193
194   typedef Aufgabe2::Server_stub _VCHACK__classname;
195   return _VCHACK__classname::reverse(_par_message);
196 }
197
198 #endif // MICO_CONF_NO_POA
199
200 struct __tc_init_AUFGABE2 {
201   __tc_init_AUFGABE2()
202   {
203     _marshaller_Aufgabe2_Server = new _Marshaller_Aufgabe2_Server;
204   }
205 };
206
207 static __tc_init_AUFGABE2 __init_AUFGABE2;
208
209 //--------------------------------------------------------
210 // Implementation of skeletons
211 //--------------------------------------------------------
212
213 // PortableServer Skeleton Class for interface Aufgabe2::Server
214 POA_Aufgabe2::Server::~Server()
215 {
216 }
217
218 ::Aufgabe2::Server_ptr
219 POA_Aufgabe2::Server::_this ()
220 {
221   CORBA::Object_var obj = MICO_SCOPE(PortableServer,ServantBase::_this) ();
222   return ::Aufgabe2::Server::_narrow (obj);
223 }
224
225 CORBA::Boolean
226 POA_Aufgabe2::Server::_is_a (const char * repoid)
227 {
228   if (strcmp (repoid, "IDL:Aufgabe2/Server:1.0") == 0) {
229     return TRUE;
230   }
231   return FALSE;
232 }
233
234 CORBA::InterfaceDef_ptr
235 POA_Aufgabe2::Server::_get_interface ()
236 {
237   CORBA::InterfaceDef_ptr ifd = MICO_SCOPE(PortableServer,ServantBase)::_get_interface ("IDL:Aufgabe2/Server:1.0");
238
239   if (CORBA::is_nil (ifd)) {
240     mico_throw (CORBA::OBJ_ADAPTER (0, CORBA::COMPLETED_NO));
241   }
242
243   return ifd;
244 }
245
246 CORBA::RepositoryId
247 POA_Aufgabe2::Server::_primary_interface (const PortableServer::ObjectId &, PortableServer::POA_ptr)
248 {
249   return CORBA::string_dup ("IDL:Aufgabe2/Server:1.0");
250 }
251
252 CORBA::Object_ptr
253 POA_Aufgabe2::Server::_make_stub (PortableServer::POA_ptr poa, CORBA::Object_ptr obj)
254 {
255   return new ::Aufgabe2::Server_stub_clp (poa, obj);
256 }
257
258 bool
259 POA_Aufgabe2::Server::dispatch (CORBA::StaticServerRequest_ptr __req)
260 {
261   #ifdef HAVE_EXCEPTIONS
262   try {
263   #endif
264     if( strcmp( __req->op_name(), "reverse" ) == 0 ) {
265       CORBA::String_var _par_message;
266       CORBA::StaticAny _sa_message( CORBA::_stc_string, &_par_message._for_demarshal() );
267
268       char* _res;
269       CORBA::StaticAny __res( CORBA::_stc_string, &_res );
270       __req->add_in_arg( &_sa_message );
271       __req->set_result( &__res );
272
273       if( !__req->read_args() )
274         return true;
275
276       _res = reverse( _par_message.inout() );
277       __req->write_results();
278       CORBA::string_free( _res );
279       return true;
280     }
281   #ifdef HAVE_EXCEPTIONS
282   } catch( CORBA::SystemException_catch &_ex ) {
283     __req->set_exception( _ex->_clone() );
284     __req->write_results();
285     return true;
286   } catch( ... ) {
287     CORBA::UNKNOWN _ex (CORBA::OMGVMCID | 1, CORBA::COMPLETED_MAYBE);
288     __req->set_exception (_ex->_clone());
289     __req->write_results ();
290     return true;
291   }
292   #endif
293
294   return false;
295 }
296
297 void
298 POA_Aufgabe2::Server::invoke (CORBA::StaticServerRequest_ptr __req)
299 {
300   if (dispatch (__req)) {
301       return;
302   }
303
304   CORBA::Exception * ex =
305     new CORBA::BAD_OPERATION (0, CORBA::COMPLETED_NO);
306   __req->set_exception (ex);
307   __req->write_results();
308 }
309
310