OSVR-Core
DefaultBool.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_DefaultBool_h_GUID_3AFC9D48_7BCD_4AAD_CC67_E3FE744CF724
26 #define INCLUDED_DefaultBool_h_GUID_3AFC9D48_7BCD_4AAD_CC67_E3FE744CF724
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 // - none
36 
37 namespace osvr {
38 namespace util {
41  template <bool DefaultValue = false> class DefaultBool {
42  public:
44  DefaultBool() : m_val(DefaultValue) {}
45 
47  explicit operator bool() const { return m_val; }
48 
50  DefaultBool &operator=(bool val) {
51  m_val = val;
52  return *this;
53  }
54 
56  void reset() { m_val = DefaultValue; }
57 
58  private:
59  bool m_val;
60  };
61 
62 } // namespace util
63 } // namespace osvr
64 #endif // INCLUDED_DefaultBool_h_GUID_3AFC9D48_7BCD_4AAD_CC67_E3FE744CF724
DefaultBool & operator=(bool val)
Assignment from a bool.
Definition: DefaultBool.h:50
Definition: RunLoopManager.h:42
void reset()
Restore the default value.
Definition: DefaultBool.h:56
A class template primarily useful for flags, that has a defined value at default initialization.
Definition: DefaultBool.h:41
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
DefaultBool()
Default constructor, initializes value to specified default.
Definition: DefaultBool.h:44