kernel_id.hpp

説明を見る。
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 
00049 #ifndef TOPPERS_KERNEL_ID_HPP_
00050 #define TOPPERS_KERNEL_ID_HPP_
00051 
00052 #include "toppers/config.hpp"
00053 #include <iosfwd>
00054 #include <string>
00055 #include <map>
00056 #include <vector>
00057 #include <boost/shared_ptr.hpp>
00058 
00059 namespace toppers
00060 {
00061 
00066   class cfg_base
00067   {
00068   public:
00069     explicit cfg_base( const std::string& file );
00073     virtual ~cfg_base() {}
00074     void save() const;
00075     const std::string file() const;
00076   protected:
00077     virtual bool do_save( std::ostream& ostr ) const = 0;
00078     virtual void do_body( std::ostream& ostr ) const = 0;
00079     virtual void do_file_header( std::ostream& ostr ) const;
00080     virtual void do_depend() const;
00081   private:
00082     std::string file_;
00083   };
00084 
00090   class kernel_id : public cfg_base
00091   {
00092   public:
00097     class id_number
00098     {
00099     public:
00100       id_number();
00104       virtual ~id_number() {}
00105 
00106       const std::string& name() const;
00107       long value() const;
00108       void set( const std::string& name, long id );
00109 
00110       static bool less_than( const boost::shared_ptr<id_number> lhs, const boost::shared_ptr<id_number> rhs );
00111     private:
00112       std::string name_;
00113       long id_;
00114     };
00115 
00116     typedef std::vector<boost::shared_ptr<id_number> > id_array;
00117 
00118     explicit kernel_id( const std::string& file = std::string( "kernel_id.h" ) );
00119 
00120     const id_array* get_id_array( const std::string& key ) const;
00121   protected:
00122     void insert_id( const std::string& key, const boost::shared_ptr<id_number>& id );
00123     void clear_id_array( const std::string& key );
00124 
00125     virtual bool do_save( std::ostream& ostr ) const;
00126 
00127     static const std::string include_guard_macro( const std::string& file );
00128   private:
00129     std::map<std::string, id_array> id_map_;
00130   };
00131 
00132 }
00133 
00134 #endif  // ! TOPPERS_KERNEL_ID_HPP_

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