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

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/prod/lib/orb.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_stdc.h"
      25                 : #include "src/cpp/prod/port/port_stdlib.h"
      26                 : 
      27                 : #include <yaorb/CORBA.h>
      28                 : #include <yaorb/YAORB.h>
      29                 : 
      30                 : #include "src/cpp/prod/tool/DEVELOPMENT.h"
      31                 : #include "src/cpp/prod/tool/Assert.h"
      32                 : #include "src/cpp/prod/tool/String.h"
      33                 : #include "src/cpp/prod/CORBA/YAOrb.h"
      34                 : #include "src/cpp/prod/boot/boot.h"
      35                 : 
      36                 : // See 99-07-08, section 4.5, page 4-17.
      37                 : 
      38                 : // FIXME : single argument "-ORBIdMyORB" or "-ORBId MyORB" not supported
      39                 : // FIXME : -ORBxx arguments not removed from argc/argv 
      40                 : 
      41                 : /*
      42                 :  *  Arguments of CORBA::ORB_init :
      43                 :  *
      44                 :  *  -ORBid <identifier>
      45                 :  *  -ORBModel Client|SingleServer|MultiProcessServer|MultiThreadServer
      46                 :  *  -ORBConfig <file name>
      47                 :  */
      48                 : 
      49                 : CORBA::ORB_ptr CORBA::ORB_init(
      50                 :    int& argc,
      51                 :    char* argv[],
      52               7 :    const char* orb_identifier)
      53                 : {
      54                 :    ORB_ptr theOrb = NULL ;
      55                 :    int arg = 0 ;
      56                 :    const char* current = NULL ;
      57                 : 
      58               7 :    String id ;
      59               7 :    String model ;
      60               7 :    String confFileName ;
      61                 : 
      62              29 :    while (arg < argc)
      63                 :    {
      64              22 :       current = argv[arg] ;
      65                 : 
      66              22 :       if (strncmp(current, "-ORB", 4) != 0)
      67                 :       {
      68               7 :          arg ++ ;
      69               7 :          continue ;
      70                 :       }
      71                 : 
      72              15 :       if (strcmp(current, "-ORBId") == 0)
      73                 :       {
      74                 :          arg ++ ;
      75               7 :          id = argv[arg] ;
      76               7 :          arg ++ ;
      77               7 :          continue ;
      78                 :       }
      79                 : 
      80               8 :       if (strcmp(current, "-ORBModel") == 0)
      81                 :       {
      82                 :          arg ++ ;
      83               7 :          model = argv[arg] ;
      84               7 :          arg ++ ;
      85               7 :          continue ;
      86                 :       }
      87                 : 
      88               1 :       if (strcmp(current, "-ORBConfig") == 0)
      89                 :       {
      90                 :          arg ++ ;
      91               1 :          confFileName = argv[arg] ;
      92               1 :          arg ++ ;
      93               1 :          continue ;
      94                 :       }
      95                 : 
      96               0 :       fprintf(stderr, "Parameter %s is not supported.\n", current) ;
      97                 : 
      98               0 :       throw CORBA::BAD_PARAM() ;
      99                 :    } ;
     100                 : 
     101               7 :    if (orb_identifier != NULL)
     102                 :    {
     103               7 :       if (strlen(orb_identifier) != 0)
     104                 :       {
     105               0 :          id = orb_identifier ;
     106                 :       }
     107                 :    }
     108                 : 
     109                 :    YAOrb *realORB = NULL ;
     110                 : 
     111               7 :    realORB = CreateOrb(model, confFileName) ;
     112                 : 
     113               6 :    if (realORB == NULL)
     114                 :    {
     115               0 :       throw CORBA::UNKNOWN() ;
     116                 :    }
     117                 : 
     118               6 :    theOrb = new CORBA::ORB(realORB) ;
     119                 : 
     120               6 :    return theOrb ;
     121                 : }
     122                 : 
     123               6 : CORBA::ORB::ORB(YAOrb* orb)
     124               6 : : _orb(orb)
     125                 : {
     126                 :    ASSERT(orb != NULL) ;
     127                 : }
     128                 : 
     129               0 : CORBA::ORB::~ORB()
     130                 : {
     131                 :    ASSERT(_orb != NULL) ;
     132               0 :    _orb->DecRefCount() ;
     133               0 : }
     134                 : 
     135                 : void
     136               6 : CORBA::ORB::IncRefCount(void)
     137                 : {
     138                 :    ASSERT(_orb != NULL) ;
     139               6 :    _orb->IncRefCount() ;
     140                 : }
     141                 : 
     142                 : void
     143               6 : CORBA::ORB::DecRefCount(void)
     144                 : {
     145                 :    ASSERT(_orb != NULL) ;
     146               6 :    _orb->DecRefCount() ;
     147                 : }
     148                 : 
     149                 : CORBA::ORB_ptr
     150               7 : CORBA::ORB::_duplicate(CORBA::ORB *orb)
     151                 : {
     152               7 :    if (orb != NULL)
     153                 :    {
     154               6 :       orb->IncRefCount() ;
     155                 :    }
     156                 : 
     157                 :    return orb ;
     158                 : }
     159                 : 
     160              10 : CORBA::Boolean CORBA::ORB::work_pending(void)
     161                 : {
     162                 :    ASSERT(_orb != NULL) ;
     163              10 :    return _orb->workPending() ;
     164                 : }
     165                 : 
     166               0 : void CORBA::ORB::perform_work(void)
     167                 : {
     168                 :    ASSERT(_orb != NULL) ;
     169               0 :    _orb->performWork() ;
     170                 : }
     171                 : 
     172               1 : void CORBA::ORB::shutdown(CORBA::Boolean wait_for_completion)
     173                 : {
     174                 :    ASSERT(_orb != NULL) ;
     175               1 :    _orb->shutdown(wait_for_completion) ;
     176                 : }
     177                 : 
     178               1 : void CORBA::ORB::run(void)
     179                 : {
     180                 :    ASSERT(_orb != NULL) ;
     181               1 :    _orb->run() ;
     182                 : }
     183                 : 
     184               5 : CORBA::ORB::ObjectIdList* CORBA::ORB::list_initial_services(void)
     185                 : {
     186                 :    ASSERT(_orb != NULL) ;
     187               5 :    const CORBA::ORB::ObjectIdList& services = _orb->listInitialServices() ;
     188               5 :    return new CORBA::ORB::ObjectIdList(services) ;
     189                 : }
     190                 : 
     191               7 : CORBA::Object_ptr CORBA::ORB::resolve_initial_references(const char* id)
     192                 : {
     193                 :    ASSERT(_orb != NULL) ;
     194               7 :    return _orb->resolveInitialReferences(id) ;
     195                 : }
     196                 : 
     197               7 : void CORBA::release(ORB_ptr orb)
     198                 : {
     199               7 :    if (orb != NULL)
     200                 :    {
     201               6 :       orb->DecRefCount() ;
     202                 :    }
     203                 : }
     204                 : 
     205               2 : CORBA::Boolean CORBA::is_nil(ORB_ptr orb)
     206                 : {
     207                 :    return ((orb == NULL) ? true : false) ;
     208                 : }
     209                 : 
     210              87 : void CORBA::release(Object_ptr obj)
     211                 : {
     212              87 :    if (obj != NULL)
     213                 :    {
     214              37 :       obj->DecRefCount() ;
     215                 :    }
     216                 : }
     217                 : 
     218              46 : CORBA::Boolean CORBA::is_nil(Object_ptr obj)
     219                 : {
     220                 :    return ((obj == NULL) ? true : false) ;
     221                 : }
     222                 : 
     223               0 : CORBA::Object_ptr CORBA::ORB::string_to_object(const char* str)
     224                 : {
     225                 :    ASSERT(_orb != NULL) ;
     226               0 :    return _orb->stringToObject(str) ;
     227                 : }
     228                 : 
     229               1 : char * CORBA::ORB::object_to_string(Object_ptr obj)
     230                 : {
     231                 :    ASSERT(_orb != NULL) ;
     232               1 :    return _orb->objectToString(obj) ;
     233                 : }
     234                 : 
     235               0 : void CORBA::release(CORBA::TypeCode* obj)
     236                 : {
     237               0 :    NON_DEV("TypeCode") ;
     238                 : }
     239                 : 

Generated by: LTP GCOV extension version 1.4