00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_LANG_SPEC_HPP
00017 #define COH_LANG_SPEC_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 class Object;
00027
00028
00029
00030
00031
00032
00033 template<class T = void> class COH_EXPORT_SPEC Void
00034 {
00035 protected:
00036 virtual ~Void()
00037 {}
00038
00039 public:
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 virtual void* _cast(const std::type_info* ) const
00057 {
00058 return NULL;
00059 }
00060 };
00061
00062
00063
00064
00065
00066
00067 template<class T> class Alias
00068 {
00069 public:
00070 typedef typename T::alias alias;
00071 };
00072
00073
00074
00075
00076
00077
00078 template<> class Alias<Void<> >
00079 {
00080 public:
00081 typedef Void<> alias;
00082 };
00083
00084
00085
00086
00087
00088
00089 template<> class Alias<Object>
00090 {
00091 public:
00092 typedef Void<Object> alias;
00093 };
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 template<class I, class NEXT> class COH_EXPORT_SPEC interface_link
00106 : public virtual I, public virtual NEXT
00107 {
00108 public:
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void* _icast(const std::type_info* pInfo) const
00128 {
00129
00130
00131
00132 static const std::type_info* pInfoThis = &typeid(I);
00133 return pInfoThis == pInfo
00134 ? (void*) static_cast<const I*>(this)
00135 : NEXT::_icast(pInfo);
00136 }
00137 };
00138
00139
00140
00141
00142
00143
00144 template<class IGNORE> class COH_EXPORT_SPEC interface_link<void, IGNORE>
00145 {
00146 public:
00147 void* _icast(const std::type_info* ) const
00148 {
00149 return NULL;
00150 }
00151 };
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 template<class I1 = void,
00174 class I2 = void,
00175 class I3 = void,
00176 class I4 = void,
00177 class I5 = void,
00178 class I6 = void,
00179 class I7 = void,
00180 class I8 = void,
00181 class I9 = void,
00182 class I10 = void,
00183 class I11 = void,
00184 class I12 = void,
00185 class I13 = void,
00186 class I14 = void,
00187 class I15 = void,
00188 class I16 = void>
00189 class COH_EXPORT_SPEC implements
00190 {
00191 public:
00192 typedef interface_link<I1,
00193 interface_link<I2,
00194 interface_link<I3,
00195 interface_link<I4,
00196 interface_link<I5,
00197 interface_link<I6,
00198 interface_link<I7,
00199 interface_link<I8,
00200 interface_link<I9,
00201 interface_link<I10,
00202 interface_link<I11,
00203 interface_link<I12,
00204 interface_link<I13,
00205 interface_link<I14,
00206 interface_link<I15,
00207 interface_link<I16,
00208 void > > > > > > > > > > > > > > > >
00209 implements_chain;
00210 };
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 template<class P = Void<>, class A = typename Alias<P>::alias >
00223 class COH_EXPORT_SPEC extends
00224 {
00225 public:
00226
00227
00228
00229 typedef P inherited;
00230
00231
00232
00233
00234
00235
00236 typedef typename P::super grand;
00237
00238
00239
00240
00241 typedef A alias;
00242 };
00243
00244
00245
00246
00247
00248
00249 template<> class COH_EXPORT_SPEC extends<Void<>, Void<> >
00250 {
00251 public:
00252 typedef Void<> inherited;
00253 typedef Void<> alias;
00254 };
00255
00256
00257
00258
00259
00260
00261
00262 #define COH_LIST1(A) A##1
00263 #define COH_LIST2(A) COH_LIST1 (A), A##2
00264 #define COH_LIST3(A) COH_LIST2 (A), A##3
00265 #define COH_LIST4(A) COH_LIST3 (A), A##4
00266 #define COH_LIST5(A) COH_LIST4 (A), A##5
00267 #define COH_LIST6(A) COH_LIST5 (A), A##6
00268 #define COH_LIST7(A) COH_LIST6 (A), A##7
00269 #define COH_LIST8(A) COH_LIST7 (A), A##8
00270 #define COH_LIST9(A) COH_LIST8 (A), A##9
00271 #define COH_LIST10(A) COH_LIST9 (A), A##10
00272 #define COH_LIST11(A) COH_LIST10(A), A##11
00273 #define COH_LIST12(A) COH_LIST11(A), A##12
00274 #define COH_LIST13(A) COH_LIST12(A), A##13
00275 #define COH_LIST14(A) COH_LIST13(A), A##14
00276 #define COH_LIST15(A) COH_LIST14(A), A##15
00277 #define COH_LIST16(A) COH_LIST15(A), A##16
00278
00279
00280
00281
00282
00283
00284 #define COH_ARG_LIST1(A) A##1& a1
00285 #define COH_ARG_LIST2(A) COH_ARG_LIST1 (A), A##2& a2
00286 #define COH_ARG_LIST3(A) COH_ARG_LIST2 (A), A##3& a3
00287 #define COH_ARG_LIST4(A) COH_ARG_LIST3 (A), A##4& a4
00288 #define COH_ARG_LIST5(A) COH_ARG_LIST4 (A), A##5& a5
00289 #define COH_ARG_LIST6(A) COH_ARG_LIST5 (A), A##6& a6
00290 #define COH_ARG_LIST7(A) COH_ARG_LIST6 (A), A##7& a7
00291 #define COH_ARG_LIST8(A) COH_ARG_LIST7 (A), A##8& a8
00292 #define COH_ARG_LIST9(A) COH_ARG_LIST8 (A), A##9& a9
00293 #define COH_ARG_LIST10(A) COH_ARG_LIST9 (A), A##10& a10
00294 #define COH_ARG_LIST11(A) COH_ARG_LIST10(A), A##11& a11
00295 #define COH_ARG_LIST12(A) COH_ARG_LIST11(A), A##12& a12
00296 #define COH_ARG_LIST13(A) COH_ARG_LIST12(A), A##13& a13
00297 #define COH_ARG_LIST14(A) COH_ARG_LIST13(A), A##14& a14
00298 #define COH_ARG_LIST15(A) COH_ARG_LIST14(A), A##15& a15
00299 #define COH_ARG_LIST16(A) COH_ARG_LIST15(A), A##16& a16
00300
00301
00302
00303
00304 #define COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, N) \
00305 template<COH_LIST##N (class A)> SPEC(COH_ARG_LIST##N (A)) \
00306 : super_spec(COH_LIST##N (a)) {} \
00307 template<COH_LIST##N (class A)> SPEC(COH_ARG_LIST##N (const A)) \
00308 : super_spec(COH_LIST##N (a)) {}
00309
00310
00311
00312
00313
00314
00315 #define COH_DEFINE_PROXY_CONSTRUCTORS(SPEC) \
00316 SPEC() : super_spec() {} \
00317 SPEC(const SPEC& that) : super_spec(that) {} \
00318 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 1) \
00319 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 2) \
00320 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 3) \
00321 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 4) \
00322 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 5) \
00323 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 6) \
00324 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 7) \
00325 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 8) \
00326 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 9) \
00327 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 10) \
00328 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 11) \
00329 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 12) \
00330 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 13) \
00331 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 14) \
00332 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 15) \
00333 COH_DEFINE_PROXY_CONSTRUCTOR(SPEC, 16)
00334
00335
00336
00337
00338 #define COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, N) \
00339 template<COH_LIST##N (class A)> static RETURN create(COH_ARG_LIST##N (A)) \
00340 {return FUNCTION(COH_LIST##N(a));} \
00341 template<COH_LIST##N (class A)> static RETURN create(COH_ARG_LIST##N (const A)) \
00342 {return FUNCTION(COH_LIST##N(a));}
00343
00344
00345
00346
00347
00348
00349
00350 #define COH_DEFINE_CREATE_METHODS(RETURN, FUNCTION) \
00351 static RETURN create() {return FUNCTION();} \
00352 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 1) \
00353 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 2) \
00354 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 3) \
00355 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 4) \
00356 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 5) \
00357 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 6) \
00358 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 7) \
00359 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 8) \
00360 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 9) \
00361 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 10) \
00362 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 11) \
00363 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 12) \
00364 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 13) \
00365 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 14) \
00366 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 15) \
00367 COH_DEFINE_PROXY_CREATE_METHOD(RETURN, FUNCTION, 16)
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 template<class T> class COH_EXPORT_SPEC factory
00392 {
00393 template<class, class, class> friend class class_spec;
00394
00395 protected:
00396
00397
00398
00399
00400
00401
00402
00403
00404 COH_DEFINE_CREATE_METHODS(T*, new T)
00405 };
00406
00407 COH_CLOSE_NAMESPACE2
00408
00409 #endif // COH_LANG_SPEC_HPP