Salome HOME
NRI : KERNEL is now defined in KERNELCatalog.
[modules/kernel.git] / src / HDFPersist / HDFattribute.cc
1 using namespace std;
2 extern "C"
3 {
4 #include "hdfi.h"
5 }
6 #include "HDFexception.hxx"
7 #include "HDFattribute.hxx"
8 #include "HDFinternalObject.hxx"
9
10 HDFattribute::HDFattribute(char *name,HDFinternalObject *father,hdf_type type)
11   : HDFobject(name)
12 {
13   _father = father;
14   _fid = _father->GetId();
15   _type = type;
16 }
17
18 void HDFattribute::CreateOnDisk()
19 {
20   if ((_id = HDFattrCreate(_fid,_name,_type)) < 0)
21     throw HDFexception("Can't create attribute");
22 }
23 void HDFattribute::OpenOnDisk()
24 {
25   if ((_id = HDFattrOpen(_fid,_name)) < 0)
26     throw HDFexception("Can't open attribute");
27 }
28 void HDFattribute::CloseOnDisk()
29 {
30   hdf_err ret;
31
32   if ((ret = HDFattrClose(_id)) < 0)
33       throw HDFexception("Can't close dataset");
34 }
35
36 void HDFattribute::WriteOnDisk(void *values)
37 {
38   hdf_err ret;
39
40   if ((ret = HDFattrWrite(_id,values)) < 0)
41     throw HDFexception("Can't create group");
42 }
43
44 void HDFattribute::ReadFromDisk(void *values)
45 {
46   hdf_err ret; 
47
48   if ((ret = HDFattrRead(_id,values)) < 0)
49     throw HDFexception("Can't read attribute");
50 }
51
52 HDFinternalObject * HDFattribute::GetFather()
53 {
54   return _father;
55 }
56
57 hdf_type HDFattribute::GetType()
58 {
59   return _type;
60 }