16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 14:49:19 +02:00

milek7/sim branch network code import

This commit is contained in:
tmj-fstate
2020-02-16 03:03:17 +01:00
parent 2ce3091e8f
commit 7a0c89f508
56 changed files with 2609 additions and 426 deletions

37
Names.h
View File

@@ -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 {