Back to index

salome-paravis  6.5.0
vtkMedSetGet.h
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef _vtkMedSetGet_h_
00021 #define _vtkMedSetGet_h_
00022 
00023 //BTX
00024 template <class T> class vtkObjectVector;
00025 template <class T> class vtkList;
00026 template <class T> class vtkMedComputeStepMap;
00027 
00028 #define vtkGetObjectVectorMacro(name, type)\
00029   virtual type* Get##name (int index);\
00030   virtual vtkIdType GetNumberOf##name ();
00031 
00032 #define vtkSetObjectVectorMacro(name, type)\
00033   virtual void  AllocateNumberOf##name (vtkIdType size);\
00034   virtual void  Set##name (vtkIdType index, type* obj);\
00035   virtual void  Append##name (type* obj);\
00036   virtual void  Remove##name (type* obj);
00037 
00038 #define vtkSetAbstractObjectVectorMacro(name, type)\
00039   virtual void SetNumberOf##name (vtkIdType size);\
00040   virtual void Set##name (vtkIdType index, type* obj);\
00041   virtual void Append##name (type* obj);
00042 
00043 #define vtkCxxGetObjectVectorMacro(class, name, type)\
00044   type* class::Get##name (int index)\
00045   {\
00046     if(index < 0 || index >= this->name->size())\
00047       return NULL;\
00048     return this->name->at(index);\
00049   }\
00050   vtkIdType class::GetNumberOf##name ()\
00051   {\
00052     return this->name->size();\
00053   }
00054 
00055 #define vtkCxxSetObjectVectorMacro(class, name, type)\
00056   void  class::AllocateNumberOf##name (vtkIdType size)\
00057   {\
00058     if(this->name->size() == size)\
00059       return;\
00060     if(size <= 0 )\
00061       this->name->clear();\
00062     else\
00063       this->name->resize(size);\
00064     for(vtkIdType _ii=0; _ii<this->name->size(); _ii++)\
00065       {\
00066         this->name->at(_ii) = vtkSmartPointer< type > ::New();\
00067       }\
00068     this->Modified();\
00069   }\
00070   void class::Set##name (vtkIdType index, type* obj)\
00071   {\
00072     if(index < 0 || index >= this->name->size())\
00073     {\
00074       vtkWarningMacro("has not been allocated before setting value" );\
00075       return;\
00076     }\
00077     if( this->name->at(index) == obj)\
00078       return;\
00079     this->name->at(index) = obj; \
00080     this->Modified();\
00081   }\
00082   void  class::Append##name (type* obj)\
00083   {\
00084     this->name->resize(this->name->size()+1);\
00085     this->name->at(this->name->size()-1) = obj;\
00086     this->Modified();\
00087   }\
00088   void  class::Remove##name (type* obj)\
00089   {\
00090     vtkIdType index=0;\
00091     for(index=0; index < this->name->size(); index++)\
00092      {\
00093        if(this->name->at(index) == obj) break;\
00094      }\
00095     if(index == this->name->size()) return;\
00096     for(vtkIdType id=index; id < this->name->size()-1; id++)\
00097       {\
00098         this->name->at(id) = this->name->at(id+1);\
00099       }\
00100     this->name->resize(this->name->size()-1);\
00101     this->Modified();\
00102   }
00103 
00104 #define vtkCxxSetAbstractObjectVectorMacro(class, name, type)\
00105   void  class::SetNumberOf##name (vtkIdType size)\
00106   {\
00107     if(this->name->size() == size)\
00108       return;\
00109     if(size <= 0 )\
00110       this->name->clear();\
00111     else\
00112       this->name->resize(size);\
00113     this->Modified();\
00114   }\
00115   void class::Set##name (vtkIdType index, type* obj)\
00116   {\
00117     if(index < 0 || index >= this->name->size())\
00118     {\
00119       vtkWarningMacro("has not been allocated before setting value" );\
00120       return;\
00121     }\
00122     if( this->name->at(index) == obj)\
00123       return;\
00124     this->name->at(index) = obj; \
00125     this->Modified();\
00126   }\
00127   void  class::Append##name (type* obj)\
00128   {\
00129     this->name->resize(this->name->size()+1);\
00130     this->name->at(this->name->size()-1) = obj;\
00131     this->Modified();\
00132   }
00133 
00134 //ETX
00135 
00136 #endif