App::PropertyList class

A class that contains multiple properties.

This is the representation of a .prop file.

PropertyLists store properties as a map, where an uint32_t (the property ID) is the key, and a Property is the value. The contents of a Property class vary depending on the property type and flags; therefore, it is recommended that, for retrieveing values from a property list, you use the static methods defined in the Property class, which are adapted to get specific types of values.

PropertyLists can have a parent; in that case, properties are also searched recursively in the parents.

PropertyList inherits from ResourceObject, and therefore, is uniquely identified using a ResourceKey. Use the class PropertyManager to get specific lists.

Base classes

class Resource::CachedResourceObject

Derived classes

class DirectPropertyList
A special kind of PropertyList that allows to have fast-access bool/int/float properties, apart from normal properties.

Public static functions

static auto SaveToDatabase(PropertyList* propList, Resource::Database* database, bool async) -> void
Adds the given property list to the IPropManager, and saves its contents into the given database.

Constructors, destructors, conversion operators

PropertyList()
~PropertyList() virtual

Public functions

auto SetProperty(uint32_t propertyID, const Property* pValue) -> void virtual
Sets the value of the property with the given ID to the specified value.
auto RemoveProperty(uint32_t propertyID) -> int virtual
Removes this propertyID and its value from the list.
auto HasProperty(uint32_t propertyID) const -> bool virtual
Tells whether a property with this propertyID is contained inside this list, or inside any of its parents.
auto GetPropertyAlt(uint32_t propertyID, Property*& result) const -> bool virtual
This does the same as GetProperty(uint32_t, Property*&).
auto GetProperty(uint32_t propertyID, Property*& result) const -> bool virtual
Gets the pointer to a Property with the given propertyID and assigns it to the parameter 'result'.
auto GetPropertyObject(uint32_t propertyID) const -> Property* virtual
Gets the pointer to a Property with the given propertyID.
auto CopyFrom(const PropertyList* pOther) -> void virtual
Copies the properties and parent from pOther.
auto AddPropertiesFrom(const PropertyList* pOther) -> void virtual
Copies all the properties from pOther to this property list.
auto CopyAllPropertiesFrom(const PropertyList* pOther) -> void virtual
Copies all the properties from pOther.
auto AddAllPropertiesFrom(const PropertyList* pOther) -> void virtual
Similar to void CopyPropertiesFrom(PropertyList* pOther), but this copies all the properties from pOther parents as well.
auto Read(IO::IStream* pInputStream) -> bool virtual
Fills this PropertyList with the information contained in the given IO::IStream, according to the PROP file format.
auto Write(IO::IStream* pOutputStream) const -> bool virtual
Writes this PropertyList into the given IO::IStream, according to the PROP file format.
auto GetPropertyIDs(eastl::vector<uint32_t>& dst) const -> void virtual
Fills the given vector with all the property IDs contained in this PropertyList.
auto Clear() -> void virtual
Removes all the properties from this PropertyList.
auto SetParent(PropertyList* pParent) -> void
Changes the parent of this list.

Protected types

using PropertyMap = eastl::vector_map<uint32_t, Property>

Protected variables

PropertyMap mProperties
PropertyListPtr mpParent
int mnOperationsDone

Function documentation

static void App::PropertyList::SaveToDatabase(PropertyList* propList, Resource::Database* database, bool async)

Adds the given property list to the IPropManager, and saves its contents into the given database.

Parameters
propList The property list to save
database The destination database
async If true, schedule to save it asynchronously and return immediately

The current resource key of the propList will be used as its file name.

void App::PropertyList::SetProperty(uint32_t propertyID, const Property* pValue) virtual

Sets the value of the property with the given ID to the specified value.

Parameters
propertyID The ID of the property to add.
pValue The value of the property, stored inside a Property object of the appropiate type.

If no property with that ID exists in this list, a new one will be created and added to the list. This does not affect the parent PropertyList; this way you are ensured that the value modified will only affect the current list.

int App::PropertyList::RemoveProperty(uint32_t propertyID) virtual

Removes this propertyID and its value from the list.

Parameters
propertyID The ID of the property to remove.
Returns true if the property was removed, false if it did not exist.

