クラス テンプレート toppers::itron::specified_object< Policy >

特定のカーネルオブジェクトを管理するクラス [詳細]

#include "toppers/itron/kernel_object.hpp"

toppers::itron::specified_object< Policy >に対する継承グラフ

Inheritance graph
[凡例]
toppers::itron::specified_object< Policy >のコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public 型

typedef specified_object<
Policy > 
self_t

Static Public メソッド

static const boost::shared_ptr<
kernel_object
build (const static_api &api, std::vector< boost::shared_ptr< kernel_object > > &container)
 kernel_object の構築
static void generate_kernel_cfg (const kernel_cfg &cfg, std::ostream &ostr)
 kernel_cfg.c の生成
static void generate_kernel_id (const kernel_id &id_cfg, std::ostream &ostr)
 kernel_id.h の生成

Protected メソッド

bool analyze_primary (const static_api &api)
 主な静的APIの解析処理
bool analyze_secondary (const static_api &api)
 副次的な静的APIの解析
virtual bool do_analyze (const static_api &api)
virtual const char * do_get_object_type () const
 カーベルオブジェクトの種類の参照
virtual bool do_has_id () const
virtual bool do_check_id_range (long id) const

説明

template<class Policy>
class toppers::itron::specified_object< Policy >

特定のカーネルオブジェクトを管理するクラス

kernel_object クラスを個々のオブジェクトに対応させるための処理をこのクラスで 定義します。
例えば、セマフォに関する定義は semaphore_policy クラスを specified_object の テンプレート引数 Policy に指定することで行います。

テンプレート引数 Policy には次のメンバを持つ型を指定してください。

  // コンストラクタで渡された初期化文字列にしたがって、pinibが指す要素を
  // 型typeに変換するファンクタ
  class generator
  {
  public:
    explicit generator( const std::string& format );
    type operator()(  boost::shared_ptr<kernel_cfg::initial_block> pinib );
  };

  // kernel_cfg.cへの出力処理をオーバーライドする。
  static bool generate_kernel_cfg( const kernel_cfg& cfg, std::ostream& ostr );

  // kernel_id.hへの出力処理をオーバーライドする。
  static bool generate_kernel_id( const kernel_id& id_cfg, std::ostream& ostr );

  // kernel_cfg.cへの書き込み可能要素の出力処理を記述する。
  static void generate_regions( const kernel_cfg& cfg, std::ostream& ostr );

  // kernel_cfg.cへの初期化ブロックの出力処理を記述する。
  static void generate_inits( const kernel_cfg& cfg, std::ostream& ostr );

  // kernel_cfg.cへの領域要素の出力処理を記述する。
  static void generate_variables( const kernel_cfg& cfg, std::ostream& ostr );

  // kernel_cfg.cへの書き込み不可要素の出力処理を記述する。
  static void generate_constants( const kernel_cfg& cfg, std::ostream& ostr );

  // kernel_cfg.cへのアサーションコードの出力処理を記述する。
  static void generate_assertions( const kernel_cfg& cfg, std::ostream& ostr );

  // オブジェクトがない場合にkenrel_cfg.cへの__EMPTY_LABEL出力処理を記述する。
  static void generate_extra_empty_labels( std::ostream& ostr );

  // 静的APIの解析処理をオーバーライドする。
  // オーバーライドした場合はtrueを返す
  bool analyze( kernel_object& obj, const static_api& api );

  // 静的APIの解析結果を判定する。
  bool verify( const static_api& api, kernel_object& obj );

  // ID番号の範囲チェックを行う。
  bool check_id_range( long id );

  static const bool use_id_;              // IDを使う場合はtrue、番号を使う場合はfalse
  static const char name_[];              // オブジェクト名
  static const char symbol_[];            // 三文字名
  static const char* const apis_[];       // 主な静的API名の配列
  static const char* const params_[];     // 主な静的API名のパラメータ並びの配列
  static const char* const apis_[];       // 副次的な静的API名の配列
  static const char* const params_[];     // 副次的な静的API名のパラメータ並びの配列
  static const char prefix_[];            // 初期化ブロック等の型名に使うプレフィックス
  static const char region_format_[];     // 領域定義の書式化文字列
  static const char init_format_[];       // 初期化ブロックの初期化文字列

参照:
kernel_object_policy_base

specified_object.hpp139 行で定義されています。


関数

