#ifndef DCM_OBJECT_GENERATOR_H #define DCM_OBJECT_GENERATOR_H #include "property_generator.hpp" namespace fusion = boost::fusion; namespace dcm { typedef std::ostream_iterator Iterator; namespace details { //grammar for a single object template struct obj_grammar : public karma::grammar()> { typename Gen::generator subrule; karma::rule()> start; details::prop_gen prop; obj_grammar(); static void getProperties(boost::shared_ptr ptr, typename details::pts::type& seq); }; //when objects should not be generated we need to get a empy rule, as obj_rule_init //trys always to access the rules attribute and when the parser_generator trait is not //specialitzed it's impossible to have the attribute type right in the unspecialized trait template struct obj_generator_fold : mpl::fold< seq, state, mpl::if_< parser_generate, mpl::push_back > >, mpl::push_back > > {}; //currently max. 10 objects are supported template struct obj_gen : public karma::grammar::type()> { typedef typename Sys::objects ObjectList; //create a vector with the appropriate rules for all objects. Do this with the rule init struct, as it gives //automatic initialisation of the rules when the objects are created typedef typename obj_generator_fold >::type init_rules_vector; //push back a empty rule so that we know where to go when nothing is to do typedef typename mpl::push_back::type rules_vector; //create the fusion sequence of our rules typedef typename fusion::result_of::as_vector::type rules_sequnce; //this struct returns the right accessvalue for the sequences. If we access a value bigger than the property vector size //we use the last rule, as we made sure this is an empty one template struct index : public mpl::if_< mpl::less, mpl::size >, mpl::int_, typename mpl::size::prior >::type {}; //this struct tells us if we should execute the generator template struct valid : public mpl::less< mpl::int_, mpl::size > {}; rules_sequnce rules; karma::rule::type()> obj; obj_gen(); }; } //namespace details }//dcm #ifndef USE_EXTERNAL #include "object_generator_imp.hpp" #endif #endif //DCM_OBJECT_GENERATOR_H