52 Entry(), entry(e), destroy_data(dd) { }
60 {
if (destroy_data) destroy_data(entry); }
77 void (*destroy_data)(T &);
94 KK::Assert<DBErr> ( can_cast_entry<T>(e),
" cannot cast entry to mismatched type");
102 KK::Assert<DBErr> ( can_cast_entry<T>(e),
" cannot cast entry to mismatched type");
111 typedef std::map< std::string, DBase::EntryP > dbtype;
168 put(std::string name,
const T &entry,
void (*entry_destructor)(T&)=0)
170 KK::Assert<DBErr> ( name!=
"",
"cannot use empty name" );
171 KK::Assert<DBErr> ( this->db.count(name)==0,
"name "+name+
" already in use!");
183 put(std::string name,
void (*entry_destructor)(T&)=0)
185 KK::Assert<DBErr> ( name!=
"",
"cannot use empty name" );
186 KK::Assert<DBErr> ( this->db.count(name)==0,
"name "+name+
" already in use!");
198 get(std::string name)
200 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
205 KK::Assert<DBErr> ( p ,
"type mismatch for variable "+name );
213 get(std::string name)
const
215 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
220 KK::Assert<DBErr> ( p ,
"type mismatch for variable "+name );
229 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
230 return this->db[name];
235 remove(std::string name)
237 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
241 this->db.erase(name);
247 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
249 if ( this->db[name]->traits & t )
250 this->db[name]->traits ^= t;
252 this->db[name]->traits |= t;
259 KK::Assert<DBErr> ( this->db.count(name)==1,
"name "+name+
" not in database!" );
261 return this->db[name]->traits & t;
265 bool has_key(std::string name)
const {
return this->db.count(name)!=0; }
268 size_t size()
const {
return db.size(); }
276 for ( dbtype::iterator i=this->db.begin(); i!=this->db.end(); i++ )
277 func((*i).first, *((*i).second));
285 for ( dbtype::iterator i=this->db.begin(); i!=this->db.end(); i++ )
286 func((*i).first, *((*i).second));
294 for ( dbtype::iterator i=this->db.begin(); i!=this->db.end(); i++ )
295 func((*i).first, *((*i).second));
301 for (
iterator n=db_in.begin(); n!=db_in.end(); n++ )
306 throw DBErr(
"cannot merge databases with duplicate entries");
316 KK::Assert<DBErr> ( !
has_key(to_nm),
"name "+to_nm+
" already in use!");
317 KK::Assert<DBErr> ( from.
has_key(from_nm),
"name "+to_nm+
" not in link database!");
319 db[to_nm] = from.db[from_nm];
328 KK::Assert<DBErr> ( !
has_key(to_nm),
"name "+to_nm+
" already in use!");