Salome HOME
PAL12874: Object Vector. Provide a possibility to display a vector with arrow on...
[modules/geom.git] / src / GEOM_I_Superv / GEOM_List_i.hh
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #ifndef __GEOM_LIST_I_H__
21 #define __GEOM_LIST_I_H__
22
23 // IDL headers
24 #include <SALOMEconfig.h>
25 #include CORBA_SERVER_HEADER(GEOM_Superv)
26
27 #include "GEOM_Gen_i.hh"
28 #include "utilities.h"
29
30 template <class Type>
31 class GEOM_List_i : 
32   public virtual POA_GEOM::GEOM_List,
33   public virtual PortableServer::RefCountServantBase
34 {
35 public:
36   GEOM_List_i();
37   GEOM_List_i(const Type& theListToCopy);
38   ~GEOM_List_i();
39
40   const Type& GetList();
41
42   template <class ElemType>
43   void AddObject(ElemType theObject);
44
45 private:
46   Type myGOList;
47 };
48
49 //=============================================================================
50 //  constructor:
51 //=============================================================================
52 template <class Type>
53 GEOM_List_i<Type>::GEOM_List_i()
54 {
55   MESSAGE("GEOM_List_i::GEOM_List_i");
56   //create an empty list
57   myGOList.length(0);
58 }
59
60 //=============================================================================
61 //  constructor:
62 //=============================================================================
63 template <class Type>
64 GEOM_List_i<Type>::GEOM_List_i(const Type& theListToCopy)
65 {
66   int aLength = theListToCopy.length();
67   myGOList.length(aLength);
68   for (int i = 0; i < aLength; i++)
69     myGOList[i] = theListToCopy[i];
70 }
71
72 //=============================================================================
73 //  destructor:
74 //=============================================================================
75 template <class Type>
76 GEOM_List_i<Type>::~GEOM_List_i()
77 {
78   MESSAGE("GEOM_List_i::~GEOM_List_i");
79 }
80
81 //=============================================================================
82 //  GetList:
83 //=============================================================================
84 template <class Type>
85 const Type& GEOM_List_i<Type>::GetList()
86 {
87   MESSAGE("GEOM_List_i::GetList()");
88   return myGOList;
89 }
90
91 //=============================================================================
92 //  AddObject:
93 //=============================================================================
94 template <class Type>
95 template <class ElemType>
96 void GEOM_List_i<Type>::AddObject(ElemType theObject)
97 {
98   MESSAGE("GEOM_List_i::AddObject(...)");
99   int aLength = myGOList.length();
100   myGOList.length(aLength+1);
101   myGOList[aLength] = theObject;
102 }
103
104 #endif