sequence_model_fwd.hpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2005-2007 Adobe Systems Incorporated 00003 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt 00004 or a copy at http://stlab.adobe.com/licenses.html) 00005 */ 00006 00007 /******************************************************************************/ 00008 00009 #ifndef ADOBE_SEQUENCE_MODEL_FWD_HPP 00010 #define ADOBE_SEQUENCE_MODEL_FWD_HPP 00011 00012 /******************************************************************************/ 00013 00014 #ifdef ADOBE_STD_SERIALIZATION 00015 #include <iostream> 00016 #endif 00017 00018 #include <boost/operators.hpp> 00019 00020 #include <adobe/copy_on_write.hpp> 00021 00022 /******************************************************************************/ 00023 00024 namespace adobe { 00025 00026 /******************************************************************************/ 00027 00028 template <typename T> 00029 class sequence_model; 00030 00031 /******************************************************************************/ 00032 00033 namespace version_0 { 00034 00035 /******************************************************************************/ 00036 00037 template <typename T> 00038 class sequence_key : boost::equality_comparable<sequence_key<T> > 00039 { 00040 typedef T value_type; 00041 typedef copy_on_write<value_type> cow_value_type; 00042 00043 public: 00044 static const sequence_key nkey; 00045 00046 sequence_key() : 00047 value_m(0) 00048 { } 00049 00050 sequence_key(const sequence_key& rhs) : 00051 value_m(rhs.value_m) 00052 { } 00053 00054 sequence_key& operator=(const sequence_key& rhs) 00055 { value_m = rhs.value_m; return *this; } 00056 00057 inline friend bool operator==(const sequence_key& x, const sequence_key& y) 00058 { return x.value_m == y.value_m; } 00059 00060 private: 00061 friend class sequence_model<T>; 00062 00063 explicit sequence_key(cow_value_type& value) : 00064 value_m(&value) 00065 { } 00066 00067 cow_value_type* value_m; 00068 00069 #ifdef ADOBE_STD_SERIALIZATION 00070 inline friend std::ostream& operator<<(std::ostream& s, const sequence_key& key) 00071 { 00072 return key == nkey ? 00073 s << "nkey" : 00074 s << reinterpret_cast<std::size_t>(key.value_m); 00075 } 00076 #endif 00077 }; 00078 00079 template <typename T> 00080 const sequence_key<T> sequence_key<T>::nkey; 00081 00082 /******************************************************************************/ 00083 00084 } // namespace version_0 00085 00086 /******************************************************************************/ 00087 00088 using adobe::version_0::sequence_key; 00089 00090 /******************************************************************************/ 00091 00092 } // namespace adobe 00093 00094 /******************************************************************************/ 00095 00096 // This makes sequence keys binary compatible, so you can pass them across DLL 00097 // boundaries. (They are (and should always remain) simply pointers, after all.) 00098 ADOBE_NAME_TYPE_1("sequence_key:version_0:adobe", adobe::version_0::sequence_key<T0>) 00099 00100 /******************************************************************************/ 00101 // ADOBE_SEQUENCE_MODEL_FWD_HPP 00102 #endif 00103 00104 /******************************************************************************/ |