00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ASSET_CATEGORY_H
00025 #define ASSET_CATEGORY_H
00026
00027 #include <string>
00028 #include <iostream>
00029 #include <boost/functional/hash.hpp>
00030
00031
00032
00033 namespace asset
00034 {
00035 using std::string;
00036 using std::ostream;
00037
00044 enum Kind
00045 {
00046 AUDIO,
00047 VIDEO,
00048 EFFECT,
00049 CODEC,
00050 STRUCT,
00051 META
00052 };
00053
00064 class Category
00065 {
00066 public:
00067
00068 private:
00069 Kind kind_;
00070 string path_;
00071
00072 public:
00073 Category (const Kind root, string subfolder ="")
00074 : kind_(root), path_(subfolder) {};
00075
00076 bool operator== (const Category& other) const { return kind_== other.kind_ && path_== other.path_; }
00077 bool operator!= (const Category& other) const { return kind_!= other.kind_ || path_!= other.path_; }
00078
00079 bool hasKind (Kind refKind) const { return kind_ == refKind; }
00080 bool isWithin (const Category&) const;
00081 void setPath (const string & newpath) { this->path_ = newpath; }
00082
00083
00084 operator string () const;
00085
00086
00087 friend size_t hash_value (const Category& cat)
00088 {
00089 size_t hash = 0;
00090 boost::hash_combine(hash, cat.kind_);
00091 boost::hash_combine(hash, cat.path_);
00092 return hash;
00093 }
00094
00095 int compare (const Category& co) const
00096 {
00097 int res = int(kind_) - int(co.kind_);
00098 if (0 != res)
00099 return res;
00100 else
00101 return path_.compare (co.path_);
00102 }
00103
00104 };
00105
00106 inline ostream& operator<< (ostream& os, const Category& cago) { return os << string(cago); }
00107
00108
00109
00110 }
00111 #endif