jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
version.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2013 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_COMMON_VERSION_HPP_
18 #define JUBATUS_CORE_COMMON_VERSION_HPP_
19 
20 #include <stdint.h>
21 #include <ostream>
22 #include <msgpack.hpp>
23 
24 namespace jubatus {
25 namespace core {
26 namespace storage {
27 
28 class version {
29  public:
30  version() : version_number_(0LLU) {}
31 
32  void increment() {
34  }
35 
36  uint64_t get_number() const {
37  return version_number_;
38  }
39 
41 
42  friend std::ostream& operator<<(std::ostream& os, const version& v);
43 
44  void set_number_unsafe(uint64_t n) {
45  // used for test only
46  version_number_ = n;
47  }
48 
49  friend bool operator==(const version& lhs, const version& rhs) {
50  return lhs.version_number_ == rhs.version_number_;
51  }
52  friend bool operator!=(const version& lhs, const version& rhs) {
53  return !(lhs == rhs);
54  }
55  friend bool operator<(const version& lhs, const version& rhs) {
56  return lhs.version_number_ < rhs.version_number_;
57  }
58  friend bool operator>(const version& lhs, const version& rhs) {
59  return rhs < lhs;
60  }
61  friend bool operator>=(const version& lhs, const version& rhs) {
62  return !(lhs < rhs);
63  }
64  friend bool operator<=(const version& lhs, const version& rhs) {
65  return !(lhs > rhs);
66  }
67 
68  void reset() {
69  version_number_ = 0;
70  }
71 
72  template<class Packer>
73  void pack(Packer& packer) const {
74  packer.pack(*this);
75  }
76 
77  void unpack(msgpack::object o) {
78  o.convert(this);
79  }
80 
81  private:
82  uint64_t version_number_;
83 };
84 
85 } // namespace storage
86 } // namespace core
87 } // namespace jubatus
88 
89 #endif // JUBATUS_CORE_COMMON_VERSION_HPP_
friend bool operator<(const version &lhs, const version &rhs)
Definition: version.hpp:55
friend bool operator!=(const version &lhs, const version &rhs)
Definition: version.hpp:52
uint64_t get_number() const
Definition: version.hpp:36
friend bool operator<=(const version &lhs, const version &rhs)
Definition: version.hpp:64
friend bool operator>(const version &lhs, const version &rhs)
Definition: version.hpp:58
friend bool operator>=(const version &lhs, const version &rhs)
Definition: version.hpp:61
void set_number_unsafe(uint64_t n)
Definition: version.hpp:44
friend bool operator==(const version &lhs, const version &rhs)
Definition: version.hpp:49
void pack(Packer &packer) const
Definition: version.hpp:73
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
std::vector< T > v(size)
friend std::ostream & operator<<(std::ostream &os, const version &v)
Definition: version.cpp:24
void unpack(msgpack::object o)
Definition: version.hpp:77