/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */


// This file automatically generated by:
//   Apache Etch 1.1.0-incubating (LOCAL-0) / c 1.1.0-incubating (LOCAL-0)
//   Fri Aug 28 15:58:20 CEST 2009
// This file is automatically created and should not be edited!

#include "helloworld_client.h"
#include "etch_objecttypes.h"
#include "etch_general.h"
#include "etch_url.h"  

unsigned short CLASSID_HELLOWORLD_CLIENT_BASE;
	
	
int destroy_helloworld_client_base(void*);


/* - - - - - - - - - - - - - -  
 * constructors
 * - - - - - - - - - - - - - -  
 */
/**
 * new_helloworld_client_base()
 * @param iservice service interface -- caller retains   
 */
i_helloworld_client* new_helloworld_client_base(struct helloworld_client_impl* implobj)
{
    i_helloworld_client* ipc = (i_helloworld_client*) new_object (sizeof(i_helloworld_client), 
        ETCHTYPEB_EXECLIENTBASE, get_dynamic_classid_unique(&CLASSID_HELLOWORLD_CLIENT_BASE));

    ipc->thisx   = implobj;  /* helloworld_client_impl on client, null on server */
    ((etch_object*)ipc)->destroy = destroy_helloworld_client_base;

    ipc->ihelloworld = new_helloworld_service_interface();

    ipc->say_hello = ipc->ihelloworld->say_hello;

    ipc->user = ipc->ihelloworld->user;
 
    return ipc;
}

/**
 * destroy_helloworld_client_base()
 * i_helloworld_client destructor.
 */
int destroy_helloworld_client_base (void* data)
{
    i_helloworld_client* ipc = (i_helloworld_client*)data;
    if (NULL == ipc) return -1;  

    if (!is_etchobj_static_content(ipc))
    {    
        if (ipc->thisx)  /* thisx is null on server (i.e. this is a remote client) */
        {   /* destroy the helloworld_client_impl object */
            ETCH_ASSERT(is_etch_client_impl((etch_object*)ipc->thisx));
            //ETCHOBJ_DESTROY();
			if(((etch_object*)ipc->thisx)){
				etch_object_destroy(((etch_object*)ipc->thisx));
			}
			ipc->thisx = NULL;
        }

        //ETCHOBJ_DESTROY(ipc->ihelloworld);
		if(ipc->ihelloworld){
			etch_object_destroy(ipc->ihelloworld);
		}
		ipc->ihelloworld = NULL;

        etch_free(ipc->iobjsession);
    }
            
    return destroy_objectex((etch_object*)ipc);
}

/* - - - - - - - - - - - - - -  
 * client base methods
 * - - - - - - - - - - - - - -  
 */

/* nothing to do - service defines no client-directed items */

