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