2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 //////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_NSFramework
19 /// \brief The file provide CFrameworkunifiedThreadPriorities class.
23 //////////////////////////////////////////////////////////////////////////////////////////////////
26 * @file frameworkunified_thread_priority.h
27 * @brief \~english The file contains declaration of CFrameworkunifiedThreadPriorities class
30 /** @addtogroup BaseSystem
33 /** @addtogroup native_service
37 /** @addtogroup framework_unified
38 * @ingroup native_service
41 /** @addtogroup framework
42 * @ingroup native_service
46 #ifndef FRAMEWORKUNIFIED_THREAD_PRIORITY_H_ // NOLINT (build/header_guard)
47 #define FRAMEWORKUNIFIED_THREAD_PRIORITY_H_
49 #include <native_service/frameworkunified_types.h>
53 #define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1 ///< \~english if specified thread name not found
55 namespace frameworkunified {
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
66 /// This class parses and stores thread priorities
67 ///////////////////////////////////////////////////////////////////////////////////////////////////
68 class CFrameworkunifiedThreadPriorities {
70 /////////////////////////////////////////////////////////////////////////////////////
71 /// \ingroup CFrameworkunifiedThreadPriorities
72 /// \~english @par Brief
73 /// CFrameworkunifiedThreadPriorities constructor
74 /// \~english @param None
75 /// \~english @retval None
76 /// \~english @par Prerequisite
78 /// \~english @par Change of internal state
80 /// \~english @par Conditions of processing failure
82 /// \~english @par Detail
83 /// CFrameworkunifiedThreadPriorities constructor, for create CFrameworkunifiedThreadPriorities
84 /// \~english @par Classification
86 /// \~english @par Type
90 /////////////////////////////////////////////////////////////////////////////////////
91 CFrameworkunifiedThreadPriorities();
93 /////////////////////////////////////////////////////////////////////////////////////
94 /// \ingroup CFrameworkunifiedThreadPriorities
95 /// \~english @par Brief
96 /// CFrameworkunifiedThreadPriorities destructor
97 /// \~english @param None
98 /// \~english @retval None
99 /// \~english @par Prerequisite
101 /// \~english @par Change of internal state
103 /// \~english @par Conditions of processing failure
105 /// \~english @par Detail
106 /// CFrameworkunifiedThreadPriorities destructor, for destory CFrameworkunifiedThreadPriorities
107 /// \~english @par Classification
109 /// \~english @par Type
113 /////////////////////////////////////////////////////////////////////////////////////
114 virtual ~CFrameworkunifiedThreadPriorities();
116 /////////////////////////////////////////////////////////////////////////////////////
117 /// \ingroup CFrameworkunifiedThreadPriorities
118 /// \~english @par Brief
119 /// Get the priority of the thread. Priority of the thread was added by \ref AddPriority(),
120 /// when parsing command line arguments.
121 /// \~english @param [in] f_cThreadName
122 /// const std::string& - Name of thread
123 /// \~english @retval SI_32 Returns the priority of a thread.
124 /// \~english @retval FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND if specified thread name not found
126 /// FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND
128 /// #define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1 // if specified thread name not found
130 /// \~english @par Prerequisite
131 /// - Call AddPriority() and set priority.
132 /// \~english @par Change of internal state
133 /// - Change of internal state according to the API does not occur.
134 /// \~english @par Conditions of processing failure
135 /// - Thread name is not registered in AddPriority()
136 /// \~english @par Detail
137 /// Get the priority of the thread. Priority of the thread was added by \ref AddPriority(),
138 /// when parsing command line arguments.
139 /// \~english @par Classification
141 /// \~english @par Type
145 /////////////////////////////////////////////////////////////////////////////////////
146 static SI_32 GetPriority(const std::string &f_cThreadName);
148 /////////////////////////////////////////////////////////////////////////////////////
149 /// \ingroup CFrameworkunifiedThreadPriorities
150 /// \~english @par Summary
151 /// set thread Priority
152 /// \~english @param [in] f_cThreadName
153 /// const std::string &f_cThreadName - thread name
154 /// \~english @param [in] f_si32Priority
155 /// SI_32 f_si32Priority - Priority
156 /// \~english @retval eFrameworkunifiedStatusOK set Priority success
157 /// \~english @par Preconditions
159 /// \~english @par Change of the internal state
160 /// - ms_mapThreadPritories[f_cThreadName] = f_si32Priority
161 /// \~english @par Causes of failures
163 /// \~english @par Classification
165 /// \~english @par Type
167 /// \~english @par Detail
168 /// set thread Priority through thread name
170 ////////////////////////////////////////////////////////////////////////////////////
171 static EFrameworkunifiedStatus AddPriority(const std::string &f_cThreadName, SI_32 f_si32Priority);
173 /////////////////////////////////////////////////////////////////////////////////////
174 /// \ingroup CFrameworkunifiedThreadPriorities
175 /// \~english @par Summary
176 /// print thread Priority
177 /// \~english @param None
178 /// \~english @retval None
179 /// \~english @par Preconditions
181 /// \~english @par Change of the internal state
183 /// \~english @par Causes of failures
185 /// \~english @par Classification
187 /// \~english @par Type
189 /// \~english @par Detail
190 /// read each thread and print it's Priority
192 ////////////////////////////////////////////////////////////////////////////////////
193 static VOID PrintPriorites();
195 /////////////////////////////////////////////////////////////////////////////////////
196 /// \ingroup CFrameworkunifiedThreadPriorities
197 /// \~english @par Summary
198 /// analyse thread param
199 /// \~english @param [in] f_cArgumentValue
200 /// PCHAR f_cArgumentValue - thread param string
201 /// \~english @retval eFrameworkunifiedStatusOK parse thread param success
202 /// \~english @retval eFrameworkunifiedStatusFail parse thread param failed
203 /// \~english @par Preconditions
205 /// \~english @par Change of the internal state
207 /// \~english @par Causes of failures
208 /// - f_cArgumentValue == NULL
209 /// - f_cArgumentValue is invalid
210 /// \~english @par Classification
212 /// \~english @par Type
214 /// \~english @par Detail
215 /// analyse thread param data, and set param to thread.
216 /// if given data is NULL or invalid , return false
217 /// \~english @see getsubopt, AddPriority
218 ////////////////////////////////////////////////////////////////////////////////////
219 static EFrameworkunifiedStatus ParseThreadArguments(PCHAR f_cArgumentValue);
222 typedef std::map<std::string, SI_32> TThreadPriorityList;
223 typedef TThreadPriorityList::iterator ThreadPrioMapIter;
224 static TThreadPriorityList ms_mapThreadPritories; // map of thread name and priority
227 } // namespace framework
228 }; // namespace frameworkunified
230 #endif /* FRAMEWORKUNIFIED_THREAD_PRIORITY_H_ */ // NOLINT (build/header_guard)