mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
maintenance: removed deprecated ground code
This commit is contained in:
56
Names.h
56
Names.h
@@ -12,62 +12,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
template <typename Type_>
|
||||
class TNames {
|
||||
|
||||
public:
|
||||
// types:
|
||||
|
||||
// constructors:
|
||||
TNames() = default;
|
||||
|
||||
// destructor:
|
||||
|
||||
// methods:
|
||||
// dodanie obiektu z wskaźnikiem. updates data field if the object already exists. returns true for insertion, false for update
|
||||
bool
|
||||
Add( int const Type, std::string const &Name, Type_ Data ) {
|
||||
|
||||
auto lookup = find_map( Type ).emplace( Name, Data );
|
||||
if( lookup.second == false ) {
|
||||
// record already exists, update it
|
||||
lookup.first->second = Data;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// new record inserted, bail out
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// returns pointer associated with provided label, or nullptr if there's no match
|
||||
Type_
|
||||
Find( int const Type, std::string const &Name ) {
|
||||
|
||||
auto const &map = find_map( Type );
|
||||
auto const lookup = map.find( Name );
|
||||
if( lookup != map.end() ) { return lookup->second; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
private:
|
||||
// types:
|
||||
typedef std::unordered_map<std::string, Type_> type_map;
|
||||
typedef std::unordered_map<int, type_map> typemap_map;
|
||||
|
||||
// methods:
|
||||
// returns database stored with specified type key; creates new database if needed.
|
||||
type_map &
|
||||
find_map( int const Type ) {
|
||||
|
||||
return m_maps.emplace( Type, type_map() ).first->second;
|
||||
}
|
||||
|
||||
// members:
|
||||
typemap_map m_maps; // list of object maps of types specified so far
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename Type_>
|
||||
class basic_table {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user