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

#include "globus_common.h"

EXTERN_C_BEGIN

#include "WidgetService.h"

GlobusDebugDeclare(WIDGETSERVICE);

extern globus_module_descriptor_t WidgetService_module;
#define WIDGETSERVICE_MODULE &WidgetService_module

#define WIDGETSERVICE_INFO  1
#define WIDGETSERVICE_DEBUG 2
#define WIDGETSERVICE_TRACE 4
#define WIDGETSERVICE_WARN  8
#define WIDGETSERVICE_ERROR 16

#define WidgetServiceDebugPrintf(LEVEL, MESSAGE) \
    GlobusDebugPrintf(WIDGETSERVICE, LEVEL, MESSAGE)

#define WidgetServiceDebugEnter() \
    WidgetServiceDebugPrintf(WIDGETSERVICE_TRACE, \
                       ("[%s] Entering\n", _globus_func_name))

#define WidgetServiceDebugExit() \
    WidgetServiceDebugPrintf(WIDGETSERVICE_TRACE, \
                       ("[%s] Exiting\n", _globus_func_name))

enum
{
    WIDGETSERVICE_ERROR_TYPE_INVOKE_FAILED = 1024,
    WIDGETSERVICE_ERROR_RETURNED_UNKNOWN_FAULT,
    WIDGETSERVICE_ERROR_NOT_IMPLEMENTED
};

#define WidgetServiceErrorInvokeFailed(result, message)               \
    globus_error_put(                                           \
        globus_error_construct_error(                           \
            WIDGETSERVICE_MODULE,                       \
            (result ? globus_error_get(result) : NULL),         \
            WIDGETSERVICE_ERROR_TYPE_INVOKE_FAILED,     \
            __FILE__,                                           \
            _globus_func_name,                                  \
            __LINE__,                                           \
            "Operation invocation failed: %s", message))

#define WidgetServiceErrorReturnedUnknownFault(opname)                 \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             WIDGETSERVICE_MODULE,                       \
             NULL,                                               \
             WIDGETSERVICE_ERROR_RETURNED_UNKNOWN_FAULT, \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s returned unknown fault", opname))

#define WidgetServiceErrorNotImplemented(opname)                       \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             WIDGETSERVICE_MODULE,                       \
             NULL,                                               \
             WIDGETSERVICE_ERROR_NOT_IMPLEMENTED,        \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s Unimplemented", opname))
        
EXTERN_C_END

#endif
