kernel_cfg.cpp

00001 /*
00002  *  TOPPERS/FDMP Kernel
00003  *      Toyohashi Open Platform for Embedded Real-Time Systems/
00004  *      Function Distributed Multiprocessor Kernel
00005  *
00006  *  Copyright (C) 2004 by Witz Corporation, JAPAN  
00007  *  Copyright (C) 2005 by Takagi Nobuhisa
00008  * 
00009  *  上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 
00010  *  によって公表されている GNU General Public License の Version 2 に記
00011  *  述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
00012  *  を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
00013  *  利用と呼ぶ)することを無償で許諾する.
00014  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
00015  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
00016  *      スコード中に含まれていること.
00017  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
00018  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
00019  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
00020  *      の無保証規定を掲載すること.
00021  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
00022  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
00023  *      と.
00024  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
00025  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
00026  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
00027  *        報告すること.
00028  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
00029  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
00030  * 
00031  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
00032  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
00033  *  含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
00034  *  接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
00035  * 
00036  */
00037 
00038 /*
00039  *  toppers/kernel_cfg.cpp
00040  */
00041 #include "toppers/kernel_cfg.hpp"
00042 #include <cassert>
00043 #include <algorithm>
00044 
00045 namespace toppers
00046 {
00047 
00051   kernel_cfg::initial_block::initial_block() : id_( -1L )
00052   {
00053   }
00054 
00059   long kernel_cfg::initial_block::id() const
00060   {
00061     return id_;
00062   }
00063 
00068   void kernel_cfg::initial_block::id( long value )
00069   {
00070     id_ = value;
00071   }
00072 
00078   const std::string& kernel_cfg::initial_block::get( const std::string& key ) const
00079   {
00080     std::map<std::string, std::string>::const_iterator iter( field_map_.find( key ) );
00081     if ( iter == field_map_.end() )
00082     {
00083       static const std::string dummy;
00084       return dummy;
00085     }
00086     return iter->second;
00087   }
00088 
00094   void kernel_cfg::initial_block::set( const std::string& key, const std::string& field )
00095   {
00096     std::string t( field ); // 例外安全対策
00097     field_map_[key].swap( t );
00098   }
00099 
00110   bool kernel_cfg::initial_block::less_than( const boost::shared_ptr<initial_block> lhs, const boost::shared_ptr<initial_block> rhs )
00111   {
00112     return lhs->id() < rhs->id();
00113   }
00114 
00121   const std::string& kernel_cfg::initial_block::get_field( const boost::shared_ptr<initial_block>& inib_ptr, const std::string& key )
00122   {
00123     return inib_ptr->get( key );
00124   }
00125 
00131   kernel_cfg::kernel_cfg( const std::string& file, const std::string& id_file )
00132     : cfg_base( file ), id_file_( id_file )
00133   {
00134   }
00135 
00140   const std::string & kernel_cfg::id_file() const
00141   {
00142     return id_file_;
00143   }
00144 
00152   bool kernel_cfg::do_save( std::ostream& ostr ) const
00153   {
00154     do_file_header( ostr );
00155     do_body( ostr );
00156     return true;
00157   }
00158 
00164   void kernel_cfg::insert_inib( const std::string& key, const boost::shared_ptr<initial_block>& inib )
00165   {
00166     if ( inib )
00167     {
00168       inib_map_[key].push_back( inib );
00169     }
00170   }
00171 
00177   const kernel_cfg::inib_array* kernel_cfg::get_inib_array( const std::string& key ) const
00178   {
00179     inib_array_map::const_iterator iter( inib_map_.find( key ) );
00180     if ( iter == inib_map_.end() )
00181     {
00182       static inib_array dummy;
00183       return &dummy;
00184     }
00185     return &iter->second;
00186   }
00187 
00192   void kernel_cfg::clear_inib_array( const std::string& key )
00193   {
00194     inib_map_[key].clear();
00195   }
00196 
00197 }

Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:31:57 2006 に Doxygen によって生成されました。