/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ### File Specific: main-programmer: Christian Meyer co-programmer: ... */ #ifndef _DATA_TANK_H #define _DATA_TANK_H #include #include #include #define MAX_FILENAME_LENGHT 64 #define POSTFIX_LENGHT 5 typedef struct DataTree { struct DataTree *up, *down, *parent; char filename[MAX_FILENAME_LENGHT]; void* resource; int type; } DataTree; class DataLoader { private: void*(**load_funcs)(char*); void(**free_funcs)(void*); char** postfixes; void** placeholders; int ntypes; public: DataLoader(); ~DataLoader(); int add_filetype( char* postfix, void*(*lfunc)(char*), void(*ffunc)(void*), char* placeholderfile); void* load_file( char* file, int type); int get_type( char* file); void* get_placeholder( int type); void free_file( void* resource, int type); }; class DataTank { private: // resources stored in binary tree structure DataTree* tree; // data loader DataLoader* loader; // tree functions void tree_add( void* r, char* filename, int type); DataTree* tree_find( char* file); void tree_remove( DataTree* rem); void tree_delete(); public: DataTank(); ~DataTank(); void* get( char* file); void unload( char* file); int add_filetype( char* postfix, void*(*lfunc)(char*), void(*ffunc)(void*), char* placeholderfile); void precache( char* resfile, void(*pfunc)(int, float, char*)); void save_precache( char* file); void save_node( DataTree* act, FILE* out); DataTree* tree_highest( DataTree* t); DataTree* tree_lowest( DataTree* t); }; #endif