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);
64 if(!dset->load(data, fname)) {
71 int DataSet<T>::dataset_done_func(int id, void *cls)
73 DataSet<T> *dset = (DataSet<T>*)cls;
75 T data = (T)resman_get_res_data(dset->rman, id);
76 int load_res = resman_get_res_result(dset->rman, id);
79 error_log("failed to load resource %d (%s)\n", id, resman_get_res_name(dset->rman, id));
81 info_log("done loading resource %d (%s)\n", id, resman_get_res_name(dset->rman, id));
91 void DataSet<T>::dataset_destroy_func(int id, void *cls)
93 DataSet<T> *dset = (DataSet<T>*)cls;
94 T data = (T)resman_get_res_data(dset->rman, id);