RDK Documentation (Open Sourced RDK Components)
Condition.hpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 /*****************************************************************************/
20 /*!
21 \file
22 \brief This file defines interface of Condition class.
23 
24 */
25 /*****************************************************************************/
26 
27 
28 /**
29 * @defgroup hdmicec
30 * @{
31 * @defgroup osal
32 * @{
33 **/
34 
35 
36 #ifndef HDMI_CCEC_OSAL_CONDITION_HPP_
37 #define HDMI_CCEC_OSAL_CONDITION_HPP_
38 
39 #include "OSAL.hpp"
40 
41 CCEC_OSAL_BEGIN_NAMESPACE
42 
43 /***************************************************************************/
44 /*!
45 
46 This is a simple class which abstract boolean functionality and is used by
47 ConditionVariable class.
48 
49 */
50 /**************************************************************************/
51 
52 class Condition {
53 public:
54 /***************************************************************************/
55 /*!
56 \brief Constructor.
57 Creates an Condition object with state set to false.
58 
59 */
60 /**************************************************************************/
61 
62  Condition(void) : cond(false) {};
63 /***************************************************************************/
64 /*!
65 \brief Constructor.
66 Creates an Condition object with state set to given parameter.
67 
68 \param initial - initial state to be set. This will be set as default state
69 of the object as well.
70 */
71 /**************************************************************************/
72 
73  Condition(bool initial) : cond(initial) {this->initial = initial;};
74 /***************************************************************************/
75 /*!
76 \brief Destructor.
77 Destroys the Condition object.
78 */
79 /**************************************************************************/
80 
81  ~Condition() {};
82 
83 /***************************************************************************/
84 /*!
85 \brief Set the state of the object.
86 Sets the state of the object, which will be either true/false.
87 
88 \param cond - state to be set.This will default to true is method called with
89  no parameters.
90 */
91 /**************************************************************************/
92 
93  virtual void set(void) {cond = true;};
94 
95 /***************************************************************************/
96 /*!
97 \brief Check the state of the object.
98 Returns the state of the object, which will be either true/false.
99 
100 \return true if set and false if not set.
101 */
102 /**************************************************************************/
103  virtual bool isSet(void) {return cond;};
104 
105 /***************************************************************************/
106 /*!
107 \brief Resets the state of the object.
108 Reset the state of object to default, which is set while creating the object.
109 
110 */
111 /**************************************************************************/
112 
113  virtual void reset(void) {cond = initial;};
114 private:
115  bool initial;
116  bool cond;
117 };
118 
119 CCEC_OSAL_END_NAMESPACE
120 
121 #endif
122 
123 
124 /** @} */
125 /** @} */
CCEC_OSAL::Condition::isSet
virtual bool isSet(void)
Check the state of the object. Returns the state of the object, which will be either true/false.
Definition: Condition.hpp:103
CCEC_OSAL::Condition
Definition: Condition.hpp:52
CCEC_OSAL::Condition::set
virtual void set(void)
Set the state of the object. Sets the state of the object, which will be either true/false.
Definition: Condition.hpp:93
CCEC_OSAL::Condition::~Condition
~Condition()
Destructor. Destroys the Condition object.
Definition: Condition.hpp:81
CCEC_OSAL::Condition::reset
virtual void reset(void)
Resets the state of the object. Reset the state of object to default, which is set while creating the...
Definition: Condition.hpp:113
CCEC_OSAL::Condition::Condition
Condition(bool initial)
Constructor. Creates an Condition object with state set to given parameter.
Definition: Condition.hpp:73
CCEC_OSAL::Condition::Condition
Condition(void)
Constructor. Creates an Condition object with state set to false.
Definition: Condition.hpp:62