2ca1376080
No functional code altered. https://dev.haiku-os.org/ticket/17197 Change-Id: I75cc74f6be0ad968fd77c31fbe5b0f650a6fe9e0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4364 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
80 lines
2.2 KiB
C++
80 lines
2.2 KiB
C++
//----------------------------------------------------------------------
|
|
// This software is part of the Haiku distribution and is covered
|
|
// by the MIT License.
|
|
//---------------------------------------------------------------------
|
|
/*!
|
|
\file ResourcesContainer.h
|
|
ResourcesContainer interface declaration.
|
|
*/
|
|
|
|
#ifndef _RESOURCES_CONTAINER_H
|
|
#define _RESOURCES_CONTAINER_H
|
|
|
|
#include <List.h>
|
|
|
|
namespace BPrivate {
|
|
namespace Storage {
|
|
|
|
class ResourceItem;
|
|
|
|
/*!
|
|
\class ResourcesContainer
|
|
\brief Represents a collection of resources.
|
|
|
|
This class can be used to manage a collection of resources represented
|
|
by ResourceItem's. Usually it does never contain two resources with the
|
|
same type \em and ID, since AddResource() replaces an old item with the
|
|
new one, unless explicitly told not to do so. This should only be done
|
|
by ResourceFile, when type and ID of the items are not yet known.
|
|
Asside from the basic vector features like Add/RemoveResource()/
|
|
ResourceAt() and MakeEmpty() a bunch of IndexOf() methods are provided
|
|
and AssimilateResources() which incorporates all resources of another
|
|
container into this one (replacing old resources, if necessary), emptying
|
|
the other one.
|
|
|
|
The ResourceItem's in a container are deleted on destruction, unless
|
|
removed before via RemoveResource(). MakeEmpty() deletes the items as
|
|
well.
|
|
|
|
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
|
|
|
|
\version 0.0.0
|
|
*/
|
|
class ResourcesContainer {
|
|
public:
|
|
ResourcesContainer();
|
|
virtual ~ResourcesContainer();
|
|
|
|
bool AddResource(ResourceItem *item, int32 index = -1,
|
|
bool replace = true);
|
|
|
|
ResourceItem *RemoveResource(int32 index);
|
|
bool RemoveResource(ResourceItem *item);
|
|
|
|
void MakeEmpty();
|
|
|
|
void AssimilateResources(ResourcesContainer &container);
|
|
|
|
int32 IndexOf(ResourceItem *item) const;
|
|
int32 IndexOf(const void *data) const;
|
|
int32 IndexOf(type_code type, int32 id) const;
|
|
int32 IndexOf(type_code type, const char *name) const;
|
|
int32 IndexOfType(type_code type, int32 index) const;
|
|
ResourceItem *ResourceAt(int32 index) const;
|
|
int32 CountResources() const;
|
|
|
|
void SetModified(bool modified);
|
|
bool IsModified() const;
|
|
|
|
private:
|
|
BList fResources;
|
|
bool fIsModified;
|
|
};
|
|
|
|
}; // namespace Storage
|
|
}; // namespace BPrivate
|
|
|
|
#endif // _RESOURCES_CONTAINER_H
|
|
|
|
|