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 #ifndef VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
18 #define VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_
20 #include <native_service/frameworkunified_types.h>
27 * @brief \~english This file supports CSSVer class, This class is a generic CSSVer abstraction
29 /** @addtogroup BaseSystem
32 /** @addtogroup system_service
36 /** @addtogroup version_library
37 * @ingroup system_service
41 using namespace std; // NOLINT (readability/nolint)
43 #define SSVER_VERCHAR_MAX (64)
44 #define SSVER_DATE_MAX (16)
47 * @struct SSVER_PkgInfo
48 * @brief \~english The structure of version package information
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.*/
57 typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList;
58 typedef SSVerPkgList::const_iterator SSVerPkgListIter;
60 ///////////////////////////////////////////////////////////////////////////////////////////////////
61 // \ingroup SS_SystemManager
62 ///////////////////////////////////////////////////////////////////////////////////////////////////
63 // \brief This class is a generic CSSVer abstraction
64 ///////////////////////////////////////////////////////////////////////////////////////////////////
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
74 SSVerPkgList m_verList;
75 void dump(void) const;
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
86 /// \~english @par Changes of the internal state
87 /// - The internal state is not changed.
88 /// \~english @par Causes of failures
90 /// \~english @par Classification
92 /// \~english @par Type
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 ////////////////////////////////////////////////////////////////////////////////////
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
116 /// \~english @par Changes of the internal state
117 /// - The internal state is not changed.
118 /// \~english @par Causes of failures
120 /// \~english @par Classfication
122 /// \~english @par Type
124 /// \~english @par Detail
125 /// Releases the instance of CSSVer class.
126 /// \~english @see CSSVer
127 ////////////////////////////////////////////////////////////////////////////////////
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
138 /// The structure of version package information
140 /// #define SSVER_VERCHAR_MAX (64)
141 /// #define SSVER_DATE_MAX (16)
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. */
149 /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
150 /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
152 /// \~english @par Preconditions
154 /// \~english @par Changes of the internal state
155 /// - The internal state is not changed.
156 /// \~english @par Causes of failures
158 /// \~english @par Classification
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();
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
177 /// The structure of version package information
179 /// #define SSVER_VERCHAR_MAX (64)
180 /// #define SSVER_DATE_MAX (16)
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. */
188 /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
189 /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
191 /// \~english @par Preconditions
193 /// \~english @par Changes of the internal state
194 /// - The internal state is not changed.
195 /// \~english @par Causes of failures
197 /// \~english @par Classification
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();
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
216 /// - true : Data does not exist
217 /// - false : Data exists
218 /// \~english @par Preconditions
220 /// \~english @par Changes of the internal state
221 /// - The internal state is not changed.
222 /// \~english @par Causes of failures
224 /// \~english @par Classification
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 ////////////////////////////////////////////////////////////////////////////////////
233 return m_verList.empty();
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
246 /// The structure of version package information
248 /// #define SSVER_VERCHAR_MAX (64)
249 /// #define SSVER_DATE_MAX (16)
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. */
257 /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
258 /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
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
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
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);
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
298 /// The structure of version package information
300 /// #define SSVER_VERCHAR_MAX (64)
301 /// #define SSVER_DATE_MAX (16)
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. */
309 /// typedef std::map<std::string, SSVER_PkgInfo> SSVerPkgList; /* Package list definition */
310 /// typedef SSVerPkgList::const_iterator SSVerPkgListIter; /* Iterator definition of package list */
312 /// \~english @retval eFrameworkunifiedStatusOK Succeeded in setting package information
313 /// \~english @retval eFrameworkunifiedStatusFail Faild at some process
314 /// \~english @par Preconditions
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
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)
338 #endif // VERSION_LIBRARY_LIBRARY_INCLUDE_SYSTEM_SERVICE_SS_VER_H_