1 /*
2  * This file is part of NumptyPhysics
3  * Copyright (C) 2008 Tim Edmonds
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 3 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  */
16 
17 #ifndef LEVELS_H
18 #define LEVELS_H
19 
20 #include <cstdio>
21 #include <sstream>
22 #include "Array.h"
23 
24 class Levels
25 {
26  public:
27   Levels( int numDirs=0, const char** dirs=NULL );
28   bool addPath( const char* path );
29   bool addLevel( const std::string& file, int rank=-1, int index=-1 );
30   int  numLevels();
31   int load( int i, unsigned char* buf, int bufLen );
32   int findLevel( const char *file );
33  private:
34   bool scanCollection( const std::string& file, int rank );
35   struct LevelDesc
36   {
37   LevelDesc( const std::string& f,int r=0, int i=-1)
fileLevelDesc38   : file(f), index(i), rank(r) {}
39     std::string file;
40     int         index;
41     int         rank;
42   };
43   Array<LevelDesc*> m_levels;
44 };
45 
46 #endif //LEVELS_H
47