00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_CLASS_SPEC_HPP
00017 #define COH_CLASS_SPEC_HPP
00018
00019 #include "coherence/lang/compatibility.hpp"
00020
00021 #include "coherence/lang/lang_spec.hpp"
00022 #include "coherence/lang/TypedHandle.hpp"
00023 #include "coherence/lang/TypedHolder.hpp"
00024
00025 COH_OPEN_NAMESPACE2(coherence,lang)
00026
00027 class Object;
00028
00029 extern COH_EXPORT void coh_throw_clone_not_supported(const std::type_info&);
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 template<class T, class E = extends<Object, void>, class I = implements<> >
00081 class COH_EXPORT_SPEC class_spec
00082 : public E, public E::inherited, public virtual I::implements_chain
00083 {
00084
00085
00086 public:
00087
00088
00089
00090 typedef class_spec this_spec;
00091
00092
00093
00094
00095 typedef factory<T> factory_spec;
00096
00097
00098
00099
00100 typedef class_spec super;
00101
00102
00103
00104
00105 typedef typename E::inherited super_spec;
00106
00107
00108
00109
00110 typedef typename E::inherited_literal inherited;
00111
00112
00113
00114
00115
00116
00117 typedef typename E::alias alias;
00118
00119
00120
00121
00122 typedef TypedHandle<T> Handle;
00123
00124
00125
00126
00127 typedef TypedHandle<const T> View;
00128
00129
00130
00131
00132 typedef TypedHolder<T> Holder;
00133
00134
00135
00136
00137 typedef typename I::interface_1 interface_1;
00138 typedef typename I::interface_2 interface_2;
00139 typedef typename I::interface_3 interface_3;
00140 typedef typename I::interface_4 interface_4;
00141 typedef typename I::interface_5 interface_5;
00142 typedef typename I::interface_6 interface_6;
00143 typedef typename I::interface_7 interface_7;
00144 typedef typename I::interface_8 interface_8;
00145 typedef typename I::interface_9 interface_9;
00146 typedef typename I::interface_10 interface_10;
00147 typedef typename I::interface_11 interface_11;
00148 typedef typename I::interface_12 interface_12;
00149 typedef typename I::interface_13 interface_13;
00150 typedef typename I::interface_14 interface_14;
00151 typedef typename I::interface_15 interface_15;
00152 typedef typename I::interface_16 interface_16;
00153
00154
00155
00156
00157 protected:
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 COH_DEFINE_PROXY_CONSTRUCTORS(class_spec)
00168
00169 public:
00170
00171
00172
00173
00174
00175
00176
00177
00178 COH_DEFINE_CREATE_METHODS(Handle, factory_spec::create)
00179
00180 virtual TypedHandle<Object> clone() const
00181 {
00182 coh_throw_clone_not_supported(typeid(T));
00183 return NULL;
00184 }
00185
00186 virtual size64_t sizeOf(bool fDeep = false) const
00187 {
00188 return fDeep
00189 ? inherited::sizeOf( true)
00190 : sizeof(T);
00191 }
00192
00193 virtual void* _cast(const std::type_info* pInfo) const
00194 {
00195
00196
00197
00198 static const std::type_info* pInfoThis = &typeid(T);
00199 if (pInfoThis == pInfo)
00200 {
00201 return (void*) static_cast<const T*>(this);
00202 }
00203
00204 void* pCast = super_spec::_cast(pInfo);
00205
00206 return pCast ? pCast : I::implements_chain::_icast(pInfo);
00207 }
00208
00209 protected:
00210
00211
00212
00213
00214
00215 static inline Handle create(const T& that)
00216 {
00217 return Handle(factory_spec::create(that));
00218 }
00219 };
00220
00221 COH_CLOSE_NAMESPACE2
00222
00223 #endif // COH_CLASS_SPEC_HPP