Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
min_module.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 20.07.2013 11:26:59 EDT
3 // File: min_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 __MIN_MODULE_HEADER
12 #define __MIN_MODULE_HEADER
13 
14 #include "module.hpp"
15 
16 namespace ustd {
17  namespace detail {
18  template<>
19  struct requirement<tag::min> {
20  typedef util::list_end type;
21  };
22  }//end namespace detail
23 
24  template<typename T, typename _base>
25  class module<T, tag::min, _base>: public _base {
26  typedef _base base;
27  T const init_min = T(1023);
28  public:
29  //------------------- ctor -------------------
30  module(): base(), min_(init_min) { //just heuristics for now
31  }
32  //------------------- ops -------------------
33  void operator<<(T const & in) {
34  base::operator<<(in);
35  if(in < min_)
36  min_ = in;
37  }
38  //------------------- fct -------------------
39  T const & min() {
40  return min_;
41  }
42  void clear() {
43  base::clear();
44  min_ = init_min;
45  }
46  private:
47  T min_;
48  };
49 }//end namespace ustd
50 
51 #endif //__MIN_MODULE_HEADER
S & operator<<(S &os, oss_class< D, max_buf > const &arg)
Definition: serializer.hpp:158
T const & min()
Definition: min_module.hpp:39
Definition: module.hpp:33
void operator<<(T const &in)
Definition: min_module.hpp:33
module()
Definition: min_module.hpp:30
void clear()
Definition: min_module.hpp:42
Definition: meta_list.hpp:22