Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00040 #ifndef __vtkKWESerializer_h
00041 #define __vtkKWESerializer_h
00042
00043 #include "vtkObject.h"
00044 #include "VTKEdgeConfigure.h"
00045
00046 #include "vtkSmartPointer.h"
00047 #include <vtkstd/vector>
00048 #include <vtkstd/map>
00049
00050 class vtkInformation;
00051
00052 class VTKEdge_IO_EXPORT vtkKWESerializer : public vtkObject
00053 {
00054 public:
00055 vtkTypeRevisionMacro(vtkKWESerializer,vtkObject);
00056 void PrintSelf(ostream& os, vtkIndent indent);
00057
00060 virtual bool IsWriting() = 0;
00061
00063 virtual void Serialize(const char* name, int& val) = 0;
00064
00066 virtual void Serialize(const char* name, int*& val, unsigned int& length) = 0;
00067
00069 virtual void Serialize(const char* name, unsigned long& val) = 0;
00070
00072 virtual void Serialize(const char* name, unsigned long*& val, unsigned int& length) = 0;
00073
00075
00076 #if defined(VTK_USE_64BIT_IDS)
00077 virtual void Serialize(const char* name, vtkIdType& val) = 0;
00078 #endif
00079
00080
00082
00083 #if defined(VTK_USE_64BIT_IDS)
00084 virtual void Serialize(const char* name, vtkIdType*& val, unsigned int& length) = 0;
00085 #endif
00086
00087
00089 virtual void Serialize(const char* name, double& val) = 0;
00090
00092 virtual void Serialize(const char* name, double*& val, unsigned int& length) = 0;
00093
00095 virtual void Serialize(const char* name, char*& str) = 0;
00096
00098 virtual void Serialize(const char* name, vtkstd::string& str) = 0;
00099
00101 virtual void Serialize(const char* name, vtkObject*& obj, bool weakPtr = false) = 0;
00102
00105 virtual void Serialize(const char* name, vtkInformation* info) = 0;
00106
00108
00109 virtual void Serialize(const char* name,
00110 vtkstd::vector<vtkSmartPointer<vtkObject> >& objs,
00111 bool weakPtr = false) = 0;
00113
00115
00116 virtual void Serialize(const char* name,
00117 vtkstd::map<int, vtkstd::vector<vtkSmartPointer<vtkObject> > >& objs) = 0;
00119
00121
00124 vtkSetMacro(ArchiveVersion, unsigned int);
00125 vtkGetMacro(ArchiveVersion, unsigned int);
00127
00129
00136 template <typename Container>
00137 static vtkstd::vector<vtkSmartPointer<vtkObject> > ToBase(Container& from)
00138 {
00139 vtkstd::vector<vtkSmartPointer<vtkObject> > retVal;
00140 typename Container::iterator iter = from.begin();
00141 for(; iter != from.end(); iter++)
00142 {
00143 retVal.push_back(*iter);
00144 }
00145 return retVal;
00146 }
00148
00150
00158 template <typename T, typename Container>
00159 static void FromBase(
00160 vtkstd::vector<vtkSmartPointer<vtkObject> >& from, Container& to)
00161 {
00162 vtkstd::vector<vtkSmartPointer<vtkObject> >::iterator iter =
00163 from.begin();
00164 for(; iter != from.end(); iter++)
00165 {
00166
00167 to.insert(to.end(), static_cast<T*>(iter->GetPointer()));
00168 }
00169 }
00171
00173
00179 template <typename Container>
00180 static vtkstd::map<int, vtkstd::vector<vtkSmartPointer<vtkObject> > >
00181 ToBase(vtkstd::map<int, Container>& from)
00182 {
00183 vtkstd::map<int, vtkstd::vector<vtkSmartPointer<vtkObject> > > retVal;
00184 typename vtkstd::map<int, Container>::iterator iter =
00185 from.begin();
00186 for(; iter != from.end(); iter++)
00187 {
00188 retVal[iter->first] = (ToBase<Container>(iter->second));
00189 }
00190 return retVal;
00191 }
00193
00195
00202 template <typename T, typename Container>
00203 static void FromBase(
00204 vtkstd::map<int, vtkstd::vector<vtkSmartPointer<vtkObject> > >& from,
00205 vtkstd::map<int, Container>& to)
00206 {
00207 vtkstd::map<int, vtkstd::vector<vtkSmartPointer<vtkObject> > >::iterator iter = from.begin();
00208 for(; iter != from.end(); iter++)
00209 {
00210 vtkstd::vector<vtkSmartPointer<vtkObject> >& f =
00211 iter->second;
00212 Container& t = to[iter->first];
00213 FromBase<T, Container>(f, t);
00214 }
00215 }
00217
00218 protected:
00219 vtkKWESerializer();
00220 ~vtkKWESerializer() {}
00221
00222 private:
00223 vtkKWESerializer(const vtkKWESerializer&);
00224 void operator=(const vtkKWESerializer&);
00225
00226 unsigned int ArchiveVersion;
00227 };
00228
00229 #endif