00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_SUBSCRIPT_HANDLE_HPP
00017 #define COH_SUBSCRIPT_HANDLE_HPP
00018
00019 #include "coherence/lang/compatibility.hpp"
00020
00021 #include "coherence/lang/TypedHandle.hpp"
00022 #include "coherence/lang/TypedHolder.hpp"
00023
00024 COH_OPEN_NAMESPACE2(coherence,lang)
00025
00026
00027
00028
00029
00030
00031
00032
00033 template<class T, class ET, class IT = size32_t>
00034 class SubscriptHandle
00035 : public TypedHandle<T>
00036 {
00037
00038
00039 typedef ET ElementType;
00040
00041
00042
00043
00044 public:
00045
00046
00047
00048 SubscriptHandle()
00049 : TypedHandle<T>()
00050 {
00051 }
00052
00053
00054
00055
00056
00057 template<class DT> SubscriptHandle<T, ET, IT>(const TypedHandle<DT>& that)
00058 : TypedHandle<T>(that)
00059 {
00060 }
00061
00062
00063
00064
00065
00066 template<class DT> SubscriptHandle<T, ET, IT>(const TypedHolder<DT>& that)
00067 : TypedHandle<T>(that)
00068 {
00069 }
00070
00071
00072
00073
00074 SubscriptHandle(T* o)
00075 : TypedHandle<T>(o)
00076 {
00077 }
00078
00079
00080
00081
00082 SubscriptHandle<T, ET, IT>(const SubscriptHandle<T, ET, IT>& that)
00083 : TypedHandle<T>(that)
00084 {
00085 }
00086
00087
00088
00089
00090 ElementType& operator[](IT i) const
00091 {
00092 T* po = TypedHandle<T>::m_o;
00093 if (NULL == po)
00094 {
00095 coh_throw_npe(typeid(T));
00096 }
00097 return (*po)[i];
00098 }
00099 };
00100
00101 COH_CLOSE_NAMESPACE2
00102
00103 #endif // COH_SUBSCRIPT_HANDLE_HPP