AppCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StorageList.h
Go to the documentation of this file.
1 #ifndef _ESTORAGELIST_H_
2 #define _ESTORAGELIST_H_
3 
4 #include "StorageItem.h"
5 #include "UniversalDictionary.h"
6 #include <inttypes.h>
7 #include <qvariant.h>
8 
9 class StorageListPr;
10 
11 class StorageList
12 {
13 public:
14  StorageList();
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 
133 private:
134  class DataClass;
135  DataClass *d;
136 };
137 
138 #endif // _ESTORAGELIST_H_
bool GetData(const int32_t &storageDataType, const int32_t &key, T &data) const
Definition: StorageList.h:92
void AddStorageItem(const int32_t &storageDataType, const int32_t &key, const QVariant &value)
Add data(key, value) to storageItem with specific storage type storageDataType.
Definition: StorageList.cpp:175
Interface of information element which can be state input.
Definition: StorageItem.h:13
T GetItem(const int32_t &storageDataType) const
Definition: StorageList.h:54
EEventTripTicketPr __EDATAPTR d
Definition: EEventTripTicket.h:96
Definition: UniversalDictionary.h:10
void CopyStorageItem(const StorageItem *item)
Definition: StorageList.cpp:197
bool RemoveData(const int32_t &storageDataType, const int32_t &key)
Definition: StorageList.cpp:230
Definition: StorageList.h:11
StorageList()
Definition: StorageList.cpp:103
virtual ~StorageList()
Definition: StorageList.cpp:122
__ECLASS DataClass
Definition: EEventUpdateCustomerData.h:35
bool GetPointer(const int32_t key, T &data)
Definition: UniversalDictionary.h:118
void PrintToLog() const
Definition: StorageList.cpp:248
StorageItem * GetItem(const int32_t &storageDataType) const
Definition: StorageList.cpp:215
bool GetPointer(const int32_t &storageDataType, const int32_t &key, T &data) const
Definition: StorageList.h:111
bool GetData(const int32_t key, T &data)
Definition: UniversalDictionary.h:53
StorageList & operator=(const StorageList &otherInstance)
Copy all storage items(persistent and transient) to new storage list.
Definition: StorageList.cpp:137