|
|
specified_factory.hpp説明を見る。00001 /* 00002 * TOPPERS/FDMP Kernel 00003 * Toyohashi Open Platform for Embedded Real-Time Systems/ 00004 * Function Distributed Multiprocessor Kernel 00005 * 00006 * Copyright (C) 2005 by Takagi Nobuhisa 00007 * 00008 * 上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 00009 * によって公表されている GNU General Public License の Version 2 に記 00010 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア 00011 * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下, 00012 * 利用と呼ぶ)することを無償で許諾する. 00013 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 00014 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 00015 * スコード中に含まれていること. 00016 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 00017 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 00018 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 00019 * の無保証規定を掲載すること. 00020 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 00021 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 00022 * と. 00023 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 00024 * 作権表示,この利用条件および下記の無保証規定を掲載すること. 00025 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 00026 * 報告すること. 00027 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 00028 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 00029 * 00030 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 00031 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も 00032 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直 00033 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない. 00034 * 00035 */ 00036 00046 #ifndef TOPPERS_ITRON_SPECIFIED_FACTORY_HPP_ 00047 #define TOPPERS_ITRON_SPECIFIED_FACTORY_HPP_ 00048 00049 #include "toppers/itron/cfg_factory.hpp" 00050 #include <boost/mpl/for_each.hpp> 00051 00052 namespace toppers 00053 { 00054 namespace itron 00055 { 00056 00057 template <class Policy> class specified_object; 00058 00068 #define TOPPERS_DEFINE_CFG_FACTORY_PRED( name, result, func ) \ 00069 struct name { \ 00070 typedef result result_type; \ 00071 name() : result_( new std::vector<result_type> ) {} \ 00072 template <typename T> void operator()( const T& ) const { \ 00073 result_->push_back( &specified_object<T>::func ); \ 00074 } \ 00075 boost::shared_ptr<std::vector<result_type> > result_; \ 00076 } 00077 00078 00105 template <class Policy> 00106 class specified_factory : public cfg_factory 00107 { 00108 public: 00114 typedef typename Policy::sequence sequence; 00115 00122 specified_factory( const cmdline::option_array& options, const std::string& version, long prid ) 00123 : cfg_factory( options, version, prid ) 00124 { 00125 } 00126 00136 static const boost::shared_ptr<cfg_factory> build( const cmdline::option_array& options, const std::string& version ) 00137 { 00138 boost::shared_ptr<cfg_factory> ptr; 00139 if ( Policy::match_version( version ) ) 00140 { 00141 ptr.reset( new specified_factory<Policy>( options, version, Policy::prid_ ) ); 00142 } 00143 return ptr; 00144 } 00145 protected: 00158 template <class Pred> 00159 static const boost::shared_ptr<std::vector<typename Pred::result_type> > get_funcions( Pred pred ) 00160 { 00161 boost::mpl::for_each< sequence >( pred ); 00162 return pred.result_; 00163 } 00164 00165 virtual const boost::shared_ptr<std::vector<kernel_cfg_generator_type> > do_create_kernel_cfg_generators() const 00166 { 00167 pred_kernel_cfg pred; 00168 return get_funcions( pred ); 00169 } 00170 virtual const boost::shared_ptr<std::vector<kernel_id_generator_type> > do_create_kernel_id_generators() const 00171 { 00172 pred_kernel_id pred; 00173 return get_funcions( pred ); 00174 } 00175 virtual const boost::shared_ptr<std::vector<kernel_object::builder_type> > do_get_kernel_object_builders() const 00176 { 00177 pred_kernel_object pred; 00178 return get_funcions( pred ); 00179 } 00180 virtual const boost::shared_ptr<std::vector<std::string> > do_get_kernel_object_names() const 00181 { 00182 pred_kernel_object_name pred; 00183 boost::mpl::for_each< sequence >( pred ); 00184 return pred.result_; 00185 } 00186 virtual extra_initializer_type do_get_extra_initializer() const 00187 { 00188 return &Policy::extra_init; 00189 } 00190 virtual const boost::shared_ptr<kernel_chk> do_create_kernel_chk() const 00191 { 00192 return boost::shared_ptr<kernel_chk>( new typename Policy::kernel_chk( "kernel_chk.c" ) ); 00193 } 00194 private: 00195 TOPPERS_DEFINE_CFG_FACTORY_PRED( pred_kernel_cfg, kernel_cfg_generator_type, generate_kernel_cfg ); 00196 TOPPERS_DEFINE_CFG_FACTORY_PRED( pred_kernel_id, kernel_id_generator_type, generate_kernel_id ); 00197 TOPPERS_DEFINE_CFG_FACTORY_PRED( pred_kernel_object, kernel_object::builder_type, build ); 00198 00199 struct pred_kernel_object_name 00200 { 00201 typedef std::string result_type; 00202 pred_kernel_object_name() : result_( new std::vector<result_type> ) {} 00203 template <typename T> void operator()( const T& ) const 00204 { 00205 result_->push_back( T::name_ ); 00206 } 00207 boost::shared_ptr<std::vector<result_type> > result_; 00208 }; 00209 }; 00210 00211 } 00212 } 00213 00214 #endif // ! TOPPERS_ITRON_SPECIFIED_FACTORY_HPP_ Copyright © 2006 by TAKAGI Nobuhisa. このページは Wed Apr 12 16:31:57 2006 に Doxygen によって生成されました。 |