Serializable.h 2.47 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file Serializable.h */

#ifndef AMDIS_SERIALIZABLE_H
#define AMDIS_SERIALIZABLE_H

#include <iostream>
#include <string>

namespace AMDiS {

  // ===============================================================================
  // ===== class Serializable ======================================================
  // ===============================================================================

  /** \brief
   * Interface for JAVA-like serialization of objects. Serializable objects can be
   * written to an out stream and read from an in stream. So i.e. they can be stored
   * on hard disk.
   */
  class Serializable
  {
  public:
    /** \brief
     * Streams the object to output stream out.
     */
45
    virtual void serialize(std::ostream &out) = 0;
46
47
48
49

    /** \brief
     * Reads the object from input stream in.
     */
50
    virtual void deserialize(std::istream &in) = 0;
51
52
53
54

    /** \brief
     * Returns the type name for this serializable object.
     */
55
56
57
    virtual std::string getTypeName() const { 
      return ""; 
    }
58

59
    virtual ~Serializable() {}
60
61
62
63
64
  };

}

#endif