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
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
#include "H5Link.hxx"
#include "H5SoftLink.hxx"
#include "H5ExternalLink.hxx"
#include "H5HardLink.hxx"
#include "H5Object.hxx"
namespace org_modules_hdf5
{
H5Link::H5Link(H5Object & _parent, const std::string & _name) : H5Object(_parent, _name)
{
if (H5Lexists(_parent.getH5Id(), name.c_str(), H5P_DEFAULT) <= 0)
{
throw H5Exception(__LINE__, __FILE__, _("The link %s does not exist."), name.c_str());
}
}
H5Link::~H5Link()
{
}
H5Link & H5Link::getLink(H5Object & _parent, const std::string & _name)
{
return getLink(_parent, _name.c_str());
}
H5Link & H5Link::getLink(H5Object & _parent, const char * _name)
{
herr_t err;
H5L_info_t info;
H5Link * link = 0;
err = H5Lget_info(_parent.getH5Id(), _name, &info, H5P_DEFAULT);
if (err < 0)
{
throw H5Exception(__LINE__, __FILE__, _("Cannot get the link info"));
}
switch (info.type)
{
case H5L_TYPE_HARD:
link = new H5HardLink(_parent, _name);
break;
case H5L_TYPE_SOFT:
link = new H5SoftLink(_parent, _name);
break;
case H5L_TYPE_EXTERNAL:
link = new H5ExternalLink(_parent, _name);
break;
case H5L_TYPE_ERROR:
default:
throw H5Exception(__LINE__, __FILE__, _("Invalid link type: %s."), _name);
}
return *link;
}
}
|