SST/macro
serialize_array.h
Go to the documentation of this file.
1 #ifndef SERIALIZE_ARRAY_H
2 #define SERIALIZE_ARRAY_H
3 
4 #include <sprockit/serializer.h>
5 
6 namespace sprockit {
7 namespace pvt {
8 
9 template <class TPtr, class IntType>
11 {
12  public:
13  TPtr& bufptr;
14  IntType& sizeptr;
15  ser_array_wrapper(TPtr& buf, IntType& size) :
16  bufptr(buf), sizeptr(size) {}
17 
18 };
19 
20 template <class TPtr>
22 {
23 public:
24  TPtr*& bufptr;
25  raw_ptr_wrapper(TPtr*& ptr) :
26  bufptr(ptr) {}
27 };
28 
29 }
30 
31 template <class T, int N>
32 class serialize<T[N]> {
33  public:
34  void operator()(T arr[N], serializer& ser){
35  ser.array<T,N>(arr);
36  }
37 };
38 
39 /** I have typedefing pointers, but no other way.
40  * T could be "void and TPtr void* */
41 template <class TPtr, class IntType>
43 array(TPtr& buf, IntType& size)
44 {
45  return pvt::ser_array_wrapper<TPtr,IntType>(buf, size);
46 }
47 
48 template <class TPtr>
50 raw_ptr(TPtr*& ptr)
51 {
52  return pvt::raw_ptr_wrapper<TPtr>(ptr);
53 }
54 
55 template <class TPtr, class IntType>
56 inline void
58  ser.binary(arr.bufptr, arr.sizeptr);
59 }
60 
61 // Needed only because the default version in serialize.h can't get
62 // the template expansions quite right trying to look through several
63 // levels of expansion
64 template <class TPtr>
65 inline void
67  ser.primitive(ptr.bufptr);
68 }
69 
70 }
71 
72 #endif // SERIALIZE_ARRAY_H
debug_int operator&(const debug_int &lhs, const debug_int &rhs)
Definition: debug.h:80
void array(T arr[N])
Definition: serializer.h:119
void operator()(T arr[N], serializer &ser)
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:33
void binary(T *&buffer, Int &size)
Definition: serializer.h:141
pvt::ser_array_wrapper< TPtr, IntType > array(TPtr &buf, IntType &size)
I have typedefing pointers, but no other way.
ser_array_wrapper(TPtr &buf, IntType &size)
void primitive(T &t)
Definition: serializer.h:102
pvt::raw_ptr_wrapper< TPtr > raw_ptr(TPtr *&ptr)