LTP GCOV extension - code coverage report
Current view: directory - test/cpp/app - client.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 24
Code covered: 79.2 % Executed lines: 19

       1                 : //==============================================================================
       2                 : // File <$/test/cpp/app/client.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 <stdio.h>
      27                 : #include <iostream>
      28                 : #include <yaorb/CORBA.h>
      29                 : 
      30                 : #include <CosNaming.h>
      31                 : 
      32               4 : int main(int argc, char *argv[])
      33                 : {
      34                 :    try
      35                 :    {
      36               4 :       int _argc = 5 ;
      37               4 :       char *_argv[] = { "client", "-ORBId", "App", "-ORBModel", "Client" } ;
      38                 : 
      39               4 :       CORBA::ORB_var myOrb = CORBA::ORB_init(_argc, _argv) ;
      40                 : 
      41                 :       CORBA::ORB::ObjectIdList *services ;
      42                 : 
      43               4 :       services = myOrb->list_initial_services() ;
      44                 : 
      45               4 :       if (services != NULL)
      46                 :       {
      47              52 :          for (unsigned int i = 0 ;
      48                 :               i < services->length() ;
      49                 :               i++)
      50                 :          {
      51                 :             std::cout << "Service[" << i << "]="
      52              48 :                << (*services)[i].in() << std::endl ;
      53                 :          }
      54                 :       }
      55                 : 
      56                 :       CORBA::Object_var obj ;
      57               4 :       obj = myOrb->resolve_initial_references("NameService") ;
      58                 : 
      59                 :       CosNaming::NamingContext_var inc ;
      60               4 :       inc = CosNaming::NamingContext::_narrow(obj) ;
      61                 : 
      62               4 :       if (CORBA::is_nil(inc))
      63                 :       {
      64               0 :          std::cout << "CosNaming::NamingContext::_narrow() failed !" ;
      65                 :       }
      66                 :       else
      67                 :       {
      68               4 :          CosNaming::NamingContext_var app2 = inc->new_context() ;
      69                 :       }
      70                 :    }
      71               4 :    catch (CORBA::SystemException& e)
      72                 :    {
      73               2 :       std::cerr << "System Exception :" << e.minor() << std::endl ;
      74                 :       std::cerr << std::flush ;
      75                 :       std::cout << std::flush ;
      76               2 :       fflush(stderr) ;
      77               2 :       fflush(stdout) ;
      78               2 :       return -1 ;
      79                 :    }
      80               0 :    catch (CORBA::UserException& e)
      81                 :    {
      82               0 :       std::cerr << "User Exception" << std::endl ;
      83               0 :       return -2 ;
      84                 :    }
      85                 : 
      86                 :    return 0L ;
      87               4 : }
      88               4 : 

Generated by: LTP GCOV extension version 1.4