RDK Documentation (Open Sourced RDK Components)
dsConstant.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 /**
22  * @file dsConstant.hpp
23  * @brief This file defines DSConstant class which is inherited by most of
24  * the device settings classes.
25  */
26 
27 
28 /**
29 * @defgroup devicesettings
30 * @{
31 * @defgroup ds
32 * @{
33 **/
34 
35 
36 #ifndef DSCONSTANTS_HPP_
37 #define DSCONSTANTS_HPP_
38 
39 #include "enumerable.hpp"
40 #include <string>
41 namespace device {
42 
43 
44 /**
45  * @class DSConstant
46  * @brief This class is used to store and manage the names and id's. It is derived
47  * by many classes like VideoResolution, VideoOutputPortType, stereoScopicMode and so on.
48  * And it is also stores information whether the derived class instances indicating the port
49  * or port attributes are enabled or not.
50  * @ingroup devicesettingsclass
51  */
52 class DSConstant : public Enumerable {
53 private:
54  bool enabled; //!< Indicates the port or port attributes inheriting this class is enabled or not.
55 
56 protected:
57  int _id; //!< Indicates the id of the instance inheriting this class.
58  std::string _name; //!< Indicates the name string of the instance inheriting this class.
59 
60 
61 /**
62  * @fn DSConstant::isValid(int min, int max, int val)
63  * @brief This function checks if the given value lies between min and max values provided.
64  *
65  * @param[in] min Indicates the minimum value for comparison.
66  * @param[in] max Indicates the maximum value for comparison.
67  * @param[in] val Indicates the value to be compared with minimum and maximum value.
68  *
69  * @return Returns true(1) if the specified val lies in between min and max values else returns
70  * false(0)
71  */
72  static bool isValid(int min, int max, int val) {
73  return (val >= min && val < max);
74  }
75 
76 public:
77 
78 /**
79  * @fn DSConstant::DSConstant()
80  * @brief This function is the default constructor for DSConstant. It initializes the DSConstant
81  * instance with default values.
82  *
83  * @return None
84  */
85  DSConstant() : enabled(false), _id(0), _name("_UNASSIGNED NAME_"){};
86 
87 
88 /**
89  * @fn DSConstant::DSConstant(const int id, const std::string &name)
90  * @brief This function is a parameterised constructor for DSConstant. It initializes the DSConstant
91  * instance with the values passed as input parameter.
92  *
93  * @param[in] id Indicates the id.
94  * @param[in] name Indicates the name string.
95  *
96  * @return None.
97  */
98  DSConstant(const int id, const std::string &name) : enabled(false), _id(id), _name(name){};
99 
100 
101 /**
102  * @fn DSConstant::~DSConstant()
103  * @brief This function is the default destructor for DSConstant.
104  *
105  * @return None
106  */
107  virtual ~DSConstant() {};
108 
109 
110 /**
111  * @fn DSConstant::operator==(int id)
112  * @brief This function is an operator overloading for == operator. It checks if the id of
113  * DSConstant instance is equal to the id passed as input parameter.
114  *
115  * @param[in] id Indicates the value to be compared against the id of the instance.
116  *
117  * @return Returns true(1) if the values compared are same else returns false(0).
118  */
119  virtual bool operator==(int id) const {
120  return id == _id;
121  }
122 
123 
124 /**
125  * @fn DSConstant::getId()
126  * @brief This function is used to get the id.
127  *
128  * @return _id Returns the id.
129  */
130  virtual int getId() const {
131  return _id;
132  };
133 
134 
135 /**
136  * @fn DSConstant::getName()
137  * @brief This function is used to the get the data member name.
138  *
139  * @return _name Returns the name string.
140  */
141  virtual const std::string & getName() const {
142  return _name;
143  }
144 
145 
146 /**
147  * @fn DSConstant::toString()
148  * @brief This function is used to the get the data member name in string format.
149  *
150  * @return _name Returns the name string.
151  */
152  virtual const std::string & toString() const {
153  return _name;
154  }
155 
156 
157 /**
158  * @fn DSConstant::enable()
159  * @brief This function is used to indicate that the port or port attribute calling this function
160  * are enabled.
161  *
162  * @return None
163  */
164  void enable() {
165  enabled = true;
166  }
167 
168 
169 /**
170  * @fn DSConstant::isEnabled()
171  * @brief This function is used to check if the calling object is enabled or not. The calling
172  * object can be an instance of video output port or audio output port or their attributes.
173  *
174  * @return Returns true if data member enabled is set to true else returns false.
175  */
176  bool isEnabled() const{
177  return enabled;
178  }
179 
180 };
181 
182 }
183 
184 #endif /* DSCONSTANT_HPP_ */
185 
186 
187 /** @} */
188 /** @} */
device::DSConstant::_id
int _id
Indicates the id of the instance inheriting this class.
Definition: dsConstant.hpp:57
device::DSConstant::DSConstant
DSConstant()
This function is the default constructor for DSConstant. It initializes the DSConstant instance with ...
Definition: dsConstant.hpp:85
device::DSConstant::enabled
bool enabled
Indicates the port or port attributes inheriting this class is enabled or not.
Definition: dsConstant.hpp:54
device::DSConstant
This class is used to store and manage the names and id's. It is derived by many classes like VideoRe...
Definition: dsConstant.hpp:52
device::DSConstant::isValid
static bool isValid(int min, int max, int val)
This function checks if the given value lies between min and max values provided.
Definition: dsConstant.hpp:72
device::DSConstant::enable
void enable()
This function is used to indicate that the port or port attribute calling this function are enabled.
Definition: dsConstant.hpp:164
device::DSConstant::DSConstant
DSConstant(const int id, const std::string &name)
This function is a parameterised constructor for DSConstant. It initializes the DSConstant instance w...
Definition: dsConstant.hpp:98
device::DSConstant::_name
std::string _name
Indicates the name string of the instance inheriting this class.
Definition: dsConstant.hpp:58
device::Enumerable
This class is inherited by many classes in DS for getting the ID.
Definition: enumerable.hpp:46
device::DSConstant::isEnabled
bool isEnabled() const
This function is used to check if the calling object is enabled or not. The calling object can be an ...
Definition: dsConstant.hpp:176
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
device::DSConstant::toString
virtual const std::string & toString() const
This function is used to the get the data member name in string format.
Definition: dsConstant.hpp:152
enumerable.hpp
This file defines Enumerable class.
device::DSConstant::operator==
virtual bool operator==(int id) const
This function is an operator overloading for == operator. It checks if the id of DSConstant instance ...
Definition: dsConstant.hpp:119
device::DSConstant::~DSConstant
virtual ~DSConstant()
This function is the default destructor for DSConstant.
Definition: dsConstant.hpp:107
device::DSConstant::getId
virtual int getId() const
This function is used to get the id.
Definition: dsConstant.hpp:130