Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

NameClient_impl.cpp

Go to the documentation of this file.
00001 
00005 /* --------------------------------------------------------------
00006 Copyright (C) 2001 LifeLine Networks BV <soap2corba@lifeline.nl>
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either
00011 version 2 of the License, or (at your option) any later
00012 version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 -------------------------------------------------------------- */
00023 #include <OB/CORBA.h>
00024 #include <OB/CosNaming.h>
00025 #include "NameClient_impl.h"
00026 
00027 //
00028 // IDL:SimpleNameServer:1.0
00029 //
00030 
00031 //
00032 // IDL:SimpleNameServer/SimpleNamingClient:1.0
00033 //
00034 SimpleNameServer::SimpleNamingClient_impl::SimpleNamingClient_impl(CosNaming::NamingContext_ptr inc)
00035 : inc_ (inc)
00036 {
00037 }
00038 
00039 SimpleNameServer::SimpleNamingClient_impl::~SimpleNamingClient_impl()
00040 {
00041 }
00042 
00043 //
00044 // IDL:SimpleNameServer/SimpleNamingClient/Resolve:1.0
00045 //
00046 CORBA::Object_ptr
00047 SimpleNameServer::SimpleNamingClient_impl::Resolve(const char* name)
00048     throw(CORBA::SystemException)
00049 {
00050     char *dup = strdup (name);
00051     char *psl;
00052     int n = 1;
00053     for (psl = strchr (dup, '/'); psl != NULL; psl = strchr (psl + 1, '/')) n ++;
00054     CosNaming::Name findName;
00055     findName.length (n);
00056     int i;
00057     char *ppart = dup;
00058     for (i = 0; i < n; i ++) {
00059         psl = strchr (ppart, '/');
00060         if (psl) *psl = 0;
00061         findName [i].id = CORBA::string_dup (ppart);
00062         findName [i].kind = CORBA::string_dup ("");
00063         if (psl) ppart = psl + 1;
00064     }
00065     free (dup);
00066     CORBA::Object_ptr p = NULL;
00067     try {
00068         p = inc_->resolve (findName);
00069     }
00070     catch (...) {
00071         printf ("Resolve '%s' failed\n", name);
00072     }
00073     return p;
00074 }
00075 

This documentation is part of the "SOAP to CORBA bridge" project
Copyright © 2000 by Lifeline Networks bv.
All rights are reserved.