1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 
16 #ifndef __H5LISTOBJECT_HXX__
17 #define __H5LISTOBJECT_HXX__
18 
19 #include "H5Object.hxx"
20 #include "H5Attribute.hxx"
21 
22 namespace org_modules_hdf5
23 {
24 
25 template<typename T>
26 class H5ListObject : public H5Object
27 {
28 
29 public :
30 
H5ListObject(H5Object & _parent)31     H5ListObject(H5Object & _parent) : H5Object(_parent), indexSize(0), indexList(0) { }
H5ListObject(H5Object & _parent,const unsigned int size,const unsigned int * index)32     H5ListObject(H5Object & _parent, const unsigned int size, const unsigned int * index) : H5Object(_parent), indexSize(size), indexList(index) { }
33 
~H5ListObject()34     virtual ~H5ListObject()
35     {
36         if (indexList)
37         {
38             delete indexList;
39         }
40     }
41 
isList() const42     virtual bool isList() const
43     {
44         return true;
45     }
46 
47     virtual void setObject(const unsigned int pos, T & object) = 0;
48     virtual T & getObject(const int pos) = 0;
getObject(const std::string & name)49     virtual T & getObject(const std::string & name)
50     {
51         throw H5Exception(__LINE__, __FILE__, _("Invalid operation"));
52     }
53 
54     virtual unsigned int getSize() const = 0;
55 
getAccessibleAttribute(const double index,const int pos,void * pvApiCtx) const56     virtual void getAccessibleAttribute(const double index, const int pos, void * pvApiCtx) const
57     {
58         T & obj = const_cast<H5ListObject<T> *>(this)->getObject((int)index);
59         obj.createOnScilabStack(pos, pvApiCtx);
60     }
61 
getAccessibleAttribute(const std::string & name,const int pos,void * pvApiCtx) const62     virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const
63     {
64         T & obj = const_cast<H5ListObject *>(this)->getObject(name);
65         obj.createOnScilabStack(pos, pvApiCtx);
66     }
67 
68 protected :
69 
70     const unsigned int indexSize;
71     const unsigned int * indexList;
72 
73 };
74 }
75 
76 #endif // __H5FILE_HXX__
77