Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
Savepoint.h
Go to the documentation of this file.
1 //===-- serialbox/core/frontend/stella/Savepoint.h ----------------------------------*- C++ -*-===//
2 //
3 // S E R I A L B O X
4 //
5 // This file is distributed under terms of BSD license.
6 // See LICENSE.txt for more information
7 //
8 //===------------------------------------------------------------------------------------------===//
9 //
13 //===------------------------------------------------------------------------------------------===//
14 
15 #ifndef SERIALBOX_CORE_FRONTEND_STELLA_SAVEPOINT_H
16 #define SERIALBOX_CORE_FRONTEND_STELLA_SAVEPOINT_H
17 
20 #include <iosfwd>
21 #include <string>
22 
23 namespace serialbox {
24 
25 namespace stella {
26 
30 class Savepoint {
31 public:
33  Savepoint();
34 
45  void Init(const std::string& name);
46 
48  explicit Savepoint(const boost::shared_ptr<SavepointImpl>& savepointImpl);
49 
51  Savepoint(const Savepoint& other);
52 
54  Savepoint& operator=(const Savepoint& other);
55 
66  void AddMetainfo(const std::string& key, const bool& value);
67  void AddMetainfo(const std::string& key, const int& value);
68  void AddMetainfo(const std::string& key, const float& value);
69  void AddMetainfo(const std::string& key, const double& value);
70  void AddMetainfo(const std::string& key, const std::string& value);
71  void AddMetainfo(const std::string& key, const char* value) {
72  AddMetainfo(key, std::string(value));
73  }
75 
77  const std::string& name() const;
78 
82  const MetainfoSet& metainfo() const { return metainfo_; }
83 
85  bool operator==(const Savepoint& other) const;
86 
88  bool operator!=(const Savepoint& other) const;
89 
91  std::string ToString() const;
92 
94  friend std::ostream& operator<<(std::ostream& out, const Savepoint& sp);
95 
97  void setImpl(const boost::shared_ptr<SavepointImpl>& savepointImpl);
98 
100  boost::shared_ptr<SavepointImpl>& getImpl();
101  const boost::shared_ptr<SavepointImpl>& getImpl() const;
102 
103 private:
104  boost::shared_ptr<SavepointImpl> savepointImpl_;
105  MetainfoSet metainfo_; // Allow refrence access
106 };
107 
108 } // namespace stella
109 
110 } // namespace serialbox
111 
112 #endif
void setImpl(const boost::shared_ptr< SavepointImpl > &savepointImpl)
Set implementation pointer.
Definition: Savepoint.cpp:99
Namespace of the STELLA frontend.
Definition: ForwardDecl.h:27
Namespace of the serialbox library.
Definition: Archive.h:25
Meta-information set.
Definition: MetainfoSet.h:36
bool operator==(const Savepoint &other) const
Compare equal.
Definition: Savepoint.cpp:85
void Init(const std::string &name)
Initialize the savepoint.
Definition: Savepoint.cpp:40
Implementation of the STELLA Savepoint.
Definition: Savepoint.h:30
Savepoint & operator=(const Savepoint &other)
Copy assignment.
Definition: Savepoint.cpp:54
void AddMetainfo(const std::string &key, const bool &value)
Add metainformation to the savepoint.
Definition: Savepoint.cpp:65
Savepoint()
Construct empty savepoint with name name
Definition: Savepoint.cpp:38
const std::string & name() const
Access to the name.
Definition: Savepoint.cpp:93
boost::shared_ptr< SavepointImpl > & getImpl()
Get implementation pointer.
Definition: Savepoint.cpp:104
const MetainfoSet & metainfo() const
Access to the metainfo.
Definition: Savepoint.h:82
friend std::ostream & operator<<(std::ostream &out, const Savepoint &sp)
Convert to stream.
Definition: Savepoint.cpp:97
bool operator!=(const Savepoint &other) const
Compare unequal.
Definition: Savepoint.cpp:89
std::string ToString() const
Convert to string.
Definition: Savepoint.cpp:95