Activator.cpp
Go to the documentation of this file.
1 #include "Activator.hpp"
2 
3 namespace iv
4 {
5 
7  _value( 0 )
8 {
9 }
10 
11 Activator::Activator( unsigned char initial ) :
12  _value( initial )
13 {
14 }
15 
16 bool Activator::operator==( Activator const & other ) const
17 {
18  return this->_value == other._value;
19 }
20 
21 bool Activator::operator!=( Activator const & other ) const
22 {
23  return this->_value != other._value;
24 }
25 
26 bool Activator::operator<( Activator const & other ) const
27 {
28  return std::tie( this->_value ) < std::tie( other._value );
29 }
30 
31 unsigned char Activator::ReadActivations( Activator const & reference ) const
32 {
33  unsigned top = this->_value;
34  unsigned bot = reference._value;
35  if( top < bot )
36  top += 256;
37  return top - bot;
38 }
39 
40 unsigned char Activator::CopyActivations( Activator & reference ) const
41 {
42  auto act = this->ReadActivations( reference );
43  reference._value = this->_value;
44  return act;
45 }
46 
47 bool Activator::CopyActivation( Activator & reference ) const
48 {
49  if( this->_value == reference._value )
50  return false;
51  reference._value++;
52  return true;
53 }
54 
56 {
57  Activator result = *this;
58  result._value++;
59  return result;
60 }
61 
62 unsigned char Activator::Value() const
63 {
64  return this->_value;
65 }
66 
67 }