Lumiera  0.pre.03
»edit your freedom«
category.hpp
Go to the documentation of this file.
1 /*
2  CATEGORY.hpp - tree like classification of Assets
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
20 #ifndef STEAM_ASSET_CATEGORY_H
21 #define STEAM_ASSET_CATEGORY_H
22 
23 #include "lib/symbol.hpp"
24 #include "lib/hash-standard.hpp"
25 
26 #include <string>
27 #include <boost/functional/hash.hpp>
28 
29 
30 
31 namespace steam {
32 namespace asset {
33 
34  using lib::Literal;
35 
36  using std::string;
37  using std::ostream;
38 
46  enum Kind
47  { AUDIO
48  , VIDEO
49  , EFFECT
50  , CODEC
51  , STRUCT
52  , META
53  };
54 
55  /************************************************************************************/
66  class Category
67  {
68 
69  Kind kind_;
70  string path_;
71 
72  public:
73  Category (const Kind root, Literal subfolder ="")
74  : kind_(root), path_(subfolder) {};
75 
76  bool operator== (Category const& other) const { return kind_== other.kind_ && path_== other.path_; }
77  bool operator!= (Category const& other) const { return kind_!= other.kind_ || path_!= other.path_; }
78 
79  bool hasKind (Kind refKind) const { return kind_ == refKind; }
80  bool isWithin (Category const&) const;
81  void setPath (string const& newpath) { this->path_ = newpath; }
82 
83 
84  operator string () const;
85 
86  friend size_t hash_value (Category const&);
87 
88 
89  int
90  compare (Category const& co) const
91  {
92  int res = int(kind_) - int(co.kind_);
93  if (0 != res)
94  return res;
95  else
96  return path_.compare (co.path_);
97  }
98 
99  };
100 
101 
102  inline size_t
103  hash_value (Category const& cat)
104  {
105  size_t hash = 0;
106  boost::hash_combine(hash, cat.kind_);
107  boost::hash_combine(hash, cat.path_);
108  return hash;
109  }
110 
111 
112 
113 }} // namespace steam::asset
114 #endif
bool isWithin(Category const &) const
hierarchical inclusion test.
Definition: category.cpp:60
Tree like classification of Assets.
Definition: category.hpp:66
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:76
Steam-Layer implementation namespace root.
Marker types to indicate a literal string and a Symbol.
Helper to use a single extension point for specialised hash functions.
Kind
top-level distinction of different Kinds of Assets.
Definition: category.hpp:46
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:35