SST/macro
serialize_vector.h
Go to the documentation of this file.
1 #ifndef SERIALIZE_VECTOR_H
2 #define SERIALIZE_VECTOR_H
3 
4 #include <vector>
5 #include <sprockit/serializer.h>
6 
7 namespace sprockit {
8 
9 template <class T>
10 class serialize<std::vector<T> > {
11  typedef std::vector<T> Vector;
12  public:
13  void
14  operator()(Vector& v, serializer& ser) {
15  switch(ser.mode())
16  {
17  case serializer::SIZER: {
18  size_t size = v.size();
19  ser.size(size);
20  break;
21  }
22  case serializer::PACK: {
23  size_t size = v.size();
24  ser.pack(size);
25  break;
26  }
27  case serializer::UNPACK: {
28  size_t s;
29  ser.unpack(s);
30  v.resize(s);
31  break;
32  }
33  }
34 
35  for (int i=0; i < v.size(); ++i){
36  serialize<T>()(v[i], ser);
37  }
38  }
39 
40 };
41 
42 }
43 
44 #endif // SERIALIZE_VECTOR_H
void unpack(T &t)
Definition: serializer.h:75
void operator()(Vector &v, serializer &ser)
SERIALIZE_MODE mode() const
Definition: serializer.h:84
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:33