btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / ResourceItem.h
blob977becbab2d098fdc99cb4edd9fc43a104fd97c9
1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the MIT License.
4 //---------------------------------------------------------------------
5 /*!
6 \file ResourcesItem.h
7 ResourceItem interface declaration.
8 */
10 #ifndef _RESOURCE_ITEM_H
11 #define _RESOURCE_ITEM_H
13 #include <DataIO.h>
14 #include <String.h>
16 namespace BPrivate {
17 namespace Storage {
19 /*!
20 \class ResourceItem
21 \brief Represents a resource loaded into memory.
23 This class represents a resource completely or partially loaded into
24 memory. The minimal information stored in the object should be its
25 type, ID and name and the size of its data. If the data are not loaded
26 then additionally the offset (into a resource file) should be valid.
27 As soon as the data are loaded as well, the offset is more or less
28 meaningless.
30 Creating a new resource can be done by calling SetIdentity() after the
31 default construction. The object then represents a resource with the
32 specified type, ID and name and with empty data. Data can arbitrarily
33 be read and written using the methods the super class BMallocIO provides.
35 The memory for the resource data is owned by the ResourceItem object and
36 freed on destruction.
38 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
40 \version 0.0.0
42 class ResourceItem : public BMallocIO {
43 public:
44 ResourceItem();
45 virtual ~ResourceItem();
47 virtual ssize_t WriteAt(off_t pos, const void *buffer, size_t size);
48 virtual status_t SetSize(off_t size);
50 void SetLocation(int32 offset, size_t initialSize);
51 void SetIdentity(type_code type, int32 id, const char *name);
53 void SetOffset(int32 offset);
54 int32 Offset() const;
56 size_t InitialSize() const;
57 size_t DataSize() const;
59 void SetType(type_code type);
60 type_code Type() const;
62 void SetID(int32 id);
63 int32 ID() const;
65 void SetName(const char *name);
66 const char *Name() const;
68 void *Data() const;
70 void SetLoaded(bool loaded);
71 bool IsLoaded() const;
73 void SetModified(bool modified);
74 bool IsModified() const;
76 private:
77 int32 fOffset;
78 size_t fInitialSize;
79 type_code fType;
80 int32 fID;
81 BString fName;
82 bool fIsLoaded;
83 bool fIsModified;
86 }; // namespace Storage
87 }; // namespace BPrivate
89 #endif // _RESOURCE_ITEM_H