Classdesc  3.D29
polyPackBase.h
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of Classdesc
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
9 #ifndef POLYPACKBASE_H
10 #define POLYPACKBASE_H
11 
13 #include "pack_base.h"
14 
15 namespace classdesc
16 {
18  struct PolyPackBase
19  {
20  virtual void pack(pack_t&, const string&) const=0;
21  virtual void unpack(unpack_t&, const string&)=0;
22  virtual ~PolyPackBase() {}
23  };
24 
26 
44  template <class T>
45  struct PolyPack: virtual public PolyPackBase
46  {
47  void pack(pack_t& x, const string& d) const
48  {::pack(x,d,static_cast<const T&>(*this));}
49 
50  void unpack(unpack_t& x, const string& d)
51  {::unpack(x,d,static_cast<T&>(*this));}
52 
53  };
54 
55  template <> struct tn<PolyPackBase>
56  {
57  static std::string name()
58  {return "classdesc::PolyPackBase";}
59  };
60  template <class T> struct tn<PolyPack<T> >
61  {
62  static std::string name()
63  {return "classdesc::PolyPack<"+typeName<T>()+">";}
64  };
65 }
66 #endif
67 
Definition: classdesc.h:400
serialisation descriptor
utility class for defining pack descriptors for polymorphic types
Definition: polyPackBase.h:45
Definition: pack_base.h:124
interface for applying pack descriptors to polymorphic objects
Definition: polyPackBase.h:18