Crossfire Server, Trunk
|
#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 * | first (std::function< bool(const T *)> op) |
T * | get (const Key &name) |
std::vector< Key > | keys () const |
T * | next (T *current) |
const std::set< Key > & | undefined () const |
virtual | ~AssetsCollection () |
Protected Member Functions | |
virtual void | added (T *) |
virtual void | replace (T *existing, T *update)=0 |
Protected Attributes | |
std::unordered_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 AssetsCollection 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 the instance is destroyed or clear() is called. The asset_destroy() and asset_create() functions must be implemented for the type T and key Key.
Actual implementations must provide some pure virtual functions.
Definition at line 55 of file AssetsCollection.h.
|
inlinevirtual |
Destroy this instance and all assets it owns.
Definition at line 62 of file AssetsCollection.h.
|
inlineprotectedvirtual |
An asset was either referenced (but undefined) or defined.
Reimplemented in Quests, Messages, Facesets, Faces, and AllAnimations.
Definition at line 203 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::define(), and AssetsCollection< Animations >::get().
|
inline |
Clear all assets.
Definition at line 69 of file AssetsCollection.h.
Referenced by START_TEST(), and AssetsCollection< Animations >::~AssetsCollection().
|
inline |
Get the number of assets.
Definition at line 80 of file AssetsCollection.h.
Referenced by assets_number_of_treasurelists(), get_faces_count(), malloc_info(), quests_count(), and FacesetsPanel::updateItem().
|
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 120 of file AssetsCollection.h.
Referenced by ArchetypesWrapper::addArchetype(), QuestsWrapper::addQuest(), CREResourcesWindow::addQuest(), FacesetLoader::load(), ArchetypeLoader::load(), MessageLoader::load(), FaceLoader::load(), TreasureLoader::load(), QuestLoader::load(), FaceLoader::loadAnimationBlock(), and START_TEST().
|
inline |
Apply a function to each asset.
op | function to apply. |
Definition at line 158 of file AssetsCollection.h.
Referenced by addArchetypes(), ArchetypeComboBox::ArchetypeComboBox(), archetypes_for_each(), ArchetypesModel::ArchetypesModel(), ResourcesManager::archetypeUse(), assets_end_load(), assets_finish_archetypes_for_play(), AssetsCollectionWrapper< Animations >::AssetsCollectionWrapper(), CREMapInformationManager::browseMaps(), build_class_list_reply(), build_race_list_reply(), MonsterResistances::buildGraph(), cfapi_system_get_archetype_vector(), check_generators(), check_spells(), check_summoned(), CRESubItemQuest::CRESubItemQuest(), do_pack(), dump_abilities(), dump_all_archetypes(), dump_animations(), dump_faces(), dump_monster_treasure(), dump_spells(), FaceComboBox::FaceComboBox(), faces_for_each(), fillEvents(), CREMainWindow::fillFacesets(), get_player_archetype(), get_spell_by_name(), isValidArchFlesh(), CREMainWindow::onReportAlchemy(), CREMainWindow::onReportArchetypes(), CREMainWindow::onReportDuplicate(), CREMainWindow::onReportLicenses(), CREMainWindow::onReportPlayer(), CREMainWindow::onReportQuests(), CREMainWindow::onReportSpellDamage(), CREMainWindow::onReportSpells(), CREMainWindow::onReportSummon(), pack_images(), polymorph_item(), polymorph_living(), print_monsters(), quest_for_each(), QuestComboBox::QuestComboBox(), recipe_find_ingredient_cost(), send_image_info(), send_map_info(), spellsTable(), START_TEST(), TreasureListComboBox::TreasureListComboBox(), and FacesetsPanel::updateItem().
|
inline |
Get a named asset if it exists.
name | asset name. |
Definition at line 108 of file AssetsCollection.h.
Referenced by ArtifactPanel::artifactChanged(), TreasureWrapper::displayIcon(), MimeUtils::extract(), finish_races(), get_message_from_identifier(), CREMainWindow::onReportAlchemyGraph(), CREMainWindow::onReportQuests(), quest_get_by_code(), CRESubItemQuest::selectedQuestChanged(), START_TEST(), treasureContains(), try_find_animation(), try_find_archetype(), try_find_face(), RecipePanel::updateItem(), and ArchetypeWrapper::uses().
|
inline |
Find the first asset matching some condition.
op | function which must return true if the asset matches, false else. |
Definition at line 167 of file AssetsCollection.h.
Referenced by ArchetypeWrapper::appearsOnTreasureList(), and SoundsDialog::soundType().
|
inline |
Get a named asset.
name | asset name. |
Definition at line 89 of file AssetsCollection.h.
Referenced by CREResourcesWindow::addQuest(), AssetsManager::AssetsManager(), find_animation(), find_archetype(), find_face(), find_treasurelist(), generate_random_treasure(), CREPixmap::init(), FacesetLoader::load(), PngLoader::load(), FaceLoader::load(), QuestLoader::load(), TreasureLoader::loadTreasure(), FaceMakerDialog::makeFaces(), CREMainWindow::onReportQuests(), and CREPixmap::setFaceset().
|
inline |
Get the names of all defined assets.
Definition at line 183 of file AssetsCollection.h.
Referenced by ArchetypesWrapper::addArchetype(), and QuestsWrapper::addQuest().
|
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 139 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 Treasures, Quests, Messages, Facesets, Faces, Archetypes, and AllAnimations.
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 177 of file AssetsCollection.h.
Referenced by AssetsManager::dumpUndefined().
|
protected |
Known assets.
Definition at line 190 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::clear(), AssetsCollection< Animations >::count(), AssetsCollection< Animations >::define(), AssetsCollection< Animations >::each(), AssetsCollection< Animations >::find(), AssetsCollection< Animations >::first(), AssetsCollection< Animations >::get(), AssetsCollection< Animations >::keys(), and AssetsCollection< Animations >::next().
|
protected |
List of undefined assets.
Definition at line 191 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::define(), AssetsCollection< Animations >::get(), and AssetsCollection< Animations >::undefined().