Salome HOME
44ef441f916becb25c78d2b066755b4b9613b308
[modules/kernel.git] / src / HDFPersist / HDFcontainerObject.cc
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
24 //  File   : HDFcontainerObject.cc
25 //  Module : SALOME
26 //
27 #include "hdfi.h"
28 #include "HDFcontainerObject.hxx"
29 #include "HDFexception.hxx"
30
31 HDFcontainerObject::HDFcontainerObject(const char *name)
32   : HDFinternalObject(name)
33 {
34   _nsons = 0;
35   _firstson = NULL;
36   _lastson = NULL;
37 }
38
39 HDFcontainerObject::~HDFcontainerObject()
40 {
41   HDFinternalObject *sonToDelete = 0;
42   while(_firstson)
43     {
44       sonToDelete = _firstson;
45       _firstson = _firstson->GetNextBrother();
46       delete sonToDelete;
47     }
48 }
49
50 int HDFcontainerObject::nInternalObjects()
51 {
52   return 0;
53 }
54
55 void HDFcontainerObject::InternalObjectIndentify(int rank, char *object_name)
56 {
57   object_name = NULL;
58 }
59
60 void HDFcontainerObject::AddSon(HDFinternalObject *son)
61 {
62   if (_nsons == 0)
63     {
64       _firstson = son;
65       _lastson = _firstson;
66     }
67   else
68     {
69       _lastson->SetNextBrother(son);
70       son->SetPreviousBrother(_lastson);
71       _lastson = son;
72     }
73   _nsons ++;
74 }
75
76 HDFinternalObject *HDFcontainerObject::GetFirstSon()
77 {
78   return _firstson;
79 }
80
81 HDFinternalObject *HDFcontainerObject::GetLastSon()
82 {
83   return _lastson;
84 }
85
86 int HDFcontainerObject::nSons()
87 {
88   return _nsons;
89 }