source: abuse/tags/pd/macabuse/inc/specache.hpp

Last change on this file was 49, checked in by Sam Hocevar, 12 years ago
  • Imported original public domain release, for future reference.
File size: 988 bytes
Line 
1#ifndef __SPECACHE_HPP_
2#define __SPECACHE_HPP_
3
4#include "specs.hpp"
5
6
7class spec_directory_cache
8{
9  class filename_node
10  {
11    public :
12    filename_node *left,*right,*next;
13    char *fn;
14    spec_directory *sd;
15    char *filename() { return fn; }
16    filename_node(char *filename, spec_directory *dir)
17    {
18      fn=(char *)memcpy(jmalloc(strlen(filename)+1,"spec_dir cache"),filename,strlen(filename)+1);
19      sd=dir;
20      next=left=right=0;     
21    }
22    ~filename_node()
23    {
24      jfree(fn);
25      delete sd;
26    }
27
28    long size;
29  } *fn_root,*fn_list;
30  void clear(filename_node *f); // private recursive member 
31  long size;
32  public :
33  spec_directory *get_spec_directory(char *filename, bFILE *fp=NULL);
34  spec_directory_cache() { fn_root=0; size=0; }
35  void clear();                             // frees up all allocated memory
36  void load(bFILE *fp);
37  void save(bFILE *fp);
38  ~spec_directory_cache() { clear(); }
39} ;
40
41extern spec_directory_cache sd_cache;
42
43#endif
Note: See TracBrowser for help on using the repository browser.