00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #ifndef COH_SUBSCRIPT_HOLDER_HPP
00017 #define COH_SUBSCRIPT_HOLDER_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 SubscriptHolder
00035     : public TypedHolder<T>
00036     {
00037     
00038 
00039     typedef ET ElementType;
00040 
00041 
00042     
00043 
00044     public:
00045 
00046 
00047 
00048         SubscriptHolder()
00049             : TypedHolder<T>()
00050             {
00051             }
00052 
00053 
00054 
00055 
00056 
00057         template<class DT> SubscriptHolder<T, ET, IT>(const TypedHandle<DT>& that)
00058             : TypedHolder<T>(that)
00059             {
00060             }
00061 
00062 
00063 
00064 
00065 
00066         template<class DT> SubscriptHolder<T, ET, IT>(const TypedHolder<DT>& that)
00067             : TypedHolder<T>(that)
00068             {
00069             }
00070 
00071 
00072 
00073 
00074         SubscriptHolder(T* o)
00075             : TypedHolder<T>(o)
00076             {
00077             }
00078 
00079 
00080 
00081 
00082         SubscriptHolder<T, ET, IT>(const SubscriptHolder<T, ET, IT>& that)
00083             : TypedHolder<T>(that)
00084             {
00085             }
00086 
00087 
00088 
00089 
00090         ElementType& operator[](IT i) const
00091             {
00092             const T* cpo = TypedHolder<T>::m_cpo;
00093             if (NULL == cpo)
00094                 {
00095                 coh_throw_npe(typeid(T));
00096                 }
00097             return (*cpo)[i];
00098             }
00099     };
00100 
00101 COH_CLOSE_NAMESPACE2
00102 
00103 #endif // COH_SUBSCRIPT_HOLDER_HPP