/*
 * 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_OPERATION_PROVIDER_H_
#define _GLOBUS_OPERATION_PROVIDER_H_

#include "globus_common.h"

EXTERN_C_BEGIN

#include "xsd_QName.h"

enum
{
    GLOBUS_OPERATION_PROVIDER_ERROR_REGISTRY_LOOKUP_FAILED = 1024,
    GLOBUS_OPERATION_PROVIDER_ERROR_FAILED_INIT,
    GLOBUS_OPERATION_PROVIDER_ERROR_OP_NOT_FOUND,
    GLOBUS_OPERATION_PROVIDER_ERROR_FAILED_TABLE_INSERT,
    GLOBUS_OPERATION_PROVIDER_ERROR_FAILED_RESOURCE_INIT,
    GLOBUS_OPERATION_PROVIDER_ERROR_OUT_OF_MEMORY
};

extern globus_module_descriptor_t       globus_l_operation_provider_module;
#define GLOBUS_OPERATION_PROVIDER_MODULE &globus_l_operation_provider_module

extern globus_extension_registry_t       globus_operation_provider_registry;
#define GLOBUS_OPERATION_PROVIDER_REGISTRY &globus_operation_provider_registry

typedef globus_result_t (* globus_operation_init_resource_func_t) (
    const char *                        resource_id);

typedef struct globus_operation_provider_descriptor_s
{
    xsd_QName *                         name;
    const char *                        id;
    void *                              init_operation_func;
    void *                              operation_func;
    globus_operation_init_resource_func_t init_resource;
} globus_operation_provider_descriptor_t;

typedef struct globus_l_operation_table_s * globus_operation_table_t;

globus_result_t
globus_operation_table_init(
    globus_operation_table_t *          table,
    const char *                        Namespace);

void
globus_operation_table_destroy(
    globus_operation_table_t            table);

globus_result_t
globus_operation_table_get_operation(
    globus_operation_table_t            table,
    const char *                        operation_name,
    void **                             init_operation,
    void **                             operation);

globus_result_t
globus_operation_table_add_provider(
    globus_operation_table_t            table,
    xsd_QName *                         operation);

globus_result_t
globus_operation_table_add_default_provider(
    globus_operation_table_t            table,
    xsd_QName *                         operation_name,
    globus_operation_provider_descriptor_t * op_desc);

globus_result_t
globus_operation_table_init_resource(
    globus_operation_table_t            table,
    const char *                        id);

EXTERN_C_END

#endif
