summaryrefslogtreecommitdiffstats
path: root/src/H5Rpkg.h
blob: c4759516f09fa07a3defa25fc4f52d6b98a1083b (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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * 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:     This file contains declarations which are visible
 *              only within the H5R package. Source files outside the
 *              H5R package should include H5Rprivate.h instead.
 */
#if !(defined H5R_FRIEND || defined H5R_MODULE)
#error "Do not include this file outside the H5R package!"
#endif

#ifndef _H5Rpkg_H
#define _H5Rpkg_H

/* Get package's private header */
#include "H5Rprivate.h"

/* Other private headers needed by this file */
#include "H5Fprivate.h"         /* Files                                    */
#include "H5Gprivate.h"         /* Groups                                   */
#include "H5Oprivate.h"         /* Object headers                           */
#include "H5Sprivate.h"         /* Dataspaces                               */


/**************************/
/* Package Private Macros */
/**************************/

/* Encode flags */
#define H5R_IS_EXTERNAL         0x1     /* Set when encoding reference to external file */

/* Macros for convenience */
#define H5R_REF_FILENAME(x)     ((x)->info.obj.filename)
#define H5R_REF_ATTRNAME(x)     ((x)->info.attr.name)

/* Header size */
#define H5R_ENCODE_HEADER_SIZE  (2 * H5_SIZEOF_UINT8_T)

/****************************/
/* Package Private Typedefs */
/****************************/

/* Object reference */
typedef struct H5R_ref_priv_obj_t {
    H5O_token_t token;          /* Object token     */
    char *filename;             /* File name        */
} H5R_ref_priv_obj_t;

/* Region reference */
typedef struct H5R_ref_priv_reg_t {
    H5R_ref_priv_obj_t obj;     /* Object reference */
    H5S_t *space;               /* Selection        */
} H5R_ref_priv_reg_t;

/* Attribute reference */
typedef struct H5R_ref_priv_attr_t {
    H5R_ref_priv_obj_t obj;     /* Object reference */
    char *name;                 /* Attribute name   */
} H5R_ref_priv_attr_t;

/* Generic reference type (keep it cache aligned) */
typedef struct H5R_ref_priv_t {
    union {
        H5R_ref_priv_obj_t  obj;/* Object reference                 */
        H5R_ref_priv_reg_t  reg;/* Region reference                 */
        H5R_ref_priv_attr_t attr;/* Attribute Reference             */
    } info;
    hid_t    loc_id;            /* Cached location identifier       */
    uint32_t encode_size;       /* Cached encoding size             */
    int8_t   type;              /* Reference type                   */
    uint8_t  token_size;        /* Cached token size                */
    hbool_t  app_ref;           /* App ref on loc_id                */
} H5R_ref_priv_t;

/*****************************/
/* Package Private Variables */
/*****************************/


/******************************/
/* Package Private Prototypes */
/******************************/
H5_DLL herr_t   H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref);
H5_DLL herr_t   H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref);
H5_DLL herr_t   H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref);
H5_DLL herr_t   H5R__destroy(H5R_ref_priv_t *ref);

H5_DLL herr_t   H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref);
H5_DLL hid_t    H5R__get_loc_id(const H5R_ref_priv_t *ref);
H5_DLL hid_t    H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id);

H5_DLL H5R_type_t   H5R__get_type(const H5R_ref_priv_t *ref);
H5_DLL htri_t   H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2);
H5_DLL herr_t   H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref);

H5_DLL herr_t   H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size);
H5_DLL herr_t   H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size);
H5_DLL herr_t   H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space);

H5_DLL ssize_t  H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size);
H5_DLL ssize_t  H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size);

H5_DLL herr_t   H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, unsigned flags);
H5_DLL herr_t   H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref);

/* Native HDF5 specific routines */
H5_DLL herr_t   H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, size_t data_size);
H5_DLL herr_t   H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, size_t *data_size);

H5_DLL herr_t   H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc);
H5_DLL herr_t   H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size);

H5_DLL herr_t   H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr);

#endif /* _H5Rpkg_H */