OSVR-Core
Stride.h
Go to the documentation of this file.
1 
25 // Copyright Iowa State University 2009-2010.
26 // Distributed under the Boost Software License, Version 1.0.
27 // (See accompanying file LICENSE_1_0.txt or copy at
28 // http://www.boost.org/LICENSE_1_0.txt)
29 
30 #pragma once
31 #ifndef INCLUDED_Stride_h_GUID_eaa50b9c_e526_4656_89dc_99008d82447d
32 #define INCLUDED_Stride_h_GUID_eaa50b9c_e526_4656_89dc_99008d82447d
33 
34 // Local includes
35 // - none
36 
37 // Library includes
38 // - none
39 
40 // Standard includes
41 // - none
42 
43 namespace util {
44 
47 
49  class Stride {
50  public:
51  Stride(const unsigned int n) :
52  _stride(n),
53  _step(0) { }
54 
55  void advance() {
56  _step = (_step + 1) % _stride;
57  }
58 
59  Stride operator++() {
60  Stride temp = *this;
61  advance();
62  return temp;
63  }
64 
65  Stride & operator++(int) {
66  advance();
67  return *this;
68  }
69 
70  operator bool() const {
71  return _step == 0;
72  }
73 
74  private:
75  unsigned int _stride;
76  unsigned int _step;
77  };
78 
80 
81 } // end of util namespace
82 
83 #endif // INCLUDED_Stride_h_GUID_eaa50b9c_e526_4656_89dc_99008d82447d
84 
Definition: RunLoopManager.h:42
Handle the task of "do this every n times" in an easy way.
Definition: Stride.h:49