BlankMat 0.1.0
Free open-source 3D texture creation application
|
Container class for storing key value pairs. Should not be instantiated directly, but should be overridden by a class that implements additional functionality. (If not overriden, this class is functionally equivalent to an unordered map, just use that instead) More...
Public Member Functions | |
void | Read (const std::string &scope, std::ifstream &file, bool clear) override |
Reads this container from the file. | |
void | Write (std::ofstream &file) override |
Writes this container to the file. | |
void | Clear () override |
Clears the container of all items, deleting them. | |
void | ClearData () |
Clears the data of the container without deleting it. Only use this if pointers to the data exist elsewhere. | |
unsigned int | WriteCount () override |
Returns the number of items that will be written from the container. | |
unsigned int | Count () |
Returns the number of elements in the container. | |
bool | Empty () |
Returns whether the container is empty or not. | |
virtual std::string | GetUniqueName (const std::string &name) |
Returns a unique name, incrementing the existing name until it is unique. | |
virtual bool | Select (const std::string &name) |
Selects the given item. Does nothing if the item is not part of the container. | |
virtual bool | IsDeleteable (T *item) |
Returns whether the given item is deletable (ie. not a default element or internal) | |
virtual bool | Select (T *item) |
Selects the given item. Does nothing if the item is not part of the container. | |
virtual void | Deselect () |
Deselects the currently selected item. | |
virtual const std::string | GetSelectedName () |
Returns the currently selected item. | |
virtual T * | GetSelectedItem () |
Returns the currently selected item. | |
virtual T * | Add (const std::string &name, T *item, bool replace, bool select=false) |
Adds the given item to the container, or if it already exists, updates the item to the given one. | |
virtual bool | TryDelete (T *item) |
Attempts to delete the given item. Does nothing if the item is not deleteable or is null. | |
virtual bool | Remove (const std::string &name) |
Removes the given item from the container. | |
virtual bool | Remove (T *item) |
Removes the given item from the container. | |
virtual T * | GetItem (const std::string &name) |
Returns the item with the given key, or nullptr if not found. | |
virtual const std::string | GetKey (T *item) |
Returns the key of the item given, or an empty string if not found. | |
virtual bool | Contains (const std::string &name) |
Returns whether the container contains an item with the given name. | |
virtual bool | Rename (const std::string &name, const std::string &newName) |
Renames the given item to the new name, or the new name with appended numbers. | |
virtual const std::unordered_map< std::string, T * > & | Data () |
Returns a reference to the data stored in the container. | |
~IContainer () | |
Clears all of the container, deleting its elements. | |
Protected Member Functions | |
virtual bool | SkipItem (T *item) |
Returns whether the item should be skipped or not. | |
virtual void | RenameItem (T *item, const std::string &name)=0 |
Renames the given item to the given name. | |
virtual const std::pair< std::string, T * > | ReadItem (const std::string &scope, std::ifstream &file)=0 |
Reads the next item from the input file stream. | |
virtual void | WriteItem (const std::string &key, T *item, std::ofstream &file)=0 |
Writes the given item into the output file stream. | |
Protected Attributes | |
std::unordered_map< std::string, T * > | mData |
Data of the container. | |
std::string | mCurSelectedName |
Currently selected item's name. | |
T * | mCurSelectedItem |
Currently selected item. | |
Container class for storing key value pairs. Should not be instantiated directly, but should be overridden by a class that implements additional functionality. (If not overriden, this class is functionally equivalent to an unordered map, just use that instead)
T | Type of item to store |
|
inline |
Clears all of the container, deleting its elements.
|
inlinevirtual |
Adds the given item to the container, or if it already exists, updates the item to the given one.
name | Name of the item |
item | The item to store |
replace | Whether to replace duplicate items (true) or rename the incoming item (false) |
select | Whether to select the item after adding it |
|
inlineoverridevirtual |
Clears the container of all items, deleting them.
Implements IWritable.
|
inline |
Clears the data of the container without deleting it. Only use this if pointers to the data exist elsewhere.
|
inlinevirtual |
Returns whether the container contains an item with the given name.
name | Name of the item |
|
inline |
Returns the number of elements in the container.
|
inlinevirtual |
Returns a reference to the data stored in the container.
|
inlinevirtual |
Deselects the currently selected item.
|
inline |
Returns whether the container is empty or not.
|
inlinevirtual |
Returns the item with the given key, or nullptr if not found.
name | Name of item to find |
|
inlinevirtual |
Returns the key of the item given, or an empty string if not found.
item | Item to search for |
|
inlinevirtual |
Returns the currently selected item.
|
inlinevirtual |
Returns the currently selected item.
|
inlinevirtual |
Returns a unique name, incrementing the existing name until it is unique.
name | Starting name |
scope | Namespace of the item |
|
inlinevirtual |
Returns whether the given item is deletable (ie. not a default element or internal)
name | Item to consider |
Reimplemented in CameraContainer, LightContainer, MaterialContainer, and TextureContainer.
|
inlineoverridevirtual |
Reads this container from the file.
scope | Scope to read in |
file | File to read from |
clear | Whether to overwrite the contents of the item |
Implements IWritable.
|
protectedpure virtual |
Reads the next item from the input file stream.
scope | Scope to read item in |
file | File to read |
Implemented in CameraContainer, EntityContainer, LightContainer, MaterialContainer, MeshContainer, ShaderContainer, and TextureContainer.
|
inlinevirtual |
Removes the given item from the container.
name | Name of item to remove |
|
inlinevirtual |
Removes the given item from the container.
item | Item to remove |
|
inlinevirtual |
Renames the given item to the new name, or the new name with appended numbers.
name | Name of the item to rename |
newName | Name to rename to |
|
protectedpure virtual |
Renames the given item to the given name.
item | Item to rename |
Implemented in CameraContainer, EntityContainer, LightContainer, MaterialContainer, MeshContainer, ShaderContainer, and TextureContainer.
|
inlinevirtual |
Selects the given item. Does nothing if the item is not part of the container.
name | Name of item to select |
|
inlinevirtual |
Selects the given item. Does nothing if the item is not part of the container.
item | Item to select |
|
inlineprotectedvirtual |
Returns whether the item should be skipped or not.
item | Item to consider |
Reimplemented in MaterialContainer, and TextureContainer.
|
inlinevirtual |
Attempts to delete the given item. Does nothing if the item is not deleteable or is null.
item | Item to try to delete |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Returns the number of items that will be written from the container.
Implements IWritable.
|
protectedpure virtual |
Writes the given item into the output file stream.
key | Key of item |
item | Item to write |
file | File to write to |
Implemented in CameraContainer, EntityContainer, LightContainer, MaterialContainer, MeshContainer, ShaderContainer, and TextureContainer.
|
protected |
Currently selected item.
|
protected |
Currently selected item's name.
|
protected |
Data of the container.