summaryrefslogtreecommitdiffstats
path: root/src/H5VLnative.c
blob: 7848c5d552e17a77e58ebe3d2c027c067c1060f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 * Purpose:     The native VOL connector where access is to a single HDF5 file 
 *              using HDF5 VFDs. 
 */

#include "H5private.h"          /* Generic Functions                        */
#include "H5Eprivate.h"         /* Error handling                           */
#include "H5Iprivate.h"         /* IDs                                      */
#include "H5Pprivate.h"         /* Property lists                           */
#include "H5VLprivate.h"        /* Virtual Object Layer                     */

#include "H5VLnative_private.h" /* Native VOL connector                     */


/* The VOL connector identification number */
static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID;

/* Prototypes */
static herr_t H5VL__native_term(void);

/* Native VOL connector class struct */
static H5VL_class_t H5VL_native_cls_g = {
    H5VL_NATIVE_VERSION,                            /* version      */
    H5VL_NATIVE_VALUE,                              /* value        */
    H5VL_NATIVE_NAME,                               /* name         */
    0,                                              /* capability flags */
    NULL,                                           /* initialize   */
    H5VL__native_term,                              /* terminate    */
    {   /* info_cls */
        (size_t)0,                                  /* info size    */
        NULL,                                       /* info copy    */
        NULL,                                       /* info compare */
        NULL,                                       /* info free    */
        NULL,                                       /* info to str  */
        NULL                                        /* str to info  */
    },
    {   /* wrap_cls */
        NULL,                                       /* get_object   */
        NULL,                                       /* get_wrap_ctx */
        NULL,                                       /* wrap_object  */
        NULL,                                       /* unwrap_object */
        NULL                                        /* free_wrap_ctx */
    },
    {   /* attribute_cls */
        H5VL__native_attr_create,                   /* create       */
        H5VL__native_attr_open,                     /* open         */
        H5VL__native_attr_read,                     /* read         */
        H5VL__native_attr_write,                    /* write        */
        H5VL__native_attr_get,                      /* get          */
        H5VL__native_attr_specific,                 /* specific     */
        H5VL__native_attr_optional,                 /* optional     */
        H5VL__native_attr_close                     /* close        */
    },
    {   /* dataset_cls */
        H5VL__native_dataset_create,                /* create       */
        H5VL__native_dataset_open,                  /* open         */
        H5VL__native_dataset_read,                  /* read         */
        H5VL__native_dataset_write,                 /* write        */
        H5VL__native_dataset_get,                   /* get          */
        H5VL__native_dataset_specific,              /* specific     */
        H5VL__native_dataset_optional,              /* optional     */
        H5VL__native_dataset_close                  /* close        */
    },
    {   /* datatype_cls */
        H5VL__native_datatype_commit,               /* commit       */
        H5VL__native_datatype_open,                 /* open         */
        H5VL__native_datatype_get,                  /* get          */
        H5VL__native_datatype_specific,             /* specific     */
        NULL,                                       /* optional     */
        H5VL__native_datatype_close                 /* close        */
    },
    {   /* file_cls */
        H5VL__native_file_create,                   /* create       */
        H5VL__native_file_open,                     /* open         */
        H5VL__native_file_get,                      /* get          */
        H5VL__native_file_specific,                 /* specific     */
        H5VL__native_file_optional,                 /* optional     */
        H5VL__native_file_close                     /* close        */
    },
    {   /* group_cls */
        H5VL__native_group_create,                  /* create       */
        H5VL__native_group_open,                    /* open         */
        H5VL__native_group_get,                     /* get          */
        H5VL__native_group_specific,                /* specific     */
        H5VL__native_group_optional,                /* optional     */
        H5VL__native_group_close                    /* close        */
    },
    {   /* link_cls */
        H5VL__native_link_create,                   /* create       */
        H5VL__native_link_copy,                     /* copy         */
        H5VL__native_link_move,                     /* move         */
        H5VL__native_link_get,                      /* get          */
        H5VL__native_link_specific,                 /* specific     */
        NULL                                        /* optional     */
    },
    {   /* object_cls */
        H5VL__native_object_open,                   /* open         */
        H5VL__native_object_copy,                   /* copy         */
        H5VL__native_object_get,                    /* get          */
        H5VL__native_object_specific,               /* specific     */
        H5VL__native_object_optional                /* optional     */
    },
    {   /* request_cls */
        NULL,                                       /* wait         */
        NULL,                                       /* notify       */
        NULL,                                       /* cancel       */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* free         */
    },
    NULL                                            /* optional     */
};


/*-------------------------------------------------------------------------
 * Function:    H5VL_native_register
 *
 * Purpose:     Register the native VOL connector and retrieve an ID for it.
 *
 * Return:      Success:    The ID for the native connector
 *              Failure:    H5I_INVALID_HID
 *
 *-------------------------------------------------------------------------
 */
hid_t
H5VL_native_register(void)
{
    hid_t ret_value = H5I_INVALID_HID;            /* Return value */

    FUNC_ENTER_NOAPI(H5I_INVALID_HID)

    /* Register the native VOL connector, if it isn't already */
    if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL))
        if((H5VL_NATIVE_ID_g = H5VL_register_connector((const H5VL_class_t *)&H5VL_native_cls_g, TRUE, H5P_DEFAULT)) < 0)
            HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector")

    /* Set return value */
    ret_value = H5VL_NATIVE_ID_g;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_register() */


/*---------------------------------------------------------------------------
 * Function:    H5VL__native_term
 *
 * Purpose:     Shut down the native VOL
 *
 * Returns:     SUCCEED (Can't fail)
 *
 *---------------------------------------------------------------------------
 */
static herr_t
H5VL__native_term(void)
{
    FUNC_ENTER_STATIC_NOERR

    /* Reset VOL ID */
    H5VL_NATIVE_ID_g = H5I_INVALID_HID;

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5VL__native_term() */