Remote Call Framework 3.3
SerializeAny.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2022, Delta V Software. All rights reserved.
6 // https://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF under GPL terms.
12 //
13 // Version: 3.3
14 // Contact: support <at> deltavsoft.com
15 //
16 //******************************************************************************
17 
18 #ifndef INCLUDE_SF_SERIALIZEANY_HPP
19 #define INCLUDE_SF_SERIALIZEANY_HPP
20 
21 #include <boost/any.hpp>
22 
23 namespace SF {
24 
25  class Archive;
26 
27  class I_SerializerAny
28  {
29  public:
30  virtual ~I_SerializerAny()
31  {}
32 
33  virtual void serialize(
34  SF::Archive &ar,
35  boost::any &a) = 0;
36  };
37 
38  template<typename T>
39  class SerializerAny : public I_SerializerAny
40  {
41  public:
42  void serialize(SF::Archive &ar, boost::any &a);
43  };
44 
45 } // namespace SF
46 
47 #include <SF/Archive.hpp>
48 
49 namespace SF {
50 
51  template<typename T>
52  void SerializerAny<T>::serialize(SF::Archive &ar, boost::any &a)
53  {
54  if (ar.isWrite())
55  {
56  ar & boost::any_cast<T>(a);
57  }
58  else
59  {
60  T t;
61  ar & t;
62  a = t;
63  }
64  }
65 
66 } // namespace SF
67 
68 #endif // ! INCLUDE_SF_SERIALIZEANY_HPP
Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:31
Definition: ByteBuffer.hpp:188
bool isWrite() const
Returns true if this archive is being written to.