00001
00002 #ifndef RC_RESOURCE_H
00003 #define RC_RESOURCE_H
00004
00005
00006 typedef enum {
00007 RESOURCE_VERTEX_ARRAY = 0,
00008 RESOURCE_TEXTURE,
00009 RESOURCE_RENDER_TARGET,
00010 RESOURCE_CUBEMAP,
00011 RESOURCE_SHADER_PROGRAM,
00012
00013 RESOURCE_TYPE_LAST
00014
00015 } ResourceType_t;
00016
00017
00018
00019
00020
00021 class Resource {
00022 friend class SceneGraph;
00023 friend class ResourceList;
00024
00025
00026
00027 protected:
00028 Resource(
00029 const char *nidentifier,
00030 u32 purge_level,
00031 ResourceType_t rtype
00032 );
00033
00034 virtual ~Resource();
00035
00036 public:
00037
00042 virtual bool isEqual(
00043 Resource *res
00044 );
00045
00047 virtual Resource *instantiate();
00048
00049 ResourceType_t getType() const;
00050
00051 void setPurgeLevel(
00052 u32 purge_level
00053 );
00054
00055 void setMaxPurgeLevel(
00056 u32 purge_level
00057 );
00058
00059 u32 getPurgeLevel() const;
00060
00061 u32 getReferenceCount() const;
00062
00064 const char *getIdentifier() const;
00065
00070 char *getIdentifierStringCopy();
00071
00072 protected:
00073
00074 static char *getNewResourceName(
00075 char *buf,
00076 char *base,
00077 ResourceType_t type
00078 );
00079
00080 #ifdef DEBUG
00081 virtual void print(
00082 FILE *f
00083 ) { }
00084 #endif
00085
00086
00087
00088 private:
00089 u32 hash;
00090
00091
00092 u32 n_refs;
00093
00094
00095 Resource *next;
00096
00097 protected:
00098 ResourceType_t type;
00099
00100 char *identifier;
00101
00102 u32 purgeLevel;
00103
00104
00105
00106
00107 bool broken;
00108
00109 public:
00110
00111 Auxiliary auxiliary;
00112
00113 };
00114
00115 #endif
00116