VIP.H

[目次 | 型・クラス・構造体 | マクロ]

目次

型・クラス・構造体一覧

マクロ一覧


   1|/**************************************************************************
   2|*  1. <<< 仮想インスタンス (Vip) >>> 
   3|***************************************************************************/
   4|
   5|#ifndef __VIP_H
   6|#define __VIP_H
   7|
   8| 
   9|/*************************************************************************
  10|*  2. <<< 優先ヘッダ >>> 
  11|**************************************************************************/
  12|#ifndef USES_PRIORITY_HEADER
  13|/*[START_OF_PRIORITY_HEADER]*/
  14|
  15|#ifndef  USES_VIP
  16|#define  USES_VIP
  17|
  18|typedef  struct _Vip_Instance  Vip_Instance;
  19|typedef  struct _Vip_Device    Vip_Device;
  20|typedef  struct _Vip_DevPool   Vip_DevPool;
  21|
  22|#endif
  23|
  24|/*[END_OF_PRIORITY_HEADER]*/
  25|#endif
  26|
  27| 
  28|/*************************************************************************
  29|*  3. <<< エラーコード, リターンコード >>> 
  30|**************************************************************************/
  31|
  32|#define  Vip_Err_Some     0
  33|
  34| 
  35|/*--------------------------------------------------------------*/
  36|/*4. <<< Interface Area -------------------------------------- >>> */ 
  37|/*--------------------------------------------------------------*/
  38|
  39|#ifdef __cplusplus
  40|extern "C" {
  41|#endif
  42|
  43| 
  44|/**************************************************************************	
  45|*  5. <<< [Vip_Instance] 仮想インスタンス >>> 
  46|*【補足】
  47|*・inherit_Vip_Instance 変数は、第1メンバ変数にしてください
  48|***************************************************************************/
  49|struct  _Vip_Instance {
  50|  Vip_Device*  selector;  /* device を選択するスイッチ */
  51|  Vip_Device*  device;
  52|
  53|  ERRORS_INITCHK_VAR
  54|};
  55|
  56|void  Vip_Instance_sync( Vip_Instance*, Vip_DevPool* pool );
  57|void  Vip_Instance_sync_sub( Vip_Instance*, Vip_DevPool* pool );
  58|
  59|/* void   Vip_Instance_setDevice( Vip_Instance*, Vip_Device* ); */
  60|/* type*  Vip_Instance_getDevice( Vip_Instance* ); */
  61|/* bool  Vip_Instance_isSync( Vip_Instance* ); */
  62|
  63| 
  64|/**************************************************************************
  65|*  6. <<< [Vip_Device] 対象デバイス >>> 
  66|*【補足】
  67|*・inherit_Vip_Instance 変数は、第1メンバ変数にしてください
  68|***************************************************************************/
  69|struct  _Vip_Device {
  70|  Vip_Instance*  vi;
  71|};
  72|
  73| 
  74|/**************************************************************************
  75|*  7. <<< [Vip_DeviceI] 対象デバイス・インターフェイス >>> 
  76|***************************************************************************/
  77|
  78|void  Vip_DeviceI_init( Vip_Device* );
  79|void  Vip_DeviceI_sync( Vip_Device* );
  80|
  81|/* void   Vip_DeviceI_setInstance( Vip_Device*, Vip_Instance* );*/
  82|/* type*  Vip_DeviceI_getInstance( Vip_Device*, type ); */
  83|/* type*  Vip_DeviceI_getSelector( Vip_Device*, type ); */
  84| 
  85|/**************************************************************************
  86|*  8. <<< [Vip_DevPool] デバイス・プール >>> 
  87|*【補足】
  88|*・(未記入)
  89|***************************************************************************/
  90|struct  _Vip_DevPool {
  91|  Vip_Device*  devices;
  92|  int   nDevice;
  93|  int   size;
  94|
  95|  ERRORS_INITCHK_VAR
  96|};
  97|
  98|/* Vip_DevPool_new_Vip_DevPool</B>( devInf );*/
  99|/*void  Vip_DevPool_init( Vip_DevPool*, Vip_Device* devices, int nDevice,
 100|  int allocType, type );*/
 101|
 102|Vip_Device*  Vip_DevPool_alloc( Vip_DevPool* );
 103|void  Vip_DevPool_free( Vip_DevPool*, Vip_Device* );
 104|void  Vip_DevPool_freeAll( Vip_DevPool* );
 105|
 106|#define  Vip_RotateType   1
 107|#define  Vip_OrderedType  2
 108|
 109|
 110|/* 内部用 */
 111|void  Vip_DevPool_init_imp( Vip_DevPool*, Vip_Device* devices, int nDevice,
 112|  int allocType, int size );
 113|Vip_Device*  Vip_DevPool_allocRotate( Vip_DevPool* );
 114|Vip_Device*  Vip_DevPool_allocOrdered( Vip_DevPool* );
 115|void  Vip_DevPool_freeRotate( Vip_DevPool*, Vip_Device* );
 116|void  Vip_DevPool_freeOrdered( Vip_DevPool*, Vip_Device* );
 117|
 118| 
 119|#ifdef __cplusplus
 120|}
 121|#endif
 122|
 123|/*--------------------------------------------------------------*/
 124|/*9. <<< Mapping Area ---------------------------------------- >>> */ 
 125|/*--------------------------------------------------------------*/
 126|
 127| 
 128|/**************************************************************************
 129|*  10. <<< [Vip_Instance_setDevice] 指定の仮想インスタンスと対応付けする >>> 
 130|*【引数】
 131|*  ・Vip_Instance*  this;   仮想インスタンス
 132|*  ・Vip_Device*  dev;      対象デバイス
 133|*  ・Vip_Device*  sel;      対象デバイスのセレクタ(NULL可)
 134|*【補足】
 135|*・void  Vip_Instance_setDevice( Vip_Instance*, Vip_Device* dev, Vip_Device* sel );
 136|***************************************************************************/
 137|#define  Vip_Instance_setDevice( this, dev, sel ) \
 138|  ( (this)->inherit_Vip_Device.device = (Vip_Device*)(dev), \
 139|    (this)->inherit_Vip_Device.selector = (Vip_Device*)(sel) )
 140| 
 141|/**************************************************************************
 142|*  11. <<< [Vip_Instance_sync] 対象デバイス同期する >>> 
 143|*【引数】
 144|*  ・Vip_Instance*  this;   仮想インスタンス
 145|*  ・Vip_DevPool*  pool;    デバイス・プール
 146|*【補足】
 147|*・void  Vip_Instance_sync( Vip_Instance*, Vip_DevPool* pool );
 148|***************************************************************************/
 149|#define  Vip_Instance_sync( this, pool ) \
 150|  if ( (this)->inherit_Vip_Instance.selector->vi != (Vip_Instance*)(this) ) \
 151|    Vip_Instance_sync_sub( this, pool ) \
 152|  else ;
 153| 
 154|/**************************************************************************
 155|*  12. <<< [Vip_Instance_isSync] 対象デバイス同期しているかどうかを得る >>> 
 156|*【引数】
 157|*  ・Vip_Instance*  this;   仮想インスタンス
 158|*【補足】
 159|*・bool  Vip_Instance_isSync( Vip_Instance* );
 160|***************************************************************************/
 161|#define  Vip_Instance_isSync( this ) \
 162|  ( (this)->inherit_Vip_Instance.device->vi == (Vip_Instance*)(this) )
 163| 
 164|/**************************************************************************
 165|*  13. <<< [Vip_Instance_getDevice] る仮想インスタンスを返す >>> 
 166|*【引数】
 167|*  ・Vip_Device*  this;   対象デバイス
 168|*  ・type;                仮想インスタンスの型名
 169|*  ・type  返り値;        現在対応付けされている仮想インスタンス
 170|*【補足】
 171|*・type  Vip_Instance_getDevice( Vip_Instance*, type );
 172|*・ハードウェアが仮想インスタンス this に対応付けされていないこともあるので
 173|*  注意してください。
 174|***************************************************************************/
 175|#define  Vip_Instance_getDevice( this, type ) \
 176|  ( (type*)(this)->inherit_Vip_Instance.device )
 177| 
 178|/**************************************************************************
 179|*  14. <<< [Vip_DeviceI_setInstance] 指定の仮想インスタンスと対応付けする >>> 
 180|*【引数】
 181|*  ・Vip_DeviceI  this;   対象デバイス
 182|*  ・ins;                 仮想インスタンス
 183|*【補足】
 184|*・void  Vip_DeviceI_setInstance( Vip_DeviceI, Vip_Instance* );
 185|***************************************************************************/
 186|#define  Vip_DeviceI_setInstance( this, ins ) \
 187|  ( ((Vip_Device*)(this).obj)->vi = (Vip_Instance*)(ins) )
 188| 
 189|/**************************************************************************
 190|*  15. <<< [Vip_DeviceI_getInstance] 現在対応付けされている仮想インスタンスを返す >>> 
 191|*【引数】
 192|*  ・Vip_DeviceI  this;   対象デバイス
 193|*  ・type;                仮想インスタンスの型名
 194|*  ・type  返り値;        現在対応付けされている仮想インスタンス
 195|*【補足】
 196|*・type  Vip_DeviceI_getInstance( Vip_DeviceI, type );
 197|***************************************************************************/
 198|#define  Vip_DeviceI_getInstance( this, type ) \
 199|  ( (type*)((Vip_Device*)(this).obj)->vi )
 200|
 201| 
 202|/**************************************************************************
 203|*  16. <<< [Vip_DeviceI_getSelector] 自分を制御するセレクタ・デバイスを返す >>> 
 204|*【引数】
 205|*  ・Vip_DeviceI  this;   対象デバイス
 206|*  ・type;                セレクタの型名
 207|*  ・type  返り値;        セレクタ
 208|*【補足】
 209|*・type  Vip_DeviceI_getSelector( Vip_DeviceI, type );
 210|***************************************************************************/
 211|#define  Vip_DeviceI_getSelector( this, type ) \
 212|  ( (type*)((Vip_Device*)(this).obj)->vi->selector )
 213|
 214| 
 215|/**************************************************************************
 216|*  17. <<< [Vip_DevPool_init] デバイス・プールを初期化する >>> 
 217|*【引数】
 218|*  ・Vip_DevPool*  pool;    デバイス・プール
 219|*  ・Vip_Device*  devices;  デバイスの配列の先頭アドレス
 220|*  ・int   nDevice;         デバイスの配列の要素数
 221|*  ・int   allocType;       ハードウェア利用アルゴリズムのタイプ(→補足)
 222|*【補足】
 223|*・void  Vip_DevPool_init( Vip_DevPool*, Vip_Device* devices, int nDevice,
 224|*    int allocType, type );
 225|*・allocType には、Vip_RotateType Vip_OrderedType を指定します。
 226|*・Vip_RotateType では、ハードウェアをローテーションして利用します。
 227|*  ただし、最近使用した仮想インスタンスを再び使用するときは、
 228|*  そのときに利用したハードウェアを再利用します。
 229|*・Vip_OrderedType では、ハードウェアの順番に意味があるときに、
 230|*  仮想インスタンスのオーダーから利用するハードウェアを決定します。
 231|*  もし、仮想インスタンスの数がハードウェアの数より多くなったときは、
 232|*  1つのハードウェアを、ソフトウェアの合成処理の結果を出力する
 233|*  ものに割り当てます。
 234|***************************************************************************/
 235|#define  Vip_DevPool_init( this, devices, nDevice, allocType, type ) \
 236|  Vip_DevPool_init_imp( this, devices, nDevice, allocType, sizeof(type) )
 237| 
 238|#endif  /* __VIP_H */ 
 239| 
 240|