1 #ifndef PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H
2 #define PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H
4 /******************************************************************************
7 * Company XS Embedded GmbH
8 *****************************************************************************/
9 /******************************************************************************
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
12 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
15 * @file persistence_client_library_data_organization.h
16 * @ingroup Persistence client library
17 * @author Ingo Huerner
18 * @brief Header of the persistence client library data organization.
27 #define PERSIST_CLIENT_LIBRARY_DATA_ORGANIZATION_INTERFACE_VERSION (0x03000000U)
29 #include "../include/persistence_client_library_error_def.h"
30 #include "../include/persistence_client_library_key.h"
32 #include <persComRct.h>
33 #include <persComDbAccess.h>
34 #include <persComDataOrg.h>
37 #include <dlt/dlt_common.h>
44 /// structure used to manage database context
45 typedef struct _PersistenceDbContext_s
50 } PersistenceDbContext_s;
52 /// persistence information
53 typedef struct _PersistenceInfo_s
55 PersistenceDbContext_s context; /**< database context*/
56 PersistenceConfigurationKey_s configKey; /**< prct configuration key*/
61 /** storages to manage the data */
62 typedef enum PersDefaultType_e_
64 PersDefaultType_Configurable = 0, /**< get the data from configurable defaults */
65 PersDefaultType_Factory, /**< get the data from factory defaults */
67 /** insert new entries here ... */
68 PersDefaultType_LastEntry /**< last entry */
72 /** storages to manage the data */
73 typedef enum PersGetDefault_e_
75 PersGetDefault_Data = 0, /**< get the data from configurable defaults */
76 PersGetDefault_Size, /**< get the data from factory defaults */
78 /** insert new entries here ... */
79 PersGetDefault_LastEntry /**< last entry */
83 /// enumerator used to identify the policy to manage the data
84 typedef enum _PersNotifyRegPolicy_e
86 Notify_register = 0, /**< register to change notifications*/
87 Notify_unregister = 1, /**< unregister for change notifications */
88 Notify_lastEntry, /**<last entry */
89 } PersNotifyRegPolicy_e;
92 /// constant definitions
93 enum _PersistenceConstantDef
95 ResIsNoFile = 0, /// flag to identify that resource a not file
96 ResIsFile = 1, /// flag to identify that resource a file
97 AccessNoLock = 1, /// flag to indicate that access is not locked
99 PCLnotInitialized = 0, /// indication if PCL is not initialized
100 PCLinitialized = 1, /// indication if PCL is initialized
102 FileClosed = 0, /// flag to identify if file will be closed
103 FileOpen = 1, /// flag to identify if file has been opend
105 Shutdown_Partial = 0, /// make partial Shutdown (close but not free everything)
106 Shutdown_Full = 1, /// make complete Shutdown (close and free everything)
107 Shutdown_MaxCount = 3, /// max number of shutdown cancel calls
109 NsmShutdownNormal = 1, /// lifecycle shutdown normal
110 NsmErrorStatus_OK = 1, /// lifecycle return OK indicator
111 NsmErrorStatus_Fail = -1, /// lifecycle return failed indicator
113 ChecksumBufSize = 64, /// max checksum size
115 DbusSubMatchSize = 12, /// max character sub match size
116 DbusMatchRuleSize = 300, /// max character size of the dbus match rule size
118 PrctKeySize = PERS_RCT_MAX_LENGTH_RESOURCE_ID, /// persistence resource config table max key size
119 PrctValueSize = sizeof(PersistenceConfigurationKey_s), /// persistence resource config table max value size
120 PrctDbTableSize = 1024, /// number of persistence resource config tables to store
122 RDRWBufferSize = 1024, /// write buffer size
124 DbKeySize = PERS_DB_MAX_LENGTH_KEY_NAME, /// database max key size
125 DbValueSize = PERS_DB_MAX_SIZE_KEY_DATA, /// database max value size
126 DbTableSize = 1024, /// database table size
128 PasMsg_Block = 0x0001, /// persistence administration service block access
129 PasMsg_Unblock = 0x0002, /// persistence administration service unblock access
130 PasMsg_WriteBack = 0x0010, /// persistence administration service write_back
132 PasErrorStatus_RespPend = 0x0001, /// persistence administration service msg return status
133 PasErrorStatus_OK = 0x0002, /// persistence administration service msg return status
134 PasErrorStatus_FAIL = 0x8000, /// persistence administration service msg return status
136 CustLibMaxLen = PERS_RCT_MAX_LENGTH_CUSTOM_NAME, /// max length of the custom library name and path
137 DbKeyMaxLen = PERS_DB_MAX_LENGTH_KEY_NAME, /// max database key length
138 DbResIDMaxLen = PERS_DB_MAX_LENGTH_KEY_NAME, /// max database key length
139 DbPathMaxLen = PERS_ORG_MAX_LENGTH_PATH_FILENAME, /// max database path length
140 MaxAppNameLen = PERS_RCT_MAX_LENGTH_RESPONSIBLE, /// max application name
141 MaxPersHandle = 128, /// max number of parallel open persistence handles
143 MaxConfKeyLengthResp = 32, /// length of the config key responsible name
144 MaxConfKeyLengthCusName = 32, /// length of the config key custom name
145 MaxRctLengthCustom_ID = 64, /// length of the customer ID
147 defaultMaxKeyValDataSize = PERS_DB_MAX_SIZE_KEY_DATA /// default limit the key-value data size to 16kB
150 /// path for the backup location
151 extern const char* gBackupPrefix;
152 /// backup filename postfix
153 extern const char* gBackupPostfix;
154 /// backup checksum filename postfix
155 extern const char* gBackupCsPostfix;
157 /// size of cached prefix string
158 extern const int gCPathPrefixSize;
159 /// size of write through prefix string
160 extern const int gWTPathPrefixSize;
162 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
163 extern const char* gLocalCachePath;
164 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
165 extern const char* gLocalWtPath;
166 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
167 extern const char* gSharedCachePath;
168 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
169 extern const char* gSharedWtPath;
170 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
171 extern const char* gSharedPublicCachePath;
172 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
173 extern const char* gSharedPublicWtPath;
175 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
176 extern const char* gLocalCachePathKey;
177 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
178 extern const char* gLocalWtPathKey;
179 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
180 extern const char* gSharedCachePathKey;
181 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
182 extern const char* gSharedWtPathKey;
183 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
184 extern const char* gSharedPublicCachePathKey;
185 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
186 extern const char* gSharedPublicWtPathKey;
188 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/>userno>/<seat>/>seatno>/<resource>
189 extern const char* gLocalCacheFilePath;
192 extern char gAppId[MaxAppNameLen];
194 /// max key value data size
195 extern int gMaxKeyValDataSize;
198 extern DltContext gPclDLTContext;
200 /// flag to indicate if client library has been initialized
201 extern unsigned int gPclInitialized;
204 /// change signal string
205 extern const char* gChangeSignal;
206 /// delete signal string
207 extern const char* gDeleteSignal;
208 /// create signal string
209 extern const char* gCreateSignal;
213 * Global notification variables, will be used to pass
214 * the notification information into the mainloop.
216 /// notification key string
217 extern char gNotifykey[DbKeyMaxLen];
218 /// notification lbid
219 extern unsigned int gNotifyLdbid;
220 /// notification user number
221 extern unsigned int gNotifyUserNo;
222 /// notification seat number
223 extern unsigned int gNotifySeatNo;
224 /// notification reason (created, changed, deleted)
225 extern pclNotifyStatus_e gNotifyReason;
226 /// notification policy (register or unregister)
227 extern PersNotifyRegPolicy_e gNotifyPolicy;
230 // dbus timeout (5 seconds)
231 extern int gTimeoutMs;
233 // dbus pending return value
234 extern int gDbusPendingRvalue;
238 * @brief definition of change callback function
240 * @param pclNotification_s callback notification structure
242 extern int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
249 #endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ORGANIZATION_H */