|
|
specified_object.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 00048 #ifndef TOPPERS_ITRON_SPECIFIED_OBJECT_HPP_ 00049 #define TOPPERS_ITRON_SPECIFIED_OBJECT_HPP_ 00050 00051 #include "toppers/itron/kernel_object.hpp" 00052 #include "toppers/itron/static_api.hpp" 00053 #include "toppers/itron/cfg_factory.hpp" 00054 #include "toppers/misc.hpp" 00055 #include <cstring> 00056 #include <boost/format.hpp> 00057 00058 namespace toppers 00059 { 00060 00061 class s_record; 00062 class nm_symbol; 00063 00064 namespace itron 00065 { 00066 00067 class kernel_chk; 00068 00138 template <class Policy> 00139 class specified_object : public kernel_object 00140 { 00141 public: 00142 typedef specified_object<Policy> self_t; 00143 00152 static const boost::shared_ptr<kernel_object> build( const static_api& api, std::vector<boost::shared_ptr<kernel_object> >& container ) 00153 { 00154 static_api::const_iterator iter( api.begin() ); 00155 boost::shared_ptr<kernel_object> ptr; 00156 00157 for ( int i = 0; Policy::apis_[i] != 0; i++ ) 00158 { 00159 if ( *iter == Policy::apis_[0] ) 00160 { 00161 ptr.reset( new self_t ); 00162 if ( ptr->analyze( api ) ) 00163 { 00164 container.push_back( ptr ); 00165 } 00166 } 00167 } 00168 if ( !ptr ) 00169 { 00170 // 副次的なAPIの処理 00171 for ( int i = 0; Policy::apis2_[i] != 0; i++ ) 00172 { 00173 if ( *iter == Policy::apis2_[i] ) 00174 { 00175 typedef std::vector<boost::shared_ptr<kernel_object> >::const_iterator const_iterator; 00176 for ( const_iterator i( container.begin() ), t( container.end() ); i != t; ++i ) 00177 { 00178 if ( std::strcmp( ( *i )->get_object_type(), Policy::name_ ) == 0 ) 00179 { 00180 if ( ( *i )->analyze( api ) ) 00181 { 00182 return *i; 00183 } 00184 } 00185 } 00186 } 00187 } 00188 } 00189 return ptr; 00190 } 00191 00197 static void generate_kernel_cfg( const kernel_cfg& cfg, std::ostream& ostr ) 00198 { 00199 Policy::generate_kernel_cfg( cfg, ostr ); 00200 } 00201 00207 static void generate_kernel_id( const kernel_id& id_cfg, std::ostream& ostr ) 00208 { 00209 if ( Policy::use_id_ ) 00210 { 00211 Policy::generate_kernel_id( id_cfg, ostr ); 00212 } 00213 } 00214 protected: 00223 bool analyze_primary( const static_api& api ) 00224 { 00225 static_api::const_iterator iter( api.begin() ); 00226 for ( int i = 0; Policy::apis_[i] != 0; i++ ) 00227 { 00228 if ( *iter == Policy::apis_[i] ) 00229 { 00230 self_t t; 00231 if ( !t.analyze_parameters( api, Policy::params_[i] ) ) 00232 { 00233 break; 00234 } 00235 swap( t ); 00236 return true; 00237 } 00238 } 00239 return false; 00240 } 00241 00255 bool analyze_secondary( const static_api& api ) 00256 { 00257 static_api::const_iterator iter( api.begin() ); 00258 for ( int i = 0; Policy::apis2_[i] != 0; i++ ) 00259 { 00260 if ( *iter == Policy::apis2_[i] ) 00261 { 00262 if ( id() < 0 && name().empty() ) 00263 { 00264 break; 00265 } 00266 self_t t( *this ); 00267 if ( !t.analyze_parameters( api, Policy::params2_[i] ) ) 00268 { 00269 break; 00270 } 00271 if ( id() != t.id() || name() != t.name() ) 00272 { 00273 break; 00274 } 00275 swap( t ); 00276 return true; 00277 } 00278 } 00279 return false; 00280 } 00281 00293 virtual bool do_analyze( const static_api& api ) 00294 { 00295 bool result = Policy::analyze( api, *this ); 00296 result = result || analyze_primary( api ); 00297 result = result || analyze_secondary( api ); 00298 result = result && Policy::verify( api, *this ); 00299 return result; 00300 } 00301 virtual const char* do_get_object_type() const 00302 { 00303 return Policy::name_; 00304 } 00305 virtual bool do_has_id() const 00306 { 00307 return !!Policy::use_id_; 00308 } 00309 virtual bool do_check_id_range( long id ) const 00310 { 00311 if ( Policy::use_id_ ) 00312 { 00313 return Policy::check_id_range( id ); 00314 } 00315 return true; 00316 } 00317 }; 00318 00326 class kernel_object_policy_base 00327 { 00328 public: 00333 class generator 00334 { 00335 public: 00336 explicit generator( const std::string& format ) : format_( format ) {} 00337 const std::string operator()( boost::shared_ptr<kernel_cfg::initial_block> pinib ); 00338 private: 00339 std::string format_; 00340 }; 00341 00352 static void generate_regions( const kernel_cfg& cfg, std::ostream& ostr ) 00353 { 00354 } 00355 00366 static void generate_inits( const kernel_cfg& cfg, std::ostream& ostr ) 00367 { 00368 } 00369 00380 static void generate_variables( const kernel_cfg& cfg, std::ostream& ostr ) 00381 { 00382 } 00383 00394 static void generate_constants( const kernel_cfg& cfg, std::ostream& ostr ) 00395 { 00396 } 00397 00408 static void generate_assertions( const kernel_cfg& cfg, std::ostream& ostr ) 00409 { 00410 } 00411 00421 static void generate_extra_empty_labels( std::ostream& ostr ) 00422 { 00423 } 00424 00436 static bool analyze( const static_api& api, kernel_object& obj ) 00437 { 00438 return false; 00439 } 00440 00452 static bool verify( const static_api& api, kernel_object& obj ) 00453 { 00454 return true; 00455 } 00456 00463 static bool check_id_range( long id ) 00464 { 00465 return id > 0; 00466 } 00467 00474 static bool check( const kernel_chk& chk, const s_record& srec, const nm_symbol& syms ) 00475 { 00476 return true; 00477 } 00478 00486 enum { use_id_ = true }; 00487 static const char name_[]; 00488 static const char symbol_[]; 00489 static const char* const apis_[]; 00490 static const char* const params_[]; 00491 static const char* const apis2_[]; 00492 static const char* const params2_[]; 00493 static const char* const prefix_; 00494 static const char region_format_[]; 00495 static const char init_format_[]; 00496 }; 00497 00498 } 00499 } 00500 00501 #endif // ! TOPPERS_ITRON_SPECIFIED_OBJECT_HPP_ Copyright © 2006 by TAKAGI Nobuhisa. このページは Wed Apr 12 16:31:57 2006 に Doxygen によって生成されました。 |