12 #ifndef PS_DATABASE_HXX
13 #define PS_DATABASE_HXX
49 void callback(
void *_caller)
OVERRIDE;
52 static const bool READONLY =
true;
53 static const bool WRITEONLY =
false;
60 if (!readHeader(db_file))
return false;
61 readMappings(db_file, db_id2name_map, db_name2id_map);
69 writeMappings(db_file, db_id2name_map);
77 writeMappings(file, db_id2name_map);
79 if (file)
delete file;
83 bool merge(
const char *_other_db_name);
100 if (it != db_name2id_map.end()) {
111 if (it != db_id2name_map.end()) {
122 if (it != db_id2name_map.end()) {
123 return it->second.compare(_name) == 0;
126 db_id2name_map[_id] = _name;
127 db_name2id_map[_name] = _id;
133 db_name2id_map.clear();
135 db_id2name_map.clear();
140 return db_id2name_map.rbegin()->first;
143 return db_id2name_map.begin()->first;
146 return db_id2name_map.size();
157 void reinit(
const char *_name,
bool _readonly);
160 : FILE_ID(
"PROBE_SET_DATABASE V1.0\n"),
164 reinit(_name, _readonly);
168 if (db_file)
delete db_file;
169 db_name2id_map.
clear();
170 db_id2name_map.clear();
177 #error ps_database.hxx included twice
178 #endif // PS_DATABASE_HXX
bool getIDForName(SpeciesID &_id, const string &_name)
Name2IDMap::const_iterator Name2IDMapCIter
bool insertMapping(SpeciesID _id, const string &_name)
bool saveTo(const char *_filename)
bool getNameForID(const SpeciesID _id, string &_name)
void setNull()
set SmartPtr to NULp
std::map< SpeciesID, SpeciesID > ID2IDMap
const PS_NodePtr getConstRootNode()
PS_Database(const char *_name, bool _readonly)
std::map< std::string, SpeciesID > Name2IDMap
void setMappings(Name2IDMap &_name2id, ID2NameMap &_id2name)
ID2NameMap::const_iterator ID2NameMapCIter
std::map< SpeciesID, std::string > ID2NameMap
static const bool WRITEONLY