common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / version_library / library / include / system_service / ss_ver.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 #ifndef VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
18 #define VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
19
20 #include <native_service/frameworkunified_types.h>
21 #include <string>
22 #include <algorithm>
23 #include <map>
24
25 /**
26  * @file ss_ver.h
27  * @brief \~english This file supports CSSVer class, This class is a generic CSSVer abstraction
28  */
29 /** @addtogroup BaseSystem
30  *  @{
31  */
32 /** @addtogroup system_service
33  *  @ingroup BaseSystem
34  *  @{
35  */
36 /** @addtogroup version_library
37  *  @ingroup system_service
38  *  @{
39  */
40
41 using namespace std;  //  NOLINT (readability/nolint)
42
43 #define SSVER_VERCHAR_MAX   (64)
44 #define SSVER_DATE_MAX      (16)
45
46 /**
47 * @struct SSVER_PkgInfo
48 * @brief \~english The structure of version package information
49 */
50 typedef struct {
51   char version[SSVER_VERCHAR_MAX]; /*!< \~english Version information (String):*/
52                                    /*!< \~english The termination of string must be "\0"*/
53   char date[SSVER_DATE_MAX]; /*!< \~english Date (String):The termination of string must be "\0" */
54                              /*!< \~english Date (String):Store "\0" when date information does not exist.*/
55 } SSVER_PkgInfo;
56
57 typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;
58 typedef SSVerPkgList::const_iterator SSVerPkgListIter;
59
60 ///////////////////////////////////////////////////////////////////////////////////////////////////
61 // \ingroup SS_SystemManager
62 ///////////////////////////////////////////////////////////////////////////////////////////////////
63 // \brief This class is a generic CSSVer abstraction
64 ///////////////////////////////////////////////////////////////////////////////////////////////////
65 /**
66  * @class CSSVer
67  * \~english @brief Version information set-up/acquisition
68  * \~english @par   Brief Introduction
69  *        Class to provide the function of the version information set-up/acquisition
70  *
71  */
72 class CSSVer {
73  private:
74   SSVerPkgList m_verList;
75   void dump(void) const;
76
77  public:
78   /////////////////////////////////////////////////////////////////////////////////////
79   /// \ingroup SS_SystemManager
80   /// \~english @par Summary
81   ///        Constructor for CSSVer class
82   /// \~english @param None
83   /// \~english @retval None
84   /// \~english @par Preconditions
85   ///       - None
86   /// \~english @par Changes of the internal state
87   ///       - The internal state is not changed.
88   /// \~english @par Causes of failures
89   ///       None
90   /// \~english @par Classification
91   ///       Public
92   /// \~english @par Type
93   ///       None
94   /// \~english @par Detail
95   ///       Creates the instance of CSSVer class. \n
96   ///       This API reads the version information registered in VersionDB and creates the package
97   ///       lists inside a instance. \n
98   ///       This can create some instances at the same time. \n
99   ///       Meanwhile, this does not guarantee the action when some threads
100   ///       inside same process access to same instances. \n
101   ///       It is possible that version information is overwritten from other process but the information overwritten
102   ///       at other process is not reflected into the version information held inside self-instance.
103   ///       By this, it is necessary to recreate an instance to get the latest information. \n
104   /// \~english @see  ~CSSVer
105   ////////////////////////////////////////////////////////////////////////////////////
106   CSSVer();
107
108   /////////////////////////////////////////////////////////////////////////////////////
109   /// \ingroup SS_SystemManager
110   /// \~english @par Summary
111   ///        Destructor for CSSVer class
112   /// \~english @param None
113   /// \~english @retval None
114   /// \~english @par Preconditions
115   ///       - None
116   /// \~english @par Changes of the internal state
117   ///       - The internal state is not changed.
118   /// \~english @par Causes of failures
119   ///       None
120   /// \~english @par Classfication
121   ///       Public
122   /// \~english @par Type
123   ///       None
124   /// \~english @par Detail
125   ///       Releases the instance of CSSVer class.
126   /// \~english @see  CSSVer
127   ////////////////////////////////////////////////////////////////////////////////////
128   ~CSSVer();
129
130   // Wrapper
131   /////////////////////////////////////////////////////////////////////////////////////
132   /// \ingroup SS_SystemManager
133   /// \~english @par Summary
134   ///        Returns the first iterator of package list.
135   /// \~english @param None
136   /// \~english @retval SSVerPkgListIter The first iterator of package list
137   /// \~english @par
138   ///       The structure of version package information
139   /// \~english @code
140   ///             #define SSVER_VERCHAR_MAX   (64)
141   ///             #define SSVER_DATE_MAX      (16)
142   ///             typedef struct{
143   ///                 char version[SSVER_VERCHAR_MAX];    /* Version information (String): The termination of
144   ///                                                         string must be "\0" */
145   ///                 char date[SSVER_DATE_MAX];          /* Date (String): The termination of string must be "\0"*/
146   ///                                                     /* Store "\0" when date information does not exist. */
147   ///             }SSVER_PkgInfo;
148   ///
149   ///             typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;  /* Package list definition            */
150   ///             typedef SSVerPkgList::const_iterator SSVerPkgListIter;      /* Iterator definition of package list */
151   ///            @endcode
152   /// \~english @par Preconditions
153   ///       - None
154   /// \~english @par Changes of the internal state
155   ///       - The internal state is not changed.
156   /// \~english @par Causes of failures
157   ///       None
158   /// \~english @par Classification
159   ///       Public
160   /// \~english @par Type
161   ///       Sync only(None communication)
162   /// \~english @par Detail
163   ///       Gets and returns the first iterator of package list from the package list inside an instance.
164   /// \~english @see  end
165   ////////////////////////////////////////////////////////////////////////////////////
166   SSVerPkgListIter begin() {
167     return m_verList.begin();
168   }
169
170   /////////////////////////////////////////////////////////////////////////////////////
171   /// \ingroup SS_SystemManager
172   /// \~english @par Summary
173   ///        Returns the end iterator of package list.
174   /// \~english @param None
175   /// \~english @retval SSVerPkgListIter The end iterator of package list
176   /// \~english @par
177   ///       The structure of version package information
178   /// \~english @code
179   ///             #define SSVER_VERCHAR_MAX   (64)
180   ///             #define SSVER_DATE_MAX      (16)
181   ///             typedef struct{
182   ///                 char version[SSVER_VERCHAR_MAX];    /* Version information (String): The termination of
183   ///                                                               string must be "\0" */
184   ///                 char date[SSVER_DATE_MAX];          /* Date (String): The termination of string must be "\0" */
185   ///                                                     /* Store "\0" when date information does not exist. */
186   ///             }SSVER_PkgInfo;
187   ///
188   ///             typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;  /* Package list definition            */
189   ///             typedef SSVerPkgList::const_iterator SSVerPkgListIter;      /* Iterator definition of package list */
190   ///            @endcode
191   /// \~english @par Preconditions
192   ///       - None
193   /// \~english @par Changes of the internal state
194   ///       - The internal state is not changed.
195   /// \~english @par Causes of failures
196   ///       None
197   /// \~english @par Classification
198   ///       Public
199   /// \~english @par Type
200   ///       Sync only(None communication)
201   /// \~english @par Detail
202   ///       Gets and returns the last iterator of package list from the package list inside a instance.
203   /// \~english @see  begin
204   ////////////////////////////////////////////////////////////////////////////////////
205   SSVerPkgListIter end() {
206     return m_verList.end();
207   }
208
209   /////////////////////////////////////////////////////////////////////////////////////
210   /// \ingroup SS_SystemManager
211   /// \~english @par Summary
212   ///        Checks whether data exists in package list or not.
213   /// \~english @param None
214   /// \~english @retval bool The possibility of data existence of package list
215   /// \~english @par
216   ///             - true    :    Data does not exist
217   ///             - false   :    Data exists
218   /// \~english @par Preconditions
219   ///       - None
220   /// \~english @par Changes of the internal state
221   ///       - The internal state is not changed.
222   /// \~english @par Causes of failures
223   ///       None
224   /// \~english @par Classification
225   ///       Public
226   /// \~english @par Type
227   ///       Sync only(None communication)
228   /// \~english @par Detail
229   ///       Returns true when package list is null and return false when data exists.
230   /// \~english @see  None
231   ////////////////////////////////////////////////////////////////////////////////////
232   bool empty() {
233     return m_verList.empty();
234   }
235
236   // Setter,getter
237   /////////////////////////////////////////////////////////////////////////////////////
238   /// \ingroup SS_SystemManager
239   /// \~english @par Summary
240   ///        Gets the package information of specified package.
241   /// \~english @param [in] name
242   ///        std::string &   -   Package name
243   /// \~english @param [out] p_info
244   ///        SSVER_PkgInfo*  -   Pointer to the storage area of package information
245   /// \~english @par
246   ///       The structure of version package information
247   /// \~english @code
248   ///             #define SSVER_VERCHAR_MAX   (64)
249   ///             #define SSVER_DATE_MAX      (16)
250   ///             typedef struct{
251   ///                 char version[SSVER_VERCHAR_MAX];    /* Version information (String): The termination of
252   ///                                                            string must be "\0" */
253   ///                 char date[SSVER_DATE_MAX];          /* Date (String): The termination of string must be "\0" */
254   ///                                                     /* Store "\0" when date information does not exist. */
255   ///             }SSVER_PkgInfo;
256   ///
257   ///             typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;  /* Package list definition            */
258   ///             typedef SSVerPkgList::const_iterator SSVerPkgListIter;      /* Iterator definition of package list */
259   ///            @endcode
260   /// \~english @retval eFrameworkunifiedStatusOK Succeeded in getting package information
261   /// \~english @retval eFrameworkunifiedStatusFileLoadError Loading error for file
262   /// \~english @retval eFrameworkunifiedStatusFail Failed at some process
263   /// \~english @par Preconditions
264   ///       - None
265   /// \~english @par Changes of the internal state
266   ///       - The internal state is not changed.
267   /// \~english @par Causes of failures
268   ///       - Pointer(p_info) to the storage area for package information specified
269   ///                           by parameters is NULL. [eFrameworkunifiedStatusFail]
270   ///       - Package information does not exist. [eFrameworkunifiedStatusFileLoadError]
271   ///       - Unexpected error occurs. [eFrameworkunifiedStatusFail]
272   /// \~english @par Classification
273   ///       Public
274   /// \~english @par Type
275   ///       Sync only(None communication)
276   /// \~english @par Detail
277   ///       Returns this package information if the package name specified by parameters exists
278   ///       in the package information list inside an instance.
279   ///       This API reads and returns the package information from package
280   ///                               information storing files if it does not exist. \n
281   ///       This adds the package information read from files to the package information list
282   ///                               inside an instance. \n
283   ///       When other CSSVer instance (B) adds package from setPkgInfo during creating instance (A),
284   ///                             after that, this API can get the package information added by instance (A).
285   /// \~english @see  setPkgInfo
286   ////////////////////////////////////////////////////////////////////////////////////
287   EFrameworkunifiedStatus getPkgInfo(const std::string &name, SSVER_PkgInfo* p_info);
288
289   /////////////////////////////////////////////////////////////////////////////////////
290   /// \ingroup SS_SystemManager
291   /// \~english @par Summary
292   ///        Sets the package information of specified package.
293   /// \~english @param [in] name
294   ///        std::string &   -   Package name
295   /// \~english @param [in] info
296   ///        SSVER_PkgInfo*  -   Package information
297   /// \~english @par
298   ///       The structure of version package information
299   /// \~english @code
300   ///             #define SSVER_VERCHAR_MAX   (64)
301   ///             #define SSVER_DATE_MAX      (16)
302   ///             typedef struct{
303   ///                 char version[SSVER_VERCHAR_MAX];    /* Version information (String): The termination of
304   ///                                                           string must be "\0" */
305   ///                 char date[SSVER_DATE_MAX];          /* Date (String): The termination of string must be \ */
306   ///                                                     /* Store "\0" when date information does not exist. */
307   ///             }SSVER_PkgInfo;
308   ///
309   ///             typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;  /* Package list definition            */
310   ///             typedef SSVerPkgList::const_iterator SSVerPkgListIter;      /* Iterator definition of package list */
311   ///            @endcode
312   /// \~english @retval eFrameworkunifiedStatusOK Succeeded in setting package information
313   /// \~english @retval eFrameworkunifiedStatusFail Faild at some process
314   /// \~english @par Preconditions
315   ///       - None
316   /// \~english @par Changes of the internal state
317   ///       - The internal state is not changed.
318   /// \~english @par Causes of failures
319   ///       - Unexpected error occurs [eFrameworkunifiedStatusFail]
320   /// \~english @par Classification
321   ///       Public
322   /// \~english @par Type
323   ///       Sync only(None communication)
324   /// \~english @par Detail
325   ///       Sets the package information specified by parameters and update VersionDB. \n
326   ///       When some package information exists in the package information list inside an instance,
327   ///       this API adds the package information specified by parameters to the package
328   ///             information list inside an instance,
329   ///       and writes the package information specified by parameters in package information storing files. \n
330   ///       When package information does not exist in the package information list inside an instance,
331   ///       this sets the package information specified by parameters to the package information list inside an instance
332   ///       and writes the package information specified by parameters in package information storing files.
333   /// \~english @see  getPkgInfo
334   ////////////////////////////////////////////////////////////////////////////////////
335   EFrameworkunifiedStatus setPkgInfo(const std::string &name, SSVER_PkgInfo &info);  //  NOLINT (readability/nolint)
336 };
337
338 #endif  // VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_