This does not affect the parent PropertyList.

bool App::PropertyList::HasProperty(uint32_t propertyID) const virtual

Tells whether a property with this propertyID is contained inside this list, or inside any of its parents.

Parameters
propertyID The ID of the property to check whether it exists.

This function will be called recursively on the PropertyList's parents until the property is found (which returns true) or no parents are left to check (which returns false).

bool App::PropertyList::GetPropertyAlt(uint32_t propertyID, Property*& result) const virtual

This does the same as GetProperty(uint32_t, Property*&).

It is rarely used.

bool App::PropertyList::GetProperty(uint32_t propertyID, Property*& result) const virtual

Gets the pointer to a Property with the given propertyID and assigns it to the parameter 'result'.

Parameters
propertyID The ID of the property to find.
result out The destination that will be assigned with the pointer to the found property (if any).
Returns true if the property was found, false otherwise.

If no property with that ID is found, the function will return false and 'result' will remain unmodified. This function will be called recursively on the PropertyList's parents until the property is found (which returns true) or no parents are left to check (which returns false).

Property* App::PropertyList::GetPropertyObject(uint32_t propertyID) const virtual

Gets the pointer to a Property with the given propertyID.

Parameters
propertyID The ID of the property to get.

This always returns a value: either the found property, or a default property object. However, using this method is not recommended, since there is no way to know if the returned property is the default one or not. Therefore, this method should only be used in cases where the value of the property does not really matter. This function will be called recursively on the PropertyList's parents until the property is found (which returns true) or no parents are left to check (which returns false).

void App::PropertyList::CopyFrom(const PropertyList* pOther) virtual

Copies the properties and parent from pOther.

Parameters
pOther The PropertyList whose properties will be copied.

After calling this method, this object will be identical to pOther (except for the ResourceKey name); that is, it will have the same properties and the same parent.

void App::PropertyList::AddPropertiesFrom(const PropertyList* pOther) virtual

Copies all the properties from pOther to this property list.

Parameters
pOther The PropertyList whose properties will be copied.

The existing properties will not be deleted; their values might get overrided if they are contained in pOther, however.

void App::PropertyList::CopyAllPropertiesFrom(const PropertyList* pOther) virtual

Copies all the properties from pOther.

Parameters
pOther The PropertyList whose properties will be copied.

The existing properties will be removed. The properties will be copied recursively from every pOther parent, so you will end up with a similar result to void AddAllPropertiesFrom(PropertyList* pOther); the difference is that the existing properties will be removed. This PropertyList's parent will be set to null; this way is ensured that this object will end up having only the same properties as pOther and its parents.

void App::PropertyList::AddAllPropertiesFrom(const PropertyList* pOther) virtual

Similar to void CopyPropertiesFrom(PropertyList* pOther), but this copies all the properties from pOther parents as well.

Parameters
pOther The PropertyList whose properties will be copied.

This method will be called recursively on pOther's parents until no parents are left, and then the properties from pOther will be copied. This ensure that pOther properties have priority over their parents'.

bool App::PropertyList::Read(IO::IStream* pInputStream) virtual

Fills this PropertyList with the information contained in the given IO::IStream, according to the PROP file format.

Parameters
pInputStream The IStream where the data will be read from.
Returns true if everything could be successfully read, false otherwise.

If there's any error while reading the file, the operation will be interrupted, and no more properties will be read.

bool App::PropertyList::Write(IO::IStream* pOutputStream) const virtual

Writes this PropertyList into the given IO::IStream, according to the PROP file format.

Parameters
pOutputStream The IStream where the data will be written.
Returns true if everything could be successfully written, false otherwise.

If there's any error while writing the file, the operation will be interrupted, and no more properties will be written.

void App::PropertyList::GetPropertyIDs(eastl::vector<uint32_t>& dst) const virtual

Fills the given vector with all the property IDs contained in this PropertyList.

Parameters
dst out A uint32_t vector where the IDs will be put.

This does not include the properties contained in the parent.

void App::PropertyList::SetParent(PropertyList* pParent)

Changes the parent of this list.

The 'parent' property will be changed accordingly.