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

#include "globus_common.h"

EXTERN_C_BEGIN

#include "CounterService.h"

GlobusDebugDeclare(COUNTERSERVICE);

extern globus_module_descriptor_t CounterService_module;
#define COUNTERSERVICE_MODULE &CounterService_module

#define COUNTERSERVICE_INFO  1
#define COUNTERSERVICE_DEBUG 2
#define COUNTERSERVICE_TRACE 4
#define COUNTERSERVICE_WARN  8
#define COUNTERSERVICE_ERROR 16

#define CounterServiceDebugPrintf(LEVEL, MESSAGE) \
    GlobusDebugPrintf(COUNTERSERVICE, LEVEL, MESSAGE)

#define CounterServiceDebugEnter() \
    CounterServiceDebugPrintf(COUNTERSERVICE_TRACE, \
                       ("[%s] Entering\n", _globus_func_name))

#define CounterServiceDebugExit() \
    CounterServiceDebugPrintf(COUNTERSERVICE_TRACE, \
                       ("[%s] Exiting\n", _globus_func_name))

enum
{
    COUNTERSERVICE_ERROR_TYPE_INVOKE_FAILED = 1024,
    COUNTERSERVICE_ERROR_RETURNED_UNKNOWN_FAULT,
    COUNTERSERVICE_ERROR_NOT_IMPLEMENTED
};

#define CounterServiceErrorInvokeFailed(result, message)               \
    globus_error_put(                                           \
        globus_error_construct_error(                           \
            COUNTERSERVICE_MODULE,                       \
            (result ? globus_error_get(result) : NULL),         \
            COUNTERSERVICE_ERROR_TYPE_INVOKE_FAILED,     \
            __FILE__,                                           \
            _globus_func_name,                                  \
            __LINE__,                                           \
            "Operation invocation failed: %s", message))

#define CounterServiceErrorReturnedUnknownFault(opname)                 \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             COUNTERSERVICE_MODULE,                       \
             NULL,                                               \
             COUNTERSERVICE_ERROR_RETURNED_UNKNOWN_FAULT, \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s returned unknown fault", opname))

#define CounterServiceErrorNotImplemented(opname)                       \
     globus_error_put(                                           \
         globus_error_construct_error(                           \
             COUNTERSERVICE_MODULE,                       \
             NULL,                                               \
             COUNTERSERVICE_ERROR_NOT_IMPLEMENTED,        \
             __FILE__,                                           \
             _globus_func_name,                                  \
             __LINE__,                                           \
             "Operation %s Unimplemented", opname))
        
EXTERN_C_END

#endif
