Sleeping Wombat GUI  0.100
swGUI
ChunkRepr.h
Go to the documentation of this file.
1 #pragma once
2 
9 
14 
15 
16 namespace sw
17 {
18 
19 class ChunkRepr;
20 DEFINE_PTR_TYPE( ChunkRepr );
21 DEFINE_WPTR_TYPE( ChunkRepr );
22 
23 class ImplHCF;
24 
25 
27 class ChunkRepr : public std::enable_shared_from_this< ChunkRepr >
28 {
31 private:
33 
35 
37 
38  ChunkReprWPtr m_parent;
39  ChunkReprPtr m_nextChunk;
40  ChunkReprPtr m_childChunk;
41 
42  AttributeReprPtr m_firstAttrib;
43 
45 
46 private:
48  ChunkRepr ( ImplHCF* hcf, ChunkReprPtr& parent );
50  ChunkRepr ( ImplHCF* hcf, ChunkReprPtr& parent, Size fileOffset );
51 
52 public:
53  static ChunkReprPtr CreateFromFile ( ImplHCF* hcf, ChunkReprPtr parent, Size fileOffset );
54  static ChunkReprPtr Create ( ImplHCF* hcf, ChunkReprPtr parent );
55 
56 
57  Chunk CreateChunk ();
58 
61  Chunk NextChunk ();
62 
65  Chunk FirstChild ();
66 
68  bool HasChildren () const;
69 
72  Chunk ParentChunk ();
73 
74 
75  Attribute AddAttribute ( AttributeType type, const DataPtr data, Size dataSize );
76  bool Fill ( const DataPtr data, Size dataSize );
77 
80 
83 
84  void AddNextChunk ( ChunkReprPtr& newChunk );
85 
86 
87  bool CheckValidity () const;
88 
89 private:
90  bool CanAddAttribute () const;
91  bool CanCreateChunk () const;
92  bool CanFillData () const;
93  bool CanLoadData () const;
94 
95  void WriteHeader ( Size revertOffset );
96  void LoadHeader ( Size revertOffset );
97  void UpdateHeader ();
98 
100 };
101 
102 
103 } // sw
bool CanLoadData() const
Definition: ChunkRepr.cpp:300
void AddNextChunk(ChunkReprPtr &newChunk)
Definition: ChunkRepr.cpp:221
Definition: ChunkHeader.h:16
Size m_absolutOffset
Offset from beginning of file.
Definition: ChunkRepr.h:36
ImplHCF * m_hcf
Definition: ChunkRepr.h:32
uint64 AttributeType
Definition: AttributeTypes.h:12
Definition: ChunkRepr.h:27
ChunkReprPtr m_childChunk
First child chunk.
Definition: ChunkRepr.h:40
Attribute AddAttribute(AttributeType type, const DataPtr data, Size dataSize)
Definition: ChunkRepr.cpp:137
Definition: DirectInputModule.cpp:11
Definition: ImplHCF.h:28
ChunkReprWPtr m_parent
Parent chunk.
Definition: ChunkRepr.h:38
Data pointer and it's size. This struct is used to transfer ownership of pointer. ...
Definition: AttributeTypes.h:34
Represents memory chunk in file.
Definition: Chunk.h:24
Main class for loading and writing HCF files.
Definition: HCF.h:34
static ChunkReprPtr Create(ImplHCF *hcf, ChunkReprPtr parent)
Definition: ChunkRepr.cpp:50
DataUnderlayingType * DataPtr
Definition: AttributeTypes.h:14
ChunkHeader m_header
Definition: ChunkRepr.h:34
DataUPack m_data
Contains chunk's data.
Definition: ChunkRepr.h:44
Plik zawiera definicje podstawowych typów zmiennych.
bool CanCreateChunk() const
Definition: ChunkRepr.cpp:270
bool CheckValidity() const
Definition: ChunkRepr.cpp:235
Chunk ParentChunk()
Get Chunks parent.
Definition: ChunkRepr.cpp:130
void WriteHeader(Size revertOffset)
Definition: ChunkRepr.cpp:324
static ChunkReprPtr CreateFromFile(ImplHCF *hcf, ChunkReprPtr parent, Size fileOffset)
Definition: ChunkRepr.cpp:43
ChunkRepr(ImplHCF *hcf, ChunkReprPtr &parent)
Write only constructor.
Definition: ChunkRepr.cpp:19
DataPack AccessData()
Returns chunk's data.
Definition: ChunkRepr.cpp:205
Data pointer and it's size.
Definition: AttributeTypes.h:19
bool CanAddAttribute() const
Definition: ChunkRepr.cpp:254
size_t Size
Definition: TypesDefinitions.h:35
Definition: Attribute.h:21
ChunkReprPtr m_nextChunk
Next chunk on the same nesting level.
Definition: ChunkRepr.h:39
DEFINE_WPTR_TYPE(AttributeRepr)
DataUPack LoadData()
Definition: ChunkRepr.cpp:358
void UpdateHeader()
Updates header in file using current info from m_header field.
Definition: ChunkRepr.cpp:350
void LoadHeader(Size revertOffset)
Definition: ChunkRepr.cpp:337
DataUPack StealData()
Returns chunk's data and transfers ownership to caller.
Definition: ChunkRepr.cpp:193
DEFINE_PTR_TYPE(AttributeRepr)
bool HasChildren() const
Check if you should call FirstChild or AccessData.
Definition: ChunkRepr.cpp:123
Chunk FirstChild()
Gets first child chunk of this chunk.
Definition: ChunkRepr.cpp:101
Chunk CreateChunk()
Definition: ChunkRepr.cpp:58
bool Fill(const DataPtr data, Size dataSize)
Definition: ChunkRepr.cpp:155
FRIEND_CLASS_TESTER(HCF)
bool CanFillData() const
Definition: ChunkRepr.cpp:285
AttributeReprPtr m_firstAttrib
Attributes list.
Definition: ChunkRepr.h:42
Chunk NextChunk()
Gets next chunk on the same nesting level.
Definition: ChunkRepr.cpp:82