Salome HOME
d5355328b3454a3debdbe80b17bfa02b5bffab58
[modules/geom.git] / src / GEOM_I_Superv / GEOM_List_i.hh
1 //  Copyright (C) 2007-2010  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.
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 #ifndef __GEOM_LIST_I_H__
24 #define __GEOM_LIST_I_H__
25
26 // IDL headers
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(GEOM_Superv)
29
30 #include "GEOM_Gen_i.hh"
31 #include "utilities.h"
32
33 template <class Type>
34 class GEOM_List_i : 
35   public virtual POA_GEOM::GEOM_List,
36   public virtual PortableServer::RefCountServantBase
37 {
38 public:
39   GEOM_List_i();
40   GEOM_List_i(const Type& theListToCopy);
41   ~GEOM_List_i();
42
43   const Type& GetList();
44
45   template <class ElemType>
46   void AddObject(ElemType theObject);
47
48 private:
49   Type myGOList;
50 };
51
52 //=============================================================================
53 //  constructor:
54 //=============================================================================
55 template <class Type>
56 GEOM_List_i<Type>::GEOM_List_i()
57 {
58   MESSAGE("GEOM_List_i::GEOM_List_i");
59   //create an empty list
60   myGOList.length(0);
61 }
62
63 //=============================================================================
64 //  constructor:
65 //=============================================================================
66 template <class Type>
67 GEOM_List_i<Type>::GEOM_List_i(const Type& theListToCopy)
68 {
69   int aLength = theListToCopy.length();
70   myGOList.length(aLength);
71   for (int i = 0; i < aLength; i++)
72     myGOList[i] = theListToCopy[i];
73 }
74
75 //=============================================================================
76 //  destructor:
77 //=============================================================================
78 template <class Type>
79 GEOM_List_i<Type>::~GEOM_List_i()
80 {
81   MESSAGE("GEOM_List_i::~GEOM_List_i");
82 }
83
84 //=============================================================================
85 //  GetList:
86 //=============================================================================
87 template <class Type>
88 const Type& GEOM_List_i<Type>::GetList()
89 {
90   MESSAGE("GEOM_List_i::GetList()");
91   return myGOList;
92 }
93
94 //=============================================================================
95 //  AddObject:
96 //=============================================================================
97 template <class Type>
98 template <class ElemType>
99 void GEOM_List_i<Type>::AddObject(ElemType theObject)
100 {
101   MESSAGE("GEOM_List_i::AddObject(...)");
102   int aLength = myGOList.length();
103   myGOList.length(aLength+1);
104   myGOList[aLength] = theObject;
105 }
106
107 #endif