/*
 * Portions of this file Copyright 1999-2005 University of Chicago
 * Portions of this file Copyright 1999-2005 The University of Southern California.
 *
 * This file or a portion of this file is licensed under the
 * terms of the Globus Toolkit Public License, found at
 * http://www.globus.org/toolkit/download/license.html.
 * If you redistribute this file, with or without
 * modifications, you must include this notice in the file.
 */


#ifndef _GLOBUS_SERVICE_REGISTRY_H_
#define _GLOBUS_SERVICE_REGISTRY_H_

#include "globus_common.h"

EXTERN_C_BEGIN

#include "globus_operation_provider.h"
#include "globus_service_engine.h"

extern globus_extension_registry_t      globus_service_registry;
#define GLOBUS_SERVICE_REGISTRY         &globus_service_registry

typedef void (* globus_operation_invoke_callback_func_t) (
    globus_result_t                     result,
    void *                              args);

typedef enum
{
    GLOBUS_SERVICE_DO_RESPONSE = 0,
    GLOBUS_SERVICE_NO_RESPONSE = 1
} globus_service_response_t;

typedef globus_result_t (* globus_operation_deserialize_func_t) (
    globus_service_engine_t                 engine,
    globus_soap_message_handle_t            message,
    globus_operation_invoke_callback_func_t invoke_callback,
    void *                                  args);

typedef globus_result_t (* globus_operation_invoke_func_t) (
    globus_service_engine_t                 engine,
    globus_soap_message_handle_t            message,
    globus_service_response_t *             response,
    globus_operation_invoke_callback_func_t invoke_callback,
    void *                                  args);

typedef globus_result_t (* globus_resource_id_func_t) (
    xsd_any_array *                     reference_properties,
    char **                             id);

typedef struct globus_service_operation_descriptor_s
{
    globus_operation_deserialize_func_t deserialize;
    globus_operation_invoke_func_t      invoke;
} globus_service_operation_descriptor_t;

typedef struct globus_service_descriptor_s
{
    xsd_QName *                         name;
    const char *                        path;
    globus_hashtable_t                  op_mapper;
    globus_operation_table_t            operations;
    globus_handler_chain_t              handlers;
    globus_xsd_type_registry_t          registry;
    globus_resource_id_func_t           get_resource_id;
    globus_mutex_t                      mutex;
} globus_service_descriptor_t;

int
globus_service_descriptor_lock(
    globus_service_descriptor_t *       desc);

int
globus_service_descriptor_unlock(
    globus_service_descriptor_t *       desc);

globus_result_t
globus_resource_id_get_as_string(
    xsd_any_array *                     reference_properties,
    char **                             id);

EXTERN_C_END

#endif
