Crossfire Server, Trunk
R22047
|
#include <AssetsCollection.h>
Public Member Functions | |
void | clear () |
size_t | count () const |
T * | define (const Key &name, T *asset) |
void | each (std::function< void(T *)> op) |
T * | find (const Key &name) |
T * | get (const Key &name) |
T * | next (T *current) |
const std::set< Key > & | undefined () const |
Protected Member Functions | |
virtual void | added (T *) |
virtual T * | create (const Key &name)=0 |
virtual void | destroy (T *item)=0 |
virtual void | replace (T *existing, T *update)=0 |
Protected Attributes | |
std::map< Key, T * > | m_assets |
std::set< Key > | m_undefined |
Collection of assets identified by a unique name. An asset is whetever is wanted, no assumption are done on the class.
A pointer to an asset returned by this class is deleted only when the NamedAssets instance is destroyed. The contents of the asset itself may change though.
If an asset is searched for and created on the fly, it is marked as "undefined" until actually defined through a call to define().
Assets are owned by this instance, and deleted when clear() is called. Because of how C++ destructors work, clear() unfortunately can't be called automatically (virtual function).
Actual implementations must provide some pure virtual functions.
Definition at line 39 of file AssetsCollection.h.
|
inlineprotectedvirtual |
An asset was either referenced (but undefined) or defined.
Reimplemented in Facesets, Messages, Faces, and AllAnimations.
Definition at line 171 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::define(), and AssetsCollection< Animations >::get().
|
inline |
Destroy all assets.
Definition at line 46 of file AssetsCollection.h.
Referenced by AssetsManager::~AssetsManager().
|
inline |
Get the number of assets.
Definition at line 57 of file AssetsCollection.h.
Referenced by assets_number_of_animations(), assets_number_of_archetypes(), assets_number_of_treasurelists(), and get_faces_count().
|
protectedpure virtual |
Create a new asset.
name | asset unique name. |
Implemented in Archetypes, Facesets, Messages, Faces, AllAnimations, and Treasures.
Referenced by AssetsCollection< Animations >::get().
|
inline |
Define an asset, erasing an existing one.
name | unique asset name. |
asset | new version of the asset. This pointer may become invalid and must not be used after the call. |
Definition at line 97 of file AssetsCollection.h.
Referenced by FacesetLoader::load(), MessageLoader::load(), FaceLoader::load(), ArchetypeLoader::load(), TreasureLoader::load(), and FaceLoader::loadAnimationBlock().
|
protectedpure virtual |
Destroy an asset.
item | asset to destroy. |
Implemented in Archetypes, Facesets, Messages, Faces, AllAnimations, and Treasures.
Referenced by AssetsCollection< Animations >::clear().
|
inline |
Apply a function to each asset.
op | function to apply. |
Definition at line 135 of file AssetsCollection.h.
Referenced by addArchetypes(), animations_for_each(), archetypes_for_each(), ArchetypesModel::ArchetypesModel(), ResourcesManager::archetypeUse(), assets_end_load(), assets_finish_archetypes_for_play(), check_generators(), check_spells(), check_summoned(), do_pack(), faces_for_each(), facesets_for_each(), CREResourcesWindow::fillAnimations(), CREResourcesWindow::fillArchetypes(), CREResourcesWindow::fillFaces(), CREResourcesWindow::fillGeneralMessages(), CREResourcesWindow::fillTreasures(), CREMainWindow::onReportArchetypes(), CREMainWindow::onReportDuplicate(), pack_images(), recipe_find_ingredient_cost(), CREFacePanel::setItem(), CRETreasurePanel::setItem(), and CREAnimationPanel::setItem().
|
inline |
Get a named asset if it exists.
name | asset name. |
Definition at line 85 of file AssetsCollection.h.
Referenced by CREResourcesWindow::fillQuests(), get_message_from_identifier(), CREMainWindow::onReportAlchemyGraph(), try_find_animation(), try_find_archetype(), and try_find_face().
|
inline |
Get a named asset.
name | asset name. |
Definition at line 66 of file AssetsCollection.h.
Referenced by AssetsManager::AssetsManager(), find_animation(), find_archetype(), find_face(), find_treasurelist(), finish_races(), CREPixmap::init(), FacesetLoader::load(), PngLoader::load(), FaceLoader::load(), TreasureLoader::loadTreasure(), FaceMakerDialog::makeFaces(), and CRETreeItemQuest::questModified().
|
inline |
Allow browsing assets in a list-like manner.
current | asset to get the next of, nullptr to get the first asset. |
Definition at line 116 of file AssetsCollection.h.
Referenced by get_next_archetype().
|
protectedpure virtual |
Replace an asset by an updated version.
existing | asset to be updated. |
update | new version of the asset, which must be destroyed. |
Implemented in Archetypes, Facesets, Messages, Faces, AllAnimations, and Treasures.
Referenced by AssetsCollection< Animations >::define().
|
inline |
Return the list of undefined assets, that is assets requested through get() but not defined through define().
Definition at line 144 of file AssetsCollection.h.
Referenced by AssetsManager::dumpUndefined().
|
protected |
Known assets.
Definition at line 147 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::clear(), AssetsCollection< Animations >::count(), AssetsCollection< Animations >::define(), AssetsCollection< Animations >::each(), AssetsCollection< Animations >::find(), AssetsCollection< Animations >::get(), and AssetsCollection< Animations >::next().
|
protected |
List of undefined assets.
Definition at line 148 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::define(), AssetsCollection< Animations >::get(), and AssetsCollection< Animations >::undefined().