Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9714 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 1, 2006, 7:50:24 PM (18 years ago)
Author:
bensch
Message:

some thoughts on Resources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/resource.h

    r7195 r9714  
    1010#include "multi_type.h"
    1111#include <string>
    12 
    13 // FORWARD DECLARATION
    14 
    15 
    16 
    17 //! An enumerator for different (UN)LOAD-types.
    18 /**
    19  * RP_NO:        will be unloaded on request
    20  * RP_LEVEL:     will be unloaded at the end of a Level
    21  * RP_CAMPAIGN:  will be unloaded at the end of a Campaign
    22  * RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
    23  */
    24 typedef enum ResourcePriority
    25 {
    26   RP_NO        =   0,
    27   RP_LEVEL     =   1,
    28   RP_CAMPAIGN  =   2,
    29   RP_GAME      =   3
    30 };
    31 
    32 
     12#include <vector>
     13#include <set>
    3314
    3415//! A Resource is an Object, that can be loaded from Disk
     
    3617 *
    3718 */
    38 class Resource : virtual public BaseObject {
     19class Resource : virtual public BaseObject
     20{
     21public:
     22  class Priority
     23  {
     24  public:
     25    void setPriorityName(unsigned int level, const std::string& name)
     26    {
     27      if (_priorityName.size() <= level)
     28        _priorityName.resize(level+1);
     29      _priorityName[level] = name;
     30    }
     31  private:
     32    std::vector<std::string>     _priorityName;
     33  };
    3934
    40  public:
    41    Resource(const std::string& fileName);
     35
     36  class Type
     37  {
     38  public:
     39    Type(const NewClassID& classID) : _classID(classID) { };
     40
     41    void addExtension(const std::string& extension);
     42
     43  private:
     44    const NewClassID&                _classID;
     45    std::vector<std::string>      _resourcePaths;
     46    std::vector<std::string>      _resourceSubPaths;
     47    std::vector<std::string>      _fileExtensions;
     48
     49  };
     50
     51
     52public:
     53  Resource(const std::string& fileName);
    4254  virtual ~Resource();
    4355
     
    4658  virtual bool unload();
    4759
    48  private:
    49    std::string       fileName;
    5060
    51    unsigned int      referenceCount;    //!< How many times this Resource has been loaded.
    52 /// TODO REMOVE THIS:   ResourceType      type;              //!< ResourceType of this Resource.
    53    ResourcePriority  prio;              //!< The Priority of this resource. (can only be increased, so noone else will delete this)
     61private:
    5462
    55    MultiType         param[3];          //!< The Parameters given to this Resource.
     63  static std::vector<std::vector<std::string> >     _resourcePaths;
     64
     65  static std::vector<std::string>                   _resourceClassNames;
     66
     67  //! GLOBALS
     68  static std::string                                _mainGlobalPath;
     69  static std::vector<std::string>                   _globalPaths;
     70
     71  std::string       fileName;
     72
     73  unsigned int      referenceCount;    //!< How many times this Resource has been loaded.
     74  /// TODO REMOVE THIS:   ResourceType      type;              //!< ResourceType of this Resource.
     75  ResourcePriority  prio;              //!< The Priority of this resource. (can only be increased, so noone else will delete this)
     76
     77  MultiType         param[3];          //!< The Parameters given to this Resource.
    5678};
    5779
Note: See TracChangeset for help on using the changeset viewer.