00001 // +-------------------------------------------------------------------------+ 00002 // | I__n__t__e__L__i__b 0.6.10 development | 00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. | 00004 // | | 00005 // | This is free software. The library part is available under | 00006 // | GNU LESSER GENERAL PUBLIC LICENSE v.2.1. | 00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt, or at http://www.gnu.org | 00008 // | Please see also docs/readme.txt and visit http://www.intelib.org | 00009 // | | 00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! | 00011 // +-------------------------------------------------------------------------+ 00012 00013 00014 00015 00023 #ifndef INTELIB_SWRAPPER_HPP_SENTRY 00024 #define INTELIB_SWRAPPER_HPP_SENTRY 00025 00026 #include "sexpress.hpp" 00027 #include "iexcept.hpp" 00028 #include "gensref.hpp" 00029 00031 00042 template <class Data> 00043 class SExpressionWrapper : public SExpression, public Data { 00044 public: 00046 static IntelibTypeId TypeId; 00047 00049 00054 SExpressionWrapper() 00055 : SExpression(SExpressionWrapper<Data>::TypeId) {} 00056 00058 00060 SExpressionWrapper(const Data &t) 00061 : SExpression(SExpressionWrapper<Data>::TypeId), Data(t) {} 00062 00063 #if INTELIB_TEXT_REPRESENTATIONS == 1 00064 SString TextRepresentation() const { return "#<WRAPPER>"; } 00065 #endif 00066 00067 protected: 00068 ~SExpressionWrapper() {} 00069 }; 00070 00072 template <class Data> 00073 IntelibTypeId SExpressionWrapper<Data>::TypeId(&SExpression::TypeId, true); 00074 00075 00077 template <class Data> 00078 class SWrapperRef 00079 : public GenericSReference<SExpressionWrapper<Data>, 00080 IntelibX_wrong_expression_type> 00081 { 00082 public: 00084 SWrapperRef() 00085 : GenericSReference<SExpressionWrapper<Data>, 00086 IntelibX_wrong_expression_type> 00087 (new SExpressionWrapper<Data>) {} 00088 00090 SWrapperRef(const Data &t) 00091 : GenericSReference<SExpressionWrapper<Data>, 00092 IntelibX_wrong_expression_type> 00093 (new SExpressionWrapper<Data>(t)) {} 00094 00096 SWrapperRef(const SWrapperRef<Data>& o) 00097 : GenericSReference<SExpressionWrapper<Data>, 00098 IntelibX_wrong_expression_type>(o) {} 00099 00101 SWrapperRef(const SReference &t) 00102 : GenericSReference<SExpressionWrapper<Data>, 00103 IntelibX_wrong_expression_type>(t) {} 00104 00106 ~SWrapperRef() {} 00107 }; 00108 00109 00110 #endif