Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/kernel.git] / src / HDFPersist / HDFcontainerObject.cc
1 //  SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : HDFcontainerObject.cc
25 //  Module : SALOME
26
27 using namespace std;
28 extern "C"
29 {
30 #include "hdfi.h"
31 }
32 #include "HDFcontainerObject.hxx"
33 #include "HDFexception.hxx"
34 #include "utilities.h"
35
36 HDFcontainerObject::HDFcontainerObject(char *name)
37   : HDFinternalObject(name)
38 {
39   _nsons = 0;
40   _firstson = NULL;
41   _lastson = NULL;
42 }
43
44 HDFcontainerObject::~HDFcontainerObject()
45 {
46   HDFinternalObject *sonToDelete = 0;
47   while(_firstson)
48     {
49       sonToDelete = _firstson;
50       _firstson = _firstson->GetNextBrother();
51 //       MESSAGE("son to delete: " << sonToDelete);
52       delete sonToDelete;
53     }
54 //   MESSAGE("destruction: " << this);
55 }
56
57 int HDFcontainerObject::nInternalObjects()
58 {
59   return 0;
60 }
61
62 void HDFcontainerObject::InternalObjectIndentify(int rank, char *object_name)
63 {
64   object_name = NULL;
65 }
66
67 void HDFcontainerObject::AddSon(HDFinternalObject *son)
68 {
69 //   MESSAGE("add son ")  MESSAGE("add to this" << this);
70 //   MESSAGE("add son " << son);
71 //   MESSAGE("firstson " << _firstson);
72 //   MESSAGE("lastson  " << _lastson);
73
74   if (_nsons == 0)
75     {
76       _firstson = son;
77       _lastson = _firstson;
78     }
79   else
80     {
81       _lastson->SetNextBrother(son);
82       son->SetPreviousBrother(_lastson);
83       _lastson = son;
84     }
85   _nsons ++;
86 //   MESSAGE("firstson " << _firstson);
87 //   MESSAGE("lastson  " << _lastson);
88 }
89
90 HDFinternalObject *HDFcontainerObject::GetFirstSon()
91 {
92   return _firstson;
93 }
94
95 HDFinternalObject *HDFcontainerObject::GetLastSon()
96 {
97   return _lastson;
98 }
99
100 int HDFcontainerObject::nSons()
101 {
102   return _nsons;
103 }