PublisherFactory.py

説明を見る。
00001 #!/usr/bin/env python
00002 # -*- coding: euc-jp -*-
00003 
00004 ##
00005 # @file  PublisherFactory.py
00006 # @brief PublisherFactory class
00007 # @date  $Date: 2007/09/05$
00008 # @author Noriaki Ando <n-ando@aist.go.jp>
00009 #
00010 # Copyright (C) 2006-2008
00011 #     Noriaki Ando
00012 #     Task-intelligence Research Group,
00013 #     Intelligent Systems Research Institute,
00014 #     National Institute of
00015 #         Advanced Industrial Science and Technology (AIST), Japan
00016 #     All rights reserved.
00017 
00018 from omniORB import any
00019 
00020 import OpenRTM
00021 
00022 
00023 ##
00024 # @if jp
00025 # @class PublisherFactory
00026 # @brief PublisherFactory クラス
00027 #
00028 # 各種Publisherオブジェクトの生成・破棄を管理するファクトリクラス
00029 # ※テンポラリな実装
00030 #   将来的には任意のPublisherを生成できるようにする。
00031 #
00032 # @else
00033 # @class PublisherFactory
00034 # @brief PublisherFactory class
00035 # @endif
00036 class PublisherFactory:
00037   """
00038   """
00039 
00040 
00041   ##
00042   # @if jp
00043   # @brief Publisherの生成
00044   #
00045   # Publisherオブジェクトを生成する。
00046   # 指定された引数に応じた適切なPublisher実装のオブジェクトが生成される。
00047   # 生成するPublisherの種別を、指定されたPropertyオブジェクトの
00048   # dataport.subscription_typeメンバに設定しておく必要がある。
00049   # また、種別によっては、Publisherの駆動を制御する情報をさらに設定する必要が
00050   # ある。
00051   # これらの具体的な内容は、それぞれのPublisher実装を参照のこと。
00052   #
00053   # @param self
00054   # @param consumer Publisherによってデータ送出を駆動されるコンシューマ
00055   # @param property 生成すべきPublisherを特定するための情報や、Publisherの
00056   #                 駆動を制御するための情報が設定されているPropertyオブジェ
00057   #                 クト
00058   #
00059   # @return 生成したPublisherオブジェクト。生成に失敗した場合はNullを返す。
00060   #
00061   # @else
00062   # @brief Create Publisher
00063   # @endif
00064   def create(self, consumer, property):
00065     pub_type = property.getProperty("dataport.subscription_type", "New")
00066 
00067     if type(pub_type) != str :
00068       pub_type = str(any.from_any(pub_type,keep_structs=True))
00069     if pub_type == "New":
00070       return OpenRTM.PublisherNew(consumer, property)
00071     elif pub_type == "Periodic":
00072       return OpenRTM.PublisherPeriodic(consumer, property)
00073     elif pub_type == "Flush":
00074       return OpenRTM.PublisherFlush(consumer, property)
00075 
00076     return None
00077 
00078 
00079   ##
00080   # @if jp
00081   # @brief Publisherの破棄
00082   #
00083   # 設定されたPublisherオブジェクトを破棄する。
00084   #
00085   # @param self
00086   # @param publisher 破棄対象Publisherオブジェクト
00087   #
00088   # @else
00089   # @brief Destroy Publisher
00090   # @endif
00091   def destroy(self, publisher):
00092     if publisher:
00093       publisher.release()
00094     del publisher

OpenRTMに対してMon Mar 17 15:11:06 2008に生成されました。  doxygen 1.5.4