1 : //=============================================================================
2 : // File <$/src/cpp/prod/CORBA/YARemoteOrb.cpp>
3 : // This file is part of YaOrb : Yet Another Object Request Broker,
4 : // Copyright (c) 2000-2003, Marc Alff.
5 : //
6 : // This program is free software; you can redistribute it and/or
7 : // modify it under the terms of the GNU General Public License
8 : // as published by the Free Software Foundation; either version 2
9 : // of the License, or (at your option) any later version.
10 : //
11 : // This program 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
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License
17 : // along with this program; if not, write to the Free Software
18 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 : //
20 : //=============================================================================
21 :
22 : // Portability
23 : #include "yaorb/config.h"
24 : #include "src/cpp/prod/port/port_unistd.h"
25 :
26 : #include <yaorb/CORBA.h>
27 :
28 : #include "src/cpp/prod/CORBA/YARemoteOrb.h"
29 : #include "src/cpp/prod/com/SocketCom.h"
30 : #include "src/cpp/prod/com/buffer.h"
31 :
32 : YARemoteOrb::YARemoteOrb(
33 : const char * host,
34 4 : int port)
35 : : _host(host),
36 : _port(port),
37 : _requestId(0),
38 4 : _com(NULL)
39 : {
40 : }
41 :
42 0 : YARemoteOrb::~YARemoteOrb()
43 : {
44 0 : }
45 :
46 : CORBA::ULong
47 4 : YARemoteOrb::GenRequestId()
48 : {
49 4 : return _requestId ++ ;
50 : }
51 :
52 : void
53 : YARemoteOrb::call(
54 : const YAORB::Request & request,
55 4 : YAORB::Reply & reply)
56 : {
57 4 : const Buffer & reqBuf = request.GetBuffer() ;
58 : // FIXME : Buffer & repBuf = reply.GetBuffer() ;
59 :
60 4 : if (_com == NULL)
61 : {
62 4 : openCom() ;
63 : }
64 :
65 4 : _com->WriteBuffer(reqBuf) ;
66 : // FIXME : _com->ReadBuffer(repBuf) ;
67 :
68 : return ;
69 : }
70 :
71 : void
72 4 : YARemoteOrb::openCom()
73 : {
74 4 : _com = new SocketCom(_host, _port) ;
75 : }
76 :
77 : void
78 0 : YARemoteOrb::closeCom()
79 : {
80 0 : if (_com != NULL)
81 : {
82 0 : delete _com ;
83 0 : _com = NULL ;
84 : }
85 : }
86 :
|