resource_location.h
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 enum ResourceLocationType {
00038 RES_TYPE_FILE = 0,
00039 RES_TYPE_IMAGE = 1
00040 };
00041
00051 class ResourceLocation {
00052 public:
00053
00054
00057 ResourceLocation(const std::string& filename): m_filename(filename),m_type(RES_TYPE_FILE) {}
00058
00061 virtual ~ResourceLocation() {};
00062
00066 const std::string& getFilename() const { return m_filename; };
00067
00070 virtual bool operator ==(const ResourceLocation& loc) const {
00071 if( m_type != loc.m_type ) {
00072 return false;
00073 }
00074
00075 if (m_filename.length() != loc.m_filename.length()) {
00076 return false;
00077 }
00078 if (!std::equal(m_filename.rbegin(), m_filename.rend(), loc.m_filename.rbegin())) {
00079 return false;
00080 }
00081 return true;
00082 }
00083
00087 virtual bool operator <(const ResourceLocation& loc) const {
00088 if( m_type < loc.m_type )
00089 return true;
00090 if( m_type > loc.m_type )
00091 return false;
00092 return m_filename < loc.m_filename;
00093 }
00094
00098 virtual ResourceLocation* clone() const {
00099 return new ResourceLocation(m_filename);
00100 }
00101
00102 ResourceLocationType getType() const { return m_type; }
00103
00104 protected:
00105 std::string m_filename;
00106 ResourceLocationType m_type;
00107 };
00108 }
00109
00110 #endif