Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / nsframework / framework_unified / client / include / native_service / frameworkunified_thread_priority.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 //////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NSFramework
19 /// \brief    The file provide CFrameworkunifiedThreadPriorities class.
20 ///
21 ///
22 ///
23 //////////////////////////////////////////////////////////////////////////////////////////////////
24 //@{
25 /**
26  * @file frameworkunified_thread_priority.h
27  * @brief \~english The file contains declaration of CFrameworkunifiedThreadPriorities class
28  *
29  */
30 /** @addtogroup BaseSystem
31  *  @{
32  */
33 /** @addtogroup native_service
34  *  @ingroup BaseSystem
35  *  @{
36  */
37 /** @addtogroup framework_unified
38  *  @ingroup native_service
39  *  @{
40  */
41 /** @addtogroup framework
42  *  @ingroup native_service
43  *  @{
44  */
45
46 #ifndef FRAMEWORKUNIFIED_THREAD_PRIORITY_H_  // NOLINT  (build/header_guard)
47 #define FRAMEWORKUNIFIED_THREAD_PRIORITY_H_
48
49 #include <native_service/frameworkunified_types.h>
50 #include <string>
51 #include <map>
52
53 #define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1  ///< \~english if specified thread name not found
54
55 namespace frameworkunified {
56 namespace framework {
57 class args {
58  public:
59   enum {
60     name,
61     priority
62   };
63 };
64
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
66 /// This class parses and stores thread priorities
67 ///////////////////////////////////////////////////////////////////////////////////////////////////
68 class CFrameworkunifiedThreadPriorities {
69  public:
70   /////////////////////////////////////////////////////////////////////////////////////
71   /// \ingroup CFrameworkunifiedThreadPriorities
72   /// \~english @par Brief
73   ///        CFrameworkunifiedThreadPriorities constructor
74   /// \~english @param None
75   /// \~english @retval None
76   /// \~english @par Prerequisite
77   ///        None
78   /// \~english @par Change of internal state
79   ///        None
80   /// \~english @par Conditions of processing failure
81   ///        None
82   /// \~english @par Detail
83   ///        CFrameworkunifiedThreadPriorities constructor, for create CFrameworkunifiedThreadPriorities
84   /// \~english @par Classification
85   ///        Public
86   /// \~english @par Type
87   ///        sync only
88   /// \~english @see
89   ///
90   /////////////////////////////////////////////////////////////////////////////////////
91   CFrameworkunifiedThreadPriorities();
92
93   /////////////////////////////////////////////////////////////////////////////////////
94   /// \ingroup CFrameworkunifiedThreadPriorities
95   /// \~english @par Brief
96   ///        CFrameworkunifiedThreadPriorities destructor
97   /// \~english @param None
98   /// \~english @retval None
99   /// \~english @par Prerequisite
100   ///        None
101   /// \~english @par Change of internal state
102   ///        None
103   /// \~english @par Conditions of processing failure
104   ///        None
105   /// \~english @par Detail
106   ///        CFrameworkunifiedThreadPriorities destructor, for destory CFrameworkunifiedThreadPriorities
107   /// \~english @par Classification
108   ///        Public
109   /// \~english @par Type
110   ///        sync only
111   /// \~english @see
112   ///
113   /////////////////////////////////////////////////////////////////////////////////////
114   virtual ~CFrameworkunifiedThreadPriorities();
115
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
125   /// \~english @par
126   ///        FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND
127   /// \~english @code
128   ///                 #define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1  // if specified thread name not found
129   ///            @endcode
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
140   ///        Public
141   /// \~english @par Type
142   ///        sync only
143   /// \~english @see
144   ///        AddPriority
145   /////////////////////////////////////////////////////////////////////////////////////
146   static SI_32 GetPriority(const std::string &f_cThreadName);
147
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
158   ///       - None
159   /// \~english @par Change of the internal state
160   ///       - ms_mapThreadPritories[f_cThreadName] = f_si32Priority
161   /// \~english @par Causes of failures
162   ///       None
163   /// \~english @par Classification
164   ///       public
165   /// \~english @par Type
166   ///       sync only
167   /// \~english @par Detail
168   ///       set thread Priority through thread name
169   /// \~english @see
170   ////////////////////////////////////////////////////////////////////////////////////
171   static EFrameworkunifiedStatus AddPriority(const std::string &f_cThreadName, SI_32 f_si32Priority);
172
173   /////////////////////////////////////////////////////////////////////////////////////
174   /// \ingroup CFrameworkunifiedThreadPriorities
175   /// \~english @par Summary
176   ///        print thread Priority
177   /// \~english @param None
178   /// \~english @retval None
179   /// \~english @par Preconditions
180   ///       - None
181   /// \~english @par Change of the internal state
182   ///       - None
183   /// \~english @par Causes of failures
184   ///       None
185   /// \~english @par Classification
186   ///       public
187   /// \~english @par Type
188   ///       sync only
189   /// \~english @par Detail
190   ///       read each thread and print it's Priority
191   /// \~english @see
192   ////////////////////////////////////////////////////////////////////////////////////
193   static VOID PrintPriorites();
194
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
204   ///       - None
205   /// \~english @par Change of the internal state
206   ///       - None
207   /// \~english @par Causes of failures
208   ///       - f_cArgumentValue == NULL
209   ///       - f_cArgumentValue is invalid
210   /// \~english @par Classification
211   ///       public
212   /// \~english @par Type
213   ///       sync only
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);
220
221  private:
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
225 };
226
227 }  // namespace framework
228 };  // namespace frameworkunified
229
230 #endif /* FRAMEWORKUNIFIED_THREAD_PRIORITY_H_ */  // NOLINT  (build/header_guard)
231 /** @}*/
232 /** @}*/
233 /** @}*/
234 /** @}*/
235 //@}