1 // Copyright (C) 2010-2011 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _vtkMedSetGet_h_
21 #define _vtkMedSetGet_h_
24 template <class T> class vtkObjectVector;
25 template <class T> class vtkList;
26 template <class T> class vtkMedComputeStepMap;
28 #define vtkGetObjectVectorMacro(name, type)\
29 virtual type* Get##name (int index);\
30 virtual vtkIdType GetNumberOf##name ();
32 #define vtkSetObjectVectorMacro(name, type)\
33 virtual void AllocateNumberOf##name (vtkIdType size);\
34 virtual void Set##name (vtkIdType index, type* obj);\
35 virtual void Append##name (type* obj);\
36 virtual void Remove##name (type* obj);
38 #define vtkSetAbstractObjectVectorMacro(name, type)\
39 virtual void SetNumberOf##name (vtkIdType size);\
40 virtual void Set##name (vtkIdType index, type* obj);\
41 virtual void Append##name (type* obj);
43 #define vtkCxxGetObjectVectorMacro(class, name, type)\
44 type* class::Get##name (int index)\
46 if(index < 0 || index >= this->name->size())\
48 return this->name->at(index);\
50 vtkIdType class::GetNumberOf##name ()\
52 return this->name->size();\
55 #define vtkCxxSetObjectVectorMacro(class, name, type)\
56 void class::AllocateNumberOf##name (vtkIdType size)\
58 if(this->name->size() == size)\
63 this->name->resize(size);\
64 for(vtkIdType _ii=0; _ii<this->name->size(); _ii++)\
66 this->name->at(_ii) = vtkSmartPointer< type > ::New();\
70 void class::Set##name (vtkIdType index, type* obj)\
72 if(index < 0 || index >= this->name->size())\
74 vtkWarningMacro("has not been allocated before setting value" );\
77 if( this->name->at(index) == obj)\
79 this->name->at(index) = obj; \
82 void class::Append##name (type* obj)\
84 this->name->resize(this->name->size()+1);\
85 this->name->at(this->name->size()-1) = obj;\
88 void class::Remove##name (type* obj)\
91 for(index=0; index < this->name->size(); index++)\
93 if(this->name->at(index) == obj) break;\
95 if(index == this->name->size()) return;\
96 for(vtkIdType id=index; id < this->name->size()-1; id++)\
98 this->name->at(id) = this->name->at(id+1);\
100 this->name->resize(this->name->size()-1);\
104 #define vtkCxxSetAbstractObjectVectorMacro(class, name, type)\
105 void class::SetNumberOf##name (vtkIdType size)\
107 if(this->name->size() == size)\
110 this->name->clear();\
112 this->name->resize(size);\
115 void class::Set##name (vtkIdType index, type* obj)\
117 if(index < 0 || index >= this->name->size())\
119 vtkWarningMacro("has not been allocated before setting value" );\
122 if( this->name->at(index) == obj)\
124 this->name->at(index) = obj; \
127 void class::Append##name (type* obj)\
129 this->name->resize(this->name->size()+1);\
130 this->name->at(this->name->size()-1) = obj;\