Overte C++ Documentation
Bilateral.h
1 //
2 // Created by Bradley Austin Davis 2015/10/09
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #pragma once
10 
11 namespace bilateral {
12  enum class Side {
13  Left = 0,
14  Right = 1,
15  Invalid = -1
16  };
17 
18  using Indices = Side;
19 
20  enum class Bits {
21  Left = 0x01,
22  Right = 0x02
23  };
24 
25  inline uint8_t bit(Side side) {
26  switch (side) {
27  case Side::Left:
28  return 0x01;
29  case Side::Right:
30  return 0x02;
31  default:
32  break;
33  }
34  return 0x00;
35  }
36 
37  inline uint8_t index(Side side) {
38  switch (side) {
39  case Side::Left:
40  return 0;
41  case Side::Right:
42  return 1;
43  default:
44  break;
45  }
46  return std::numeric_limits<uint8_t>::max();
47  }
48 
49  inline Side side(int index) {
50  switch (index) {
51  case 0:
52  return Side::Left;
53  case 1:
54  return Side::Right;
55  default:
56  break;
57  }
58  return Side::Invalid;
59  }
60 
61  template <typename F>
62  void for_each_side(F f) {
63  f(Side::Left);
64  f(Side::Right);
65  }
66 }