Init basesystem source codes.
[staging/basesystem.git] / nsframework / notification_persistent_service / server / include / ns_npp_registry_entry.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_NPPService
19 /// \brief    The file contains declaration of CRegistryEntry class.
20 ///
21 ///
22 ///
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24
25 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_
26 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_
27
28 #include <native_service/frameworkunified_types.h>
29 #include <string>
30 #include "ns_npp_types.h"
31
32 /**
33  *  This class contains the registry information  of the files/folders to be peresisted.
34  */
35 class CRegistryEntry {
36  public:
37   ////////////////////////////////////////////////////////////////////////////////////////////////
38   /// CRegistryEntry
39   /// Constructor of CRegistryEntry class
40   ///
41   /// \param [OUT] f_ctag
42   ///      std::string& - File or Folder tag
43   ///
44   /// \param [OUT] f_crequester
45   ///      std::string& - Requester Name
46   ///
47   /// \param [OUT] f_cstoragepath
48   ///      std::string& - File or Folder persistence storage path
49   ///
50   /// \param [IN] f_bisuserpersistence
51   ///      BOOL - File or Folder is user specific
52   /// \return
53   ///
54   ////////////////////////////////////////////////////////////////////////////////////////////////
55   explicit CRegistryEntry(const std::string &f_ctag, const std::string &f_crequester,
56                           const std::string &f_cstoragepath, BOOL f_bisuserpersistence);
57
58   ////////////////////////////////////////////////////////////////////////////////////////////////
59   /// CRegistryEntry
60   /// Copy Constructor of CRegistryEntry class
61   ///
62   /// \param
63   ///
64   /// \return
65   ///
66   ////////////////////////////////////////////////////////////////////////////////////////////////
67   CRegistryEntry(const CRegistryEntry &f_objin);
68
69   ////////////////////////////////////////////////////////////////////////////////////////////////
70   /// operator=
71   /// Operator overload =
72   ///
73   /// \param [IN] f_objin
74   ///      CRegistryEntry& - In object.
75   ///
76   /// \return
77   ///
78   ////////////////////////////////////////////////////////////////////////////////////////////////
79   CRegistryEntry &operator=(const CRegistryEntry &f_objin);  // NOLINT (readability/naming)
80
81   ////////////////////////////////////////////////////////////////////////////////////////////////
82   /// SetReleasePath
83   /// Set release path.
84   ///
85   /// \param [IN] f_creleasepath
86   ///       std::string& - Path of the file/folder to be released.
87   ///
88   /// \return
89   ///
90   ////////////////////////////////////////////////////////////////////////////////////////////////
91   VOID SetReleasePath(const std::string &f_creleasepath);
92
93   ////////////////////////////////////////////////////////////////////////////////////////////////
94   /// SetBeingPersisted
95   /// Set the file/folder persist member variable to true to notify that the file/folder is being
96   /// persisted.
97   ///
98   /// \param
99   ///
100   /// \return
101   ///
102   ////////////////////////////////////////////////////////////////////////////////////////////////
103   VOID SetBeingPersisted();
104
105   ////////////////////////////////////////////////////////////////////////////////////////////////
106   /// AckReceived
107   /// Ack from copy worker received. Process the ack.
108   ///
109   /// \param
110   ///
111   /// \return
112   ///
113   ////////////////////////////////////////////////////////////////////////////////////////////////
114   VOID AckReceived();
115
116   ////////////////////////////////////////////////////////////////////////////////////////////////
117   /// IsReleased
118   /// Check if File/folder released or not.
119   ///
120   /// \param
121   ///
122   /// \return BOOL
123   //      BOOL - True if file/folder is released else false
124   ///
125   ////////////////////////////////////////////////////////////////////////////////////////////////
126   BOOL IsReleased() const;
127
128   ////////////////////////////////////////////////////////////////////////////////////////////////
129   /// HasntBeenPersisted
130   /// File persisted or not
131   ///
132   /// \param
133   ///
134   /// \return BOOL
135   //      BOOL - True if file is not persisted else false
136   ///
137   ////////////////////////////////////////////////////////////////////////////////////////////////
138   BOOL HasntBeenPersisted() const;
139
140   ////////////////////////////////////////////////////////////////////////////////////////////////
141   /// IsPersisted
142   /// File/Folder persisted or not
143   ///
144   /// \param
145   ///
146   /// \return BOOL
147   //      BOOL - True if file/folder is persisted else false
148   ///
149   ////////////////////////////////////////////////////////////////////////////////////////////////
150   BOOL IsPersisted() const;
151
152   ////////////////////////////////////////////////////////////////////////////////////////////////
153   /// IsAckPending
154   /// Ack is pending or not.
155   ///
156   /// \param
157   ///
158   /// \return BOOL
159   //      BOOL - True if ack is pending else false
160   ///
161   ////////////////////////////////////////////////////////////////////////////////////////////////
162   BOOL IsAckPending() const;
163
164   ////////////////////////////////////////////////////////////////////////////////////////////////
165   /// GetPersistPath
166   /// Get the persist path.
167   ///
168   /// \param
169   ///
170   /// \return std::string
171   //      std::string - Returns the persist path.
172   ///
173   ////////////////////////////////////////////////////////////////////////////////////////////////
174   std::string GetPersistPath() const;
175
176   ////////////////////////////////////////////////////////////////////////////////////////////////
177   /// GetReleasePath
178   /// Get the release path.
179   ///
180   /// \param
181   ///
182   /// \return std::string
183   //      std::string - Returns the release path.
184   ///
185   ////////////////////////////////////////////////////////////////////////////////////////////////
186   std::string GetReleasePath() const;
187
188   ////////////////////////////////////////////////////////////////////////////////////////////////
189   /// GetLoadPath
190   /// Get the load path.
191   ///
192   /// \param [IN] f_epersisttype
193   ///       ENotificationpersistentservicePersistType - type of persisted data
194   ///
195   /// \param [IN] f_cusername
196   ///       std::string - Current user name
197   ///
198   ///
199   /// \return std::string
200   //      std::string - Returns the load path.
201   ///
202   ////////////////////////////////////////////////////////////////////////////////////////////////
203   std::string GetLoadPath(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) const;
204
205   ////////////////////////////////////////////////////////////////////////////////////////////////
206   /// GetRequester
207   /// Get the name of requester.
208   ///
209   /// \param
210   ///
211   /// \return std::string
212   //      std::string - Returns the name of requester.
213   ///
214   ////////////////////////////////////////////////////////////////////////////////////////////////
215   std::string GetRequester() const;
216
217   ////////////////////////////////////////////////////////////////////////////////////////////////
218   /// GetTag
219   /// Get the tag.
220   ///
221   /// \param
222   ///
223   /// \return std::string
224   //      std::string - Returns the tag.
225   ///
226   ////////////////////////////////////////////////////////////////////////////////////////////////
227   std::string GetTag() const;
228
229   ////////////////////////////////////////////////////////////////////////////////////////////////
230   /// IsUserPersistence
231   /// Returns TRUE if it is a user persistence.
232   ///
233   /// \param
234   ///
235   /// \return BOOL
236   //      BOOL - Returns TRUE if it is a user persistence.
237   ///
238   ////////////////////////////////////////////////////////////////////////////////////////////////
239   BOOL IsUserPersistence();
240
241   ////////////////////////////////////////////////////////////////////////////////////////////////
242   /// SetCurrentAction
243   /// Set current copying action of a the corresponding tag.
244   ///
245   /// \param [IN] f_ecurrentaction
246   ///       ENPS_Loadtype - Current action
247   ///
248   /// \return
249   ////////////////////////////////////////////////////////////////////////////////////////////////
250   VOID SetCurrentAction(ENPS_Loadtype f_ecurrentaction);
251
252   ////////////////////////////////////////////////////////////////////////////////////////////////
253   /// ResetPersistedFlag
254   /// Reset Persist flags
255   ///
256   /// \param
257   ///
258   /// \return
259   ////////////////////////////////////////////////////////////////////////////////////////////////
260   VOID ResetPersistedFlag();
261
262   ////////////////////////////////////////////////////////////////////////////////////////////////
263   /// SetPersistProperties
264   /// creates persistence path and stores the persist type
265   ///
266   /// \param [IN] f_epersisttype
267   ///       ENotificationpersistentservicePersistType - Set persist type
268   /// \param [IN] f_cusername
269   ///       std::string - Username related to persist tag if any.
270   ///
271   ///
272   /// \return
273   ////////////////////////////////////////////////////////////////////////////////////////////////
274   VOID SetPersistProperties(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername = "");
275
276   ////////////////////////////////////////////////////////////////////////////////////////////////
277   /// GetPersistType
278   /// Returns persist type of a job
279   ///
280   /// \param
281   ///
282   /// \return ENotificationpersistentservicePersistType
283   //      ENotificationpersistentservicePersistType - Returns persist type
284   ///
285   ////////////////////////////////////////////////////////////////////////////////////////////////
286   ENotificationpersistentservicePersistType GetPersistType() const;
287
288   ////////////////////////////////////////////////////////////////////////////////////////////////
289   /// SetPersistentCategory
290   /// Sets the persistent type related to tag
291   ///
292   /// \param [IN] f_epersistcategory
293   ///      EFrameworkunifiedPersistCategory - persist category
294   ///
295   /// \return EFrameworkunifiedStatus
296   //      EFrameworkunifiedStatus - success or failure status
297   ///
298   ////////////////////////////////////////////////////////////////////////////////////////////////
299   EFrameworkunifiedStatus SetPersistentCategory(EFrameworkunifiedPersistCategory f_epersistcategory);
300
301   ////////////////////////////////////////////////////////////////////////////////////////////////
302   /// GetPersistentCategory
303   /// Returns persistent type of tag
304   ///
305   /// \param
306   ///
307   /// \return EFrameworkunifiedPersistCategory
308   //      EFrameworkunifiedPersistCategory - Returns persistent type
309   ///
310   ////////////////////////////////////////////////////////////////////////////////////////////////
311   EFrameworkunifiedPersistCategory GetPersistentCategory();
312
313   ENPSPersistenceJobState m_eJobState;  // Current state of a job
314
315  private:
316   std::string    m_cTag;        // File/Folder tag
317   std::string    m_cRequestor;      // Requester application name
318   BOOL         m_bIsReleased;     // if file or folder released
319   BOOL         m_bIsPersisted;    // if file or folder is persisted
320   std::string    m_cPersistPath;    // Persist path
321   std::string    m_cReleasePath;    // Release path
322   std::string    m_cBasePath;     // Persist base path
323   BOOL       m_bIsUserPersistence;  // If user persistence
324   ENPS_Loadtype    m_eCurrentAction;    // Current action to load file to/from
325   /// temporary/persistence memory
326   ENotificationpersistentservicePersistType m_ePersistType;
327   EFrameworkunifiedPersistCategory m_ePersistCategory;  // Persistent category
328 };
329
330 #endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_