AppCore
Loading...
Searching...
No Matches
StorageList.h
Go to the documentation of this file.
1#ifndef _ESTORAGELIST_H_
2#define _ESTORAGELIST_H_
3
4#include "StorageItem.h"
6#include <inttypes.h>
7#include <qvariant.h>
8
9class StorageListPr;
10
11class StorageList
12{
13public:
15
19 StorageList( const StorageList &otherStorageList );
20 StorageList( const StorageList *otherStorageList );
21 virtual ~StorageList();
22
26 StorageList &operator =( const StorageList &otherInstance );
27 StorageList &operator =( const StorageList *otherInstance );
28
37 void AddStorageItem( const int32_t &storageDataType, const int32_t &key, const QVariant &value );
38 void AddStorageItem( const int32_t &storageDataType, const int32_t &key, void *value );
39
44 void CopyStorageItem( const StorageItem *item );
45
51 StorageItem *GetItem( const int32_t &storageDataType ) const;
52
53 template<typename T>
54 T GetItem( const int32_t &storageDataType ) const
55 {
56 StorageItem *storageItem = GetItem( storageDataType );
57 if ( storageItem == NULL )
58 {
59 return NULL;
60 }
61
62 T requiredStrogeItem = DYNAMIC_CAST( T, storageItem );
63 if ( requiredStrogeItem == NULL )
64 {
65 return NULL;
66 }
67
68 return requiredStrogeItem;
69 }
70
71#ifdef EMTEST_XSCALE
72 bool GetData( const int32_t &storageDataType, const int32_t &key, QString &data ) const
73 {
74 StorageItem *storageItem = GetItem( storageDataType );
75 if ( storageItem == NULL )
76 {
77 return false;
78 }
79
80 UniversalDictionary *dictionary = DYNAMIC_CAST( UniversalDictionary *, storageItem );
81 if ( dictionary == NULL )
82 {
83 return false;
84 }
85
86 bool ok = dictionary->GetData( key, data );
87 return ok;
88 }
89#endif
90
91 template<typename T>
92 bool GetData( const int32_t &storageDataType, const int32_t &key, T &data ) const
93 {
94 StorageItem *storageItem = GetItem( storageDataType );
95 if ( storageItem == NULL )
96 {
97 return false;
98 }
99
100 UniversalDictionary *dictionary = DYNAMIC_CAST( UniversalDictionary *, storageItem );
101 if ( dictionary == NULL )
102 {
103 return false;
104 }
105
106 bool ok = dictionary->GetData<T>( key, data );
107 return ok;
108 }
109
110 template<typename T>
111 bool GetPointer( const int32_t &storageDataType, const int32_t &key, T &data ) const
112 {
113 StorageItem *storageItem = GetItem( storageDataType );
114 if ( storageItem == NULL )
115 {
116 return false;
117 }
118
119 UniversalDictionary *dictionary = DYNAMIC_CAST( UniversalDictionary *, storageItem );
120 if ( dictionary == NULL )
121 {
122 return false;
123 }
124
125 bool ok = dictionary->GetPointer<T>( key, data );
126 return ok;
127 }
128
129 bool RemoveData( const int32_t &storageDataType, const int32_t &key );
130
131 void PrintToLog() const;
132
133private:
134 class DataClass;
135 DataClass *d;
136};
137
138#endif // _ESTORAGELIST_H_
Interface of information element which can be state input.
Definition StorageItem.h:14
Definition StorageList.h:12
StorageItem * GetItem(const int32_t &storageDataType) const
void CopyStorageItem(const StorageItem *item)
StorageList(const StorageList *otherStorageList)
void AddStorageItem(const int32_t &storageDataType, const int32_t &key, void *value)
bool GetPointer(const int32_t &storageDataType, const int32_t &key, T &data) const
Definition StorageList.h:111
StorageList & operator=(const StorageList &otherInstance)
Copy all storage items(persistent and transient) to new storage list.
Definition StorageList.cpp:137
void AddStorageItem(const int32_t &storageDataType, const int32_t &key, const QVariant &value)
Add data(key, value) to storageItem with specific storage type storageDataType.
bool GetData(const int32_t &storageDataType, const int32_t &key, T &data) const
Definition StorageList.h:92
void PrintToLog() const
virtual ~StorageList()
T GetItem(const int32_t &storageDataType) const
Definition StorageList.h:54
StorageList(const StorageList &otherStorageList)
Copy persistent Storage items from @otherStorageList to new storage list.
bool RemoveData(const int32_t &storageDataType, const int32_t &key)
Definition UniversalDictionary.h:11
bool GetPointer(const int32_t key, T &data)
Definition UniversalDictionary.h:118
bool GetData(const int32_t key, T &data)
Definition UniversalDictionary.h:53