CMemoryBankSerializerComp.h
Go to the documentation of this file.
1 #ifndef icbox_CMemoryBankSerializerComp_included
2 #define icbox_CMemoryBankSerializerComp_included
3 
4 
5 #include "iser/IVersionInfo.h"
7 
8 #include "icomp/CComponentBase.h"
9 
10 #include "ilog/TLoggerCompWrap.h"
11 
12 
13 namespace icbox
14 {
15 
16 
19  virtual public ifile::IFilePersistence
20 {
21 public:
23 
24  enum MessageId
25  {
26  MI_CBIOS_ERROR = 0xad20
27  };
28 
29  I_BEGIN_COMPONENT(CMemoryBankSerializerComp);
30  I_REGISTER_INTERFACE(ifile::IFilePersistence);
31 
32  I_ASSIGN(m_versionInfoCompPtr, "VersionInfo", "Provide information about archive versions", false, "VersionInfo");
33  I_ASSIGN(m_memoryBankIdAttrPtr, "MemoryBank", "Memory bank of Crypto Box", true, 1);
34  I_ASSIGN(m_partitionIdAttrPtr, "PartitionId", "Partition ID will be used", true, 999);
35  I_ASSIGN(m_accessKeyAttrPtr, "AccessKey", "User or administrator key", false, "demo");
36  I_ASSIGN(m_isAdminKeyAttrPtr, "IsAdminKey", "True, if access key is admin key", true, false);
37  I_END_COMPONENT;
38 
40 
41  // reimplemented (ifile::IFilePersistence)
42  virtual bool IsOperationSupported(
43  const istd::IChangeable* dataObjectPtr,
44  const QString* filePathPtr = NULL,
45  int flags = -1,
46  bool beQuiet = true) const;
47  virtual int LoadFromFile(istd::IChangeable& data, const QString& filePath = QString()) const;
48  virtual int SaveToFile(const istd::IChangeable& data, const QString& filePath = QString()) const;
49 
50  // reimplemented (ifile::IFileTypeInfo)
51  virtual bool GetFileExtensions(QStringList& result, int flags = -1, bool doAppend = false) const;
52  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
53 
54 protected:
55  bool CheckError(quint32 errorCode) const;
56  bool EnsurePartitionOpened() const;
57  bool EnsurePartitionClosed() const;
58  bool ReadFromMem(int offset, void* bufferPtr, int size) const;
59  bool WriteToMem(int offset, const void* bufferPtr, int size) const;
60 
61  // reimplemented (icomp::CComponentBase)
62  virtual void OnComponentCreated();
63  virtual void OnComponentDestroyed();
64 
65 private:
66  I_REF(iser::IVersionInfo, m_versionInfoCompPtr);
67  I_ATTR(int, m_memoryBankIdAttrPtr);
68  I_ATTR(int, m_partitionIdAttrPtr);
69  I_ATTR(QString, m_accessKeyAttrPtr);
70  I_ATTR(bool, m_isAdminKeyAttrPtr);
71 
72  bool m_isInitialized;
73  mutable bool m_isOpened;
74  mutable bool m_isLogged;
75 };
76 
77 
78 } // namespace icbox
79 
80 
81 #endif // !icbox_CMemoryBankSerializerComp_included
82 
83 
bool ReadFromMem(int offset, void *bufferPtr, int size) const
bool CheckError(quint32 errorCode) const
bool WriteToMem(int offset, const void *bufferPtr, int size) const
virtual int SaveToFile(const istd::IChangeable &data, const QString &filePath=QString()) const
virtual int LoadFromFile(istd::IChangeable &data, const QString &filePath=QString()) const
virtual bool GetFileExtensions(QStringList &result, int flags=-1, bool doAppend=false) const
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const

© 2007-2011 Witold Gantzke and Kirill Lepskiy