Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
count_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:14 EDT
3 // File: countag::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 __COUNT_MODULE_HEADER
12 #define __COUNT_MODULE_HEADER
13 
14 #include "module.hpp"
15 
16 namespace ustd {
17  namespace detail {
18  template<>
19  struct requirement<tag::count> {
20  typedef util::list_end type;
21  };
22  }//end namespace detail
23 
24  template<typename T, typename _base>
25  class module<T, tag::count, _base>: public _base {
26  typedef _base base;
27  public:
28  typedef module type;
29  typedef size_t size_type;
30  //------------------- ctor -------------------
31  module(): base(), count_(0) {
32  }
33  //------------------- ops -------------------
34  void operator<<(T const & in) {
35  base::operator<<(in);
36  ++count_;
37  }
38  //------------------- fct -------------------
39  size_type const & count() const {
40  return count_;
41  }
42  void clear() {
43  base::clear();
44  count_ = size_type();
45  }
46  private:
47  size_type count_;
48  };
49 }//end namespace ustd
50 
51 #endif //__COUNT_MODULE_HEADER
module()
Definition: count_module.hpp:31
size_type const & count() const
Definition: count_module.hpp:39
S & operator<<(S &os, oss_class< D, max_buf > const &arg)
Definition: serializer.hpp:158
module type
Definition: count_module.hpp:28
Definition: module.hpp:33
void operator<<(T const &in)
Definition: count_module.hpp:34
size_t size_type
Definition: count_module.hpp:29
Definition: meta_list.hpp:22
void clear()
Definition: count_module.hpp:42