00001
00013 #ifndef BS_SIMULATOR_EVENTS_H_
00014 #define BS_SIMULATOR_EVENTS_H_
00015
00016 #include "pp_param_list.h"
00017
00018
00019 #define PUSH_LIST(seq_, size_) BOOST_PP_CAT(PUSH_LIST_, size_) seq_
00020 #define PUSH_LIST_0
00021 #define PUSH_LIST_1(x) params->push_back(boost::lexical_cast<std::string> (A1));
00022 #define PUSH_LIST_2(x) params->push_back(boost::lexical_cast<std::string> (A2)); PUSH_LIST_1
00023 #define PUSH_LIST_3(x) params->push_back(boost::lexical_cast<std::string> (A3)); PUSH_LIST_2
00024 #define PUSH_LIST_4(x) params->push_back(boost::lexical_cast<std::string> (A4)); PUSH_LIST_3
00025
00026 #define DECL(type_, name_, t_, ts_) \
00027 void BOOST_PP_CAT(on_, name_) (PARAM_LIST_FOR_EACH(t_, ts_)) \
00028 { \
00029 smart_ptr <type_> params = BS_KERNEL.create_object (type_::bs_type ()); \
00030 PUSH_LIST (BOOST_PP_TUPLE_TO_SEQ(ts_, t_), ts_) \
00031 this->fire_signal (BOOST_PP_CAT(name_, _signal), params); \
00032 }
00033
00034 #define UDECL_I(r, data, i, elem) \
00035 DECL(data, BOOST_PP_TUPLE_ELEM(3,0,elem), BOOST_PP_TUPLE_ELEM(3,1,elem), BOOST_PP_TUPLE_ELEM(3,2,elem))
00036
00037 #define DECLARE_SIGNAL_ENUM_I(r, data, i, elem) \
00038 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3,0,elem), _signal),
00039
00040 #define DECLARE_SIGNALS_ENUM(ts_, t_) \
00041 BLUE_SKY_SIGNALS_DECL_BEGIN(bs_node) \
00042 BOOST_PP_SEQ_FOR_EACH_I(DECLARE_SIGNAL_ENUM_I, _, BOOST_PP_TUPLE_TO_SEQ(ts_, t_)) \
00043 BLUE_SKY_SIGNALS_DECL_END
00044
00045 #ifdef BSPY_EXPORTING_PLUGIN
00046 #define EXPORT_SIGNAL_ENUM_I(r, data, i, elem) \
00047 .value (BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(3,0,elem)), data::BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3,0,elem), _signal))
00048
00049 #define EXPORT_SIGNALS_ENUM(name_, ts_, t_) \
00050 static void py_export_signals_enum () \
00051 { \
00052 using namespace boost::python; \
00053 enum_ <signal_codes> (BOOST_PP_STRINGIZE(BOOST_PP_CAT(name_, _signals))) \
00054 BOOST_PP_SEQ_FOR_EACH_I(EXPORT_SIGNAL_ENUM_I, name_, BOOST_PP_TUPLE_TO_SEQ(ts_, t_)) \
00055 .export_values () \
00056 ; \
00057 }
00058 #endif
00059
00060 #ifdef BSPY_EXPORTING_PLUGIN
00061 #define DECLARE_EVENT_LIST(name_, params_, ts_, t_) \
00062 public: \
00063 DECLARE_SIGNALS_ENUM(ts_, t_) \
00064 BOOST_PP_SEQ_FOR_EACH_I(UDECL_I, params_, BOOST_PP_TUPLE_TO_SEQ(ts_, t_)) \
00065 EXPORT_SIGNALS_ENUM(name_, ts_, t_)
00066 #else
00067 #define DECLARE_EVENT_LIST(name_, params_, ts_, t_) \
00068 public: \
00069 DECLARE_SIGNALS_ENUM(ts_, t_) \
00070 BOOST_PP_SEQ_FOR_EACH_I(UDECL_I, params_, BOOST_PP_TUPLE_TO_SEQ(ts_, t_))
00071 #endif
00072
00073
00074
00075 #endif // #ifndef BS_SIMULATOR_EVENTS_H_