00001
00009 #ifndef BS_BOS_CORE_WELL_EVENT_PARAMS_DECL_H_
00010 #define BS_BOS_CORE_WELL_EVENT_PARAMS_DECL_H_
00011
00012 #include <boost/preprocessor/seq/for_each.hpp>
00013 #include <boost/preprocessor/cat.hpp>
00014 #include <boost/preprocessor/tuple/elem.hpp>
00015 #include <boost/preprocessor/stringize.hpp>
00016
00017 #include "named_pbase_type_helper.h"
00018
00019 #define PARAMS_DECL_BLUE_SKY(type_t, base_t, type_name) \
00020 BLUE_SKY_TYPE_STD_CREATE_T_MEM (type_t) \
00021 BLUE_SKY_TYPE_STD_COPY_T_MEM (type_t) \
00022 BS_LOCK_THIS_DECL(type_t); \
00023 \
00024 friend class type_descriptor; \
00025 \
00026 static const type_descriptor & \
00027 td_maker (const std::string &stype_postfix) \
00028 { \
00029 static blue_sky::type_descriptor td(Loki::Type2Type<type_t> () \
00030 , Loki::Type2Type <base_t> () \
00031 , Loki::Int2Type <false> () \
00032 , stype_postfix \
00033 , "" \
00034 , ""); \
00035 \
00036 return td; \
00037 } \
00038 \
00039 static blue_sky::type_descriptor bs_type() \
00040 { \
00041 return td_maker (std::string (type_name) + "_" + BOOST_CURRENT_FUNCTION); \
00042 } \
00043 virtual blue_sky::type_descriptor bs_resolve_type() const \
00044 { \
00045 return bs_type (); \
00046 }
00047
00048
00049 #define PARAMS_DECLARE_CLASS_I(r, data, i, elem) \
00050 BOOST_PP_TUPLE_ELEM (3, 0, elem),
00051
00052 #define PARAMS_DECLARE_CLASS_GETTERS_I(r, data, i, elem) \
00053 tools::named_pbase_value_type_helper <BOOST_PP_TUPLE_ELEM (3, 2, elem)>::type \
00054 BOOST_PP_CAT (get_, BOOST_PP_TUPLE_ELEM (3, 0, elem)) () const \
00055 { \
00056 idx_type index = BOOST_PP_TUPLE_ELEM (3, 0, elem); \
00057 return tools::named_pbase_value_type_helper <BOOST_PP_TUPLE_ELEM (3, 2, elem)>::get (this, index); \
00058 } \
00059 tools::named_pbase_value_type_helper <BOOST_PP_TUPLE_ELEM (3, 2, elem)>::type \
00060 BOOST_PP_CAT (get_, BOOST_PP_TUPLE_ELEM (3, 0, elem)) ( \
00061 const tools::named_pbase_value_type_helper <BOOST_PP_TUPLE_ELEM (3, 2, elem)>::type &def \
00062 ) const \
00063 { \
00064 idx_type index = BOOST_PP_TUPLE_ELEM (3, 0, elem); \
00065 return tools::named_pbase_value_type_helper <BOOST_PP_TUPLE_ELEM (3, 2, elem)>::get_d (this, index, def); \
00066 } \
00067 bool \
00068 BOOST_PP_CAT (check_, BOOST_PP_TUPLE_ELEM (3, 0, elem)) () const \
00069 { \
00070 idx_type index = BOOST_PP_TUPLE_ELEM (3, 0, elem); \
00071 return this->check_value (index); \
00072 }
00073 #define PARAMS_DECLARE_CLASS_EREG_I(r, data, i, elem) \
00074 ereg <data> (BOOST_PP_TUPLE_ELEM (3, 0, elem), \
00075 BOOST_PP_STRINGIZE (BOOST_PP_TUPLE_ELEM (3, 0, elem)), \
00076 BOOST_PP_TUPLE_ELEM (3, 1, elem), \
00077 BOOST_PP_TUPLE_ELEM (3, 2, elem));
00078
00079 #define MAIN_PARAMS_DECLARE_CLASS(class_name, seq) \
00080 struct BS_API_PLUGIN class_name : public named_pbase \
00081 { \
00082 PROP_BASE_IDX_DECL_BEGIN (class_name, named_pbase) \
00083 BOOST_PP_SEQ_FOR_EACH_I (PARAMS_DECLARE_CLASS_I, _, seq) \
00084 CLASS_NAME_TOTAL, \
00085 PROP_BASE_IDX_DECL_END \
00086 PBASE_ACCESS_MS (class_name); \
00087 BOOST_PP_SEQ_FOR_EACH_I (PARAMS_DECLARE_CLASS_GETTERS_I, _, seq) \
00088 ~class_name () {} \
00089 class_name (bs_type_ctor_param ) \
00090 : bs_refcounter (), named_pbase () \
00091 { \
00092 this->resize (CLASS_NAME_TOTAL); \
00093 BOOST_PP_SEQ_FOR_EACH_I (PARAMS_DECLARE_CLASS_EREG_I, class_name, seq) \
00094 } \
00095 class_name (const class_name &c) \
00096 : bs_refcounter (c), named_pbase () \
00097 { \
00098 this->resize (CLASS_NAME_TOTAL); \
00099 BOOST_PP_SEQ_FOR_EACH_I (PARAMS_DECLARE_CLASS_EREG_I, class_name, seq) \
00100 } \
00101 PARAMS_DECL_BLUE_SKY (class_name, named_pbase, BOOST_PP_STRINGIZE (class_name)) \
00102 };
00103
00104 #define MAIN_PARAMS(seq) \
00105 MAIN_PARAMS_DECLARE_CLASS (main_params_class, seq); \
00106 smart_ptr <main_params_class, true> main_params_; \
00107 smart_ptr <named_pbase, true> \
00108 main_params () const \
00109 { \
00110 return main_params_; \
00111 }
00112
00113 #define NEXT_LINE_PARAMS(seq) \
00114 MAIN_PARAMS_DECLARE_CLASS (next_line_params_class, seq); \
00115 typedef smart_ptr <next_line_params_class, true> sp_next_line_params_t; \
00116 seq_vector <sp_next_line_params_t> next_line_params_; \
00117 smart_ptr <named_pbase, true> \
00118 add_next_line_params () \
00119 { \
00120 sp_next_line_params_t p = BS_KERNEL.create_object (next_line_params_class::bs_type ()); \
00121 if (!p) \
00122 { \
00123 bs_throw_exception ("Can't create next_line_params"); \
00124 } \
00125 next_line_params_.push_back (p); \
00126 return p; \
00127 } \
00128 bool is_multi_line () const { return true; }
00129
00130
00131
00132 #endif // #ifndef BS_BOS_CORE_WELL_EVENT_PARAMS_DECL_H_