mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 15:59:18 +02:00
milek7/sim branch network code import
This commit is contained in:
37
Names.h
37
Names.h
@@ -38,6 +38,43 @@ public:
|
||||
// item with this name already exists; update mapping to point to the new one, for backward compatibility
|
||||
mapping.first->second = itemhandle;
|
||||
return false; }
|
||||
void purge (std::string const &Name)
|
||||
{
|
||||
auto lookup = m_itemmap.find( Name );
|
||||
if (lookup == m_itemmap.end())
|
||||
return;
|
||||
delete m_items[lookup->second];
|
||||
|
||||
detach(Name);
|
||||
}
|
||||
void detach (std::string const &Name)
|
||||
{
|
||||
auto lookup = m_itemmap.find( Name );
|
||||
if (lookup == m_itemmap.end())
|
||||
return;
|
||||
|
||||
m_items[lookup->second] = nullptr;
|
||||
// TBD, TODO: remove from m_items?
|
||||
|
||||
m_itemmap.erase(lookup);
|
||||
}
|
||||
uint32_t find_id( std::string const &Name) const {
|
||||
auto lookup = m_itemmap.find( Name );
|
||||
return (
|
||||
lookup != m_itemmap.end() ?
|
||||
lookup->second :
|
||||
-1 );
|
||||
}
|
||||
void purge (Type_ *Item)
|
||||
{
|
||||
for (auto it = m_items.begin(); it != m_items.end(); it++) {
|
||||
if (*it == Item) {
|
||||
delete *it;
|
||||
*it = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// locates item with specified name. returns pointer to the item, or nullptr
|
||||
Type_ *
|
||||
find( std::string const &Name ) const {
|
||||
|
||||
Reference in New Issue
Block a user