6 DataSet<T>::DataSet(T (*create_func)(), bool (*load_func)(T, const char*), bool (*done_func)(T), void (*destr_func)(T))
13 rman = resman_create();
14 resman_set_load_func(rman, dataset_load_func, this);
15 resman_set_done_func(rman, dataset_done_func, this);
16 resman_set_destroy_func(rman, dataset_destroy_func, this);
20 DataSet<T>::~DataSet()
26 void DataSet<T>::clear()
31 rman = resman_create();
35 void DataSet<T>::update()
41 T DataSet<T>::get(const char *name) const
43 typename std::map<std::string, T>::const_iterator iter = data.find(name);
44 if(iter != data.end()) {
50 resman_lookup(rman, name, res);
55 // --- static functions to pass as callback to resman ---
58 int DataSet<T>::dataset_load_func(const char *fname, int id, void *cls)
60 DataSet<T> *dset = (DataSet<T>*)cls;
61 T data = (T)resman_get_res_data(dset->rman, id);
63 if(!dset->load(data, fname)) {
70 int DataSet<T>::dataset_done_func(int id, void *cls)
72 DataSet<T> *dset = (DataSet<T>*)cls;
74 T data = (T)resman_get_res_data(dset->rman, id);
75 int load_res = resman_get_res_result(dset->rman, id);
78 error_log("failed to load resource %d (%s)\n", id, resman_get_res_name(dset->rman, id));
80 info_log("done loading resource %d (%s)\n", id, resman_get_res_name(dset->rman, id));
90 void DataSet<T>::dataset_destroy_func(int id, void *cls)
92 DataSet<T> *dset = (DataSet<T>*)cls;
93 T data = (T)resman_get_res_data(dset->rman, id);