Lumiera  0.pre.03
»edit your freedom«
buffer-local-tag.hpp
Go to the documentation of this file.
1 /*
2  BUFFER-LOCAL-TAG.hpp - opaque data for BufferProvider implementation
3 
4  Copyright (C)
5  2011, 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_ENGINE_BUFFR_LOCAL_TAG_H
21 #define STEAM_ENGINE_BUFFR_LOCAL_TAG_H
22 
23 
24 #include "lib/error.hpp"
25 #include "lib/hash-value.h"
26 
27 #include <boost/functional/hash.hpp>
28 
29 
30 namespace steam {
31 namespace engine {
32 
33  namespace metadata {
34  class Key;
35  class Entry;
36  }
37  class BufferMetadata;
38 
39  using lib::HashVal;
40 
41 
42 
49  class LocalTag
50  {
51  union OpaqueData
52  {
53  uint64_t _as_number;
54  void* _as_pointer;
55  };
56 
57  OpaqueData privateID_;
58 
59  public:
60  explicit
61  LocalTag (uint64_t opaqueValue=0)
62  {
63  privateID_._as_number = opaqueValue;
64  }
65 
66  LocalTag (void* impl_related_ptr)
67  {
68  privateID_._as_number = 0;
69  privateID_._as_pointer = impl_related_ptr;
70  }
71 
73  static const LocalTag UNKNOWN;
74 
75  operator uint64_t() const
76  {
77  return privateID_._as_number;
78  }
79 
80  operator void*() const
81  {
82  return privateID_._as_pointer;
83  }
84 
85  explicit
86  operator bool() const
87  {
88  return bool(privateID_._as_number);
89  }
90 
91  friend size_t
92  hash_value (LocalTag const& lkey)
93  {
94  boost::hash<uint64_t> hashFunction;
95  return hashFunction(lkey.privateID_._as_number);
96  }
97 
98  friend bool
99  operator== (LocalTag const& left, LocalTag const& right)
100  {
101  return uint64_t(left) == uint64_t(right);
102  }
103  friend bool
104  operator!= (LocalTag const& left, LocalTag const& right)
105  {
106  return uint64_t(left) != uint64_t(right);
107  }
108 
109 
110  private:
112  LocalTag& operator= (LocalTag const& o)
113  {
114  privateID_ = o.privateID_;
115  return *this;
116  }
117 
119  friend class metadata::Key;
120  };
121 
122 
123 }} // namespace steam::engine
124 #endif /*STEAM_ENGINE_BUFFR_LOCAL_TAG_H*/
an opaque mark to be used by the BufferProvider implementation.
Steam-Layer implementation namespace root.
Description of a Buffer-"type".
Lumiera error handling (C++ interface).
static const LocalTag UNKNOWN
Marker when no distinct local key is given.
Hash value types and utilities.
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
HashVal hash_value(ProcID const &procID)
generate registry hash value based on the distinct data in ProcID.
Definition: proc-node.cpp:105