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) |
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 Quests, Messages, Facesets, Faces, and AllAnimations.
Definition at line 181 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 START_TEST(), and 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(), get_faces_count(), quests_count(), and FacesetsPanel::setItem().
|
protectedpure virtual |
Create a new asset.
name | asset unique name. |
Implemented in Facesets, Archetypes, Messages, Faces, Quests, 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 CREResourcesWindow::addQuest(), FacesetLoader::load(), ArchetypeLoader::load(), MessageLoader::load(), FaceLoader::load(), QuestLoader::load(), TreasureLoader::load(), FaceLoader::loadAnimationBlock(), and START_TEST().
|
protectedpure virtual |
Destroy an asset.
item | asset to destroy. |
Implemented in Treasures, Quests, Messages, Facesets, Faces, Archetypes, and AllAnimations.
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(), ArchetypeComboBox::ArchetypeComboBox(), archetypes_for_each(), ArchetypesModel::ArchetypesModel(), ArchetypesWrapper::ArchetypesWrapper(), ResourcesManager::archetypeUse(), assets_end_load(), assets_finish_archetypes_for_play(), AssetsCollectionWrapper< Animations >::AssetsCollectionWrapper(), CREMapInformationManager::browseMaps(), MonsterResistances::buildGraph(), check_generators(), check_spells(), check_summoned(), CREQuestPanel::CREQuestPanel(), CRESubItemQuest::CRESubItemQuest(), do_pack(), FaceComboBox::FaceComboBox(), faces_for_each(), facesets_for_each(), fillEvents(), CREMainWindow::fillFacesets(), isValidArchFlesh(), CREMainWindow::onReportAlchemy(), CREMainWindow::onReportArchetypes(), CREMainWindow::onReportDuplicate(), CREMainWindow::onReportLicenses(), CREMainWindow::onReportPlayer(), CREMainWindow::onReportQuests(), CREMainWindow::onReportSpellDamage(), CREMainWindow::onReportSpells(), CREMainWindow::onReportSummon(), pack_images(), quest_for_each(), recipe_find_ingredient_cost(), FacesetsPanel::setItem(), CRETreasurePanel::setItem(), spellsTable(), and TreasureListComboBox::TreasureListComboBox().
|
inline |
Get a named asset if it exists.
name | asset name. |
Definition at line 85 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(), RecipePanel::setItem(), START_TEST(), treasureContains(), try_find_animation(), try_find_archetype(), try_find_face(), 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 144 of file AssetsCollection.h.
Referenced by ArchetypeWrapper::appearsOnTreasureList().
|
inline |
Get a named asset.
name | asset name. |
Definition at line 66 of file AssetsCollection.h.
Referenced by CREResourcesWindow::addQuest(), AssetsManager::AssetsManager(), CREQuestPanel::commitData(), 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 |
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 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 154 of file AssetsCollection.h.
Referenced by AssetsManager::dumpUndefined().
|
protected |
Known assets.
Definition at line 157 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(), and AssetsCollection< Animations >::next().
|
protected |
List of undefined assets.
Definition at line 158 of file AssetsCollection.h.
Referenced by AssetsCollection< Animations >::define(), AssetsCollection< Animations >::get(), and AssetsCollection< Animations >::undefined().