00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_RESOURCE_LOCATION_H
00023 #define FIFE_RESOURCE_LOCATION_H
00024
00025
00026 #include <string>
00027
00028
00029
00030
00031
00032
00033
00034
00035 namespace FIFE {
00036
00037 #define RES_TYPE_FILE 0
00038 #define RES_TYPE_IMAGE 1
00039
00049 class ResourceLocation {
00050 public:
00051
00052
00055 ResourceLocation(const std::string& filename): m_filename(filename),m_type(RES_TYPE_FILE) {}
00056
00059 virtual ~ResourceLocation() {};
00060
00064 const std::string& getFilename() const { return m_filename; };
00065
00068 virtual bool operator ==(const ResourceLocation& loc) const {
00069 if( m_type != loc.m_type ) {
00070 return false;
00071 }
00072
00073 if (m_filename.length() != loc.m_filename.length()) {
00074 return false;
00075 }
00076 if (!std::equal(m_filename.rbegin(), m_filename.rend(), loc.m_filename.rbegin())) {
00077 return false;
00078 }
00079 return true;
00080 }
00081
00085 virtual bool operator <(const ResourceLocation& loc) const {
00086 if( m_type < loc.m_type )
00087 return true;
00088 if( m_type > loc.m_type )
00089 return false;
00090 return m_filename < loc.m_filename;
00091 }
00092
00096 virtual ResourceLocation* clone() const {
00097 return new ResourceLocation(m_filename);
00098 }
00099
00100 int getType() const { return m_type; }
00101
00102 protected:
00103 std::string m_filename;
00104 int m_type;
00105 };
00106 }
00107
00108 #endif