00001
00020 #ifndef RTC_OUTPORTBASE_H
00021 #define RTC_OUTPORTBASE_H
00022
00023 #include <vector>
00024 #include <string>
00025
00026 #include <coil/Properties.h>
00027 #include <coil/stringutil.h>
00028
00029 #include <rtm/PortBase.h>
00030 #include <rtm/InPortConsumer.h>
00031 #include <rtm/OutPortProvider.h>
00032 #include <rtm/ConnectorBase.h>
00033 #include <rtm/CdrBufferBase.h>
00034 #include <rtm/SystemLogger.h>
00035 #include <rtm/ConnectorListener.h>
00036
00037 namespace RTC
00038 {
00039 class PublisherBase;
00040 class ConnectorBase;
00041 class OutPortConnector;
00042
00230 class OutPortBase
00231 : public PortBase, public DataPortStatus
00232 {
00233 public:
00234 DATAPORTSTATUS_ENUM
00235
00236 typedef std::vector<OutPortConnector*> ConnectorList;
00237
00257 OutPortBase(const char* name, const char* data_type);
00258
00275 virtual ~OutPortBase(void);
00276
00293 void init(coil::Properties& prop);
00294
00316 virtual bool write() = 0;
00317
00336 coil::Properties& properties();
00337
00356 const std::vector<OutPortConnector*>& connectors();
00357
00376 ConnectorInfoList getConnectorProfiles();
00377
00396 coil::vstring getConnectorIds();
00397
00416 coil::vstring getConnectorNames();
00417
00438 OutPortConnector* getConnectorById(const char* id);
00439
00460 OutPortConnector* getConnectorByName(const char* name);
00461
00484 bool getConnectorProfileById(const char* id,
00485 ConnectorInfo& prof);
00486
00509 bool getConnectorProfileByName(const char* name,
00510 ConnectorInfo& prof);
00511
00512
00529 virtual void activateInterfaces();
00530
00547 virtual void deactivateInterfaces();
00548
00549
00625 void addConnectorDataListener(ConnectorDataListenerType listener_type,
00626 ConnectorDataListener* listener,
00627 bool autoclean = true);
00628
00629
00649 void removeConnectorDataListener(ConnectorDataListenerType listener_type,
00650 ConnectorDataListener* listener);
00651
00652
00705 void addConnectorListener(ConnectorListenerType callback_type,
00706 ConnectorListener* listener,
00707 bool autoclean = true);
00708
00728 void removeConnectorListener(ConnectorListenerType callback_type,
00729 ConnectorListener* listener);
00730
00748 bool isLittleEndian();
00749
00775 virtual ReturnCode_t
00776 connect(ConnectorProfile& connector_profile)
00777 throw (CORBA::SystemException);
00778
00779
00780 protected:
00795 void configure();
00796
00843 virtual ReturnCode_t
00844 publishInterfaces(ConnectorProfile& connector_profile);
00845
00884 virtual ReturnCode_t
00885 subscribeInterfaces(const ConnectorProfile& connector_profile);
00886
00918 virtual void
00919 unsubscribeInterfaces(const ConnectorProfile& connector_profile);
00920
00928 void initProviders();
00929
00937 void initConsumers();
00938
00974 bool checkEndian(const coil::Properties& prop, bool& littleEndian);
00975
00983 OutPortProvider* createProvider(ConnectorProfile& cprof,
00984 coil::Properties& prop);
00992 InPortConsumer* createConsumer(const ConnectorProfile& cprof,
00993 coil::Properties& prop);
00994
01002 OutPortConnector* createConnector(const ConnectorProfile& cprof,
01003 coil::Properties& prop,
01004 InPortConsumer* consumer);
01012 OutPortConnector* createConnector(const ConnectorProfile& cprof,
01013 coil::Properties& prop,
01014 OutPortProvider* provider);
01015
01016 protected:
01024 coil::Properties m_properties;
01032 std::vector<OutPortConnector*> m_connectors;
01040 coil::vstring m_providerTypes;
01048 coil::vstring m_consumerTypes;
01056 bool m_littleEndian;
01064 ConnectorListeners m_listeners;
01065
01073 struct provider_cleanup;
01074
01082 struct connector_cleanup;
01083 };
01084 };
01085 #endif // RTC_RTCOUTPORTBASE_H