Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
max_module.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 20.07.2013 11:27:07 EDT
3 // File: max_module.hpp
4 
5 /* This program is free software. It comes without any warranty, to
6  * the extent permitted by applicable law. You can redistribute it
7  * and/or modify it under the terms of the Do What The Fuck You Want
8  * To Public License, Version 2, as published by Sam Hocevar. See
9  * http://www.wtfpl.net/ or COPYING for more details. */
10 
11 #ifndef __MAX_MODULE_HEADER
12 #define __MAX_MODULE_HEADER
13 
14 #include "module.hpp"
15 
16 namespace ustd {
17  namespace detail {
18  template<>
19  struct requirement<tag::max> {
20  typedef util::list_end type;
21  };
22  }//end namespace detail
23 
24  template<typename T, typename _base>
25  class module<T, tag::max, _base>: public _base {
26  typedef _base base;
27  T const init_max = T();
28  public:
29  //------------------- ctor -------------------
30  module(): base(), max_(init_max) {
31  }
32  //------------------- ops -------------------
33  void operator<<(T const & in) {
34  base::operator<<(in);
35  if(in > max_)
36  max_ = in;
37  }
38  //------------------- fct -------------------
39  T const & max() {
40  return max_;
41  }
42  void clear() {
43  base::clear();
44  max_ = init_max;
45  }
46  private:
47  T max_;
48  };
49 }//end namespace ustd
50 
51 #endif //__MAX_MODULE_HEADER
S & operator<<(S &os, oss_class< D, max_buf > const &arg)
Definition: serializer.hpp:158
void operator<<(T const &in)
Definition: max_module.hpp:33
Definition: module.hpp:33
void clear()
Definition: max_module.hpp:42
T const & max()
Definition: max_module.hpp:39
module()
Definition: max_module.hpp:30
Definition: meta_list.hpp:22