template<class Policy>
bool toppers::itron::specified_object< Policy >::analyze_primary const static_api api  )  [inline, protected]
 

主な静的APIの解析処理

引数:
api 解析する静的API情報
戻り値:
解析に成功した場合は true を返す
この関数で解析する静的APIの情報は、 Policy::apis_ および Policy::params_ の最初の要素を使用する。

specified_object.hpp223 行で定義されています。

参照先 toppers::itron::static_api::begin().

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       }

関数の呼び出しグラフ:

template<class Policy>
bool toppers::itron::specified_object< Policy >::analyze_secondary const static_api api  )  [inline, protected]
 

副次的な静的APIの解析

引数:
api 解析する静的API情報
戻り値:
解析に成功した場合は true を返す
この関数は、例えばタスクのように、そのカーネルオブジェクトに関連する 静的APIが複数存在する場合に使用する。
具体的には、タスクであれば CRE_TSK の解析は analyze_primary 関数で行い、 DEF_TSK の解析は analyze_secondary で行うことになる。

この関数で解析する静的APIの情報は、 Policy::apis_ および Policy::params_ の2番目の要素(配列添え字は 1 〜)以降を使用する。

specified_object.hpp255 行で定義されています。

参照先 toppers::itron::static_api::begin().

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       }

関数の呼び出しグラフ:

template<class Policy>
static const boost::shared_ptr<kernel_object> toppers::itron::specified_object< Policy >::build const static_api api,
std::vector< boost::shared_ptr< kernel_object > > &  container
[inline, static]
 

kernel_object の構築

引数:
api 静的API情報
container 構築した kernel_object 格納用コンテナ
戻り値:
構築された kernel_object へのスマートポインタ
覚え書き:
格納用コンテナを引数として渡すのは DEF_TEX のように既存の kernel_object を更新する静的APIの対応するため

specified_object.hpp152 行で定義されています。

参照先 toppers::itron::static_api::begin().

参照元 toppers::itron::fdmp::cfg_contents::do_parse().

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       }

関数の呼び出しグラフ:

template<class Policy>
virtual bool toppers::itron::specified_object< Policy >::do_analyze const static_api api  )  [inline, protected, virtual]
 

実際の静的APIの解析は以下の手順で行います。

  1. Policy::analyze
  2. analyze_primary
  3. analyze_secondary

上記の手順のうち、最初に成功した( true が返ってきた)ものを解析結果と して採用します。 解析に成功した場合 Policy::verify によって整合性を判定します。

toppers::itron::kernel_objectを実装しています。

specified_object.hpp293 行で定義されています。

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       }

template<class Policy>
virtual const char* toppers::itron::specified_object< Policy >::do_get_object_type  )  const [inline, protected, virtual]
 

カーベルオブジェクトの種類の参照

戻り値:
種類を表す文字列を返す

toppers::itron::kernel_objectを実装しています。

specified_object.hpp301 行で定義されています。

00302       {
00303         return Policy::name_;
00304       }

template<class Policy>
virtual bool toppers::itron::specified_object< Policy >::do_has_id  )  const [inline, protected, virtual]
 

戻り値:
ID番号を使用する場合には true を返す
覚え書き:
"do has"というのは英語的には間違いですが、検索の便宜のために 敢えてこのように命名しています。

toppers::itron::kernel_objectを実装しています。

specified_object.hpp305 行で定義されています。

00306       {
00307         return !!Policy::use_id_;
00308       }

template<class Policy>
static void toppers::itron::specified_object< Policy >::generate_kernel_cfg const kernel_cfg cfg,
std::ostream &  ostr
[inline, static]
 

kernel_cfg.c の生成

引数:
cfg kernel_cfg.c 生成情報
ostr 出力ストリーム

specified_object.hpp197 行で定義されています。

00198       {
00199         Policy::generate_kernel_cfg( cfg, ostr );
00200       }

template<class Policy>
static void toppers::itron::specified_object< Policy >::generate_kernel_id const kernel_id id_cfg,
std::ostream &  ostr
[inline, static]
 

kernel_id.h の生成

引数:
id_cfg kernel_id.h 生成情報
ostr 出力ストリーム

specified_object.hpp207 行で定義されています。

00208       {
00209         if ( Policy::use_id_ )
00210         {
00211           Policy::generate_kernel_id( id_cfg, ostr );
00212         }
00213       }


このクラスの説明は次のファイルから生成されました:
Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:32:06 2006 に Doxygen によって生成されました。