LTP GCOV extension - code coverage report
Current view: directory - src/cpp/prod/lib - request.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 30
Code covered: 90.0 % Executed lines: 27

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/prod/lib/request.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                 : #include <yaorb/CORBA.h>
      23                 : #include <yaorb/YAORB.h>
      24                 : 
      25                 : #include "src/cpp/prod/tool/DEVELOPMENT.h"
      26                 : #include "src/cpp/prod/tool/Assert.h"
      27                 : 
      28                 : #include "src/cpp/prod/protocol/cdr/cdr_fragment.h"
      29                 : #include "src/cpp/prod/protocol/giop/request_header_12.h"
      30                 : #include "src/cpp/prod/CORBA/YARemoteOrb.h"
      31                 : 
      32               4 : YAORB::Request::Request()
      33               4 :  : _cdr(NULL), _giop(), _buffer()
      34                 : {
      35               0 : }
      36                 : 
      37                 : YAORB::CDR*
      38                 : YAORB::Request::init(
      39                 :    const YAORB::Ref & ref,
      40               4 :    const char* operation)
      41                 : {
      42                 :    GIOP12RequestHeader *giopReq = NULL ;
      43                 : 
      44               4 :    YARemoteOrb *remoteOrb = ref.GetRemoteOrb() ;
      45               4 :    const GIOPEncapsulation & encap = ref.GetObjKey() ;
      46                 : 
      47               4 :    CORBA::ULong request_id = remoteOrb->GenRequestId() ;
      48                 :    CORBA::Octet response_flags = 34 ; // FIXME
      49               4 :    GIOPEncapsulation * encap2 = new GIOPEncapsulation(encap) ;
      50               4 :    TargetAddress * target = new TargetAddress(encap2) ;
      51                 : 
      52                 :    giopReq = new GIOP12RequestHeader(
      53                 :       request_id,
      54                 :       response_flags,
      55                 :       *target,
      56               4 :       operation) ;
      57                 : 
      58               4 :    _giop.SetRequest(giopReq) ;
      59                 : 
      60                 :    // FIXME : sizes
      61               4 :    _cdr = new CDRFragment(0, 80, 0, 80) ;
      62                 : 
      63               4 :    _giop.cdr(_cdr) ;
      64                 : 
      65                 :    return _cdr ;
      66                 : }
      67                 : 
      68                 : YAORB::CDR*
      69               0 : YAORB::Request::GetCDR(void)
      70                 : {
      71                 :    return _cdr ;
      72                 : }
      73                 : 
      74                 : void
      75               4 : YAORB::Request::complete()
      76                 : {
      77                 :    int totalSize ;
      78                 :    int msgSize ;
      79                 : 
      80               4 :    totalSize = _cdr->GetPosition() ;
      81                 :    msgSize = totalSize - GIOP_MESSAGE_HEADER_SIZE ;
      82                 : 
      83               4 :    GIOPMessageHeader & header = _giop.GetHeader() ;
      84               4 :    header.SetMessageSize(msgSize) ;
      85                 : 
      86                 :    // Reset the cdr stream, and encode the header again
      87                 :    // so that the message size is updated.
      88               4 :    _cdr->reset(CDR_WRITE) ;
      89               4 :    _giop.cdr_header(_cdr) ;
      90                 : 
      91               4 :    _buffer.resize(totalSize) ;
      92               4 :    CORBA::Octet* data = _buffer.GetData() ;
      93                 : 
      94                 :    // FIXME : copy ==> poor performances
      95               4 :    _cdr->reset(CDR_READ) ;
      96               4 :    _cdr->cdr_OctetArray(data, totalSize) ;
      97                 : 
      98               4 :    delete _cdr ;
      99               4 :    _cdr = NULL ;
     100                 : }
     101                 : 
     102                 : const Buffer &
     103               8 : YAORB::Request::GetBuffer() const
     104                 : {
     105                 :    return _buffer ;
     106                 : }
     107                 : 
     108               4 : YAORB::Request::~Request()
     109                 : {
     110               4 :    NON_DEV("Request") ;
     111               0 : }
     112                 : 

Generated by: LTP GCOV extension version 1.4