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
00227 class OutPortBase
00228 : public PortBase, public DataPortStatus
00229 {
00230 public:
00231 DATAPORTSTATUS_ENUM
00232
00233 typedef std::vector<OutPortConnector*> ConnectorList;
00234
00252 OutPortBase(const char* name, const char* data_type);
00253
00270 virtual ~OutPortBase(void);
00271
00286 void init(coil::Properties& prop);
00287
00309 virtual bool write() = 0;
00310
00311
00330
00331
00350 coil::Properties& properties();
00351
00370 const std::vector<OutPortConnector*>& connectors();
00371
00390 ConnectorInfoList getConnectorProfiles();
00391
00410 coil::vstring getConnectorIds();
00411
00430 coil::vstring getConnectorNames();
00431
00452 OutPortConnector* getConnectorById(const char* id);
00453
00474 OutPortConnector* getConnectorByName(const char* name);
00475
00498 bool getConnectorProfileById(const char* id,
00499 ConnectorInfo& prof);
00500
00523 bool getConnectorProfileByName(const char* name,
00524 ConnectorInfo& prof);
00525
00526
00543 virtual void activateInterfaces();
00544
00561 virtual void deactivateInterfaces();
00562
00563
00639 void addConnectorDataListener(ConnectorDataListenerType listener_type,
00640 ConnectorDataListener* listener,
00641 bool autoclean = true);
00642
00643
00663 void removeConnectorDataListener(ConnectorDataListenerType listener_type,
00664 ConnectorDataListener* listener);
00665
00666
00719 void addConnectorListener(ConnectorListenerType callback_type,
00720 ConnectorListener* listener,
00721 bool autoclean = true);
00722
00742 void removeConnectorListener(ConnectorListenerType callback_type,
00743 ConnectorListener* listener);
00744
00762 bool isLittleEndian();
00763
00789 virtual ReturnCode_t
00790 connect(ConnectorProfile& connector_profile)
00791 throw (CORBA::SystemException);
00792
00793
00794 protected:
00809 void configure();
00810
00857 virtual ReturnCode_t
00858 publishInterfaces(ConnectorProfile& connector_profile);
00859
00898 virtual ReturnCode_t
00899 subscribeInterfaces(const ConnectorProfile& connector_profile);
00900
00932 virtual void
00933 unsubscribeInterfaces(const ConnectorProfile& connector_profile);
00934
00942 void initProviders();
00943
00951 void initConsumers();
00952
00953 bool checkEndian(const coil::Properties& prop, bool& littleEndian);
00954
00962 OutPortProvider* createProvider(ConnectorProfile& cprof,
00963 coil::Properties& prop);
00971 InPortConsumer* createConsumer(const ConnectorProfile& cprof,
00972 coil::Properties& prop);
00973
00981 OutPortConnector* createConnector(const ConnectorProfile& cprof,
00982 coil::Properties& prop,
00983 InPortConsumer* consumer);
00991 OutPortConnector* createConnector(const ConnectorProfile& cprof,
00992 coil::Properties& prop,
00993 OutPortProvider* provider);
00994
00995 protected:
01003 coil::Properties m_properties;
01011 std::vector<OutPortConnector*> m_connectors;
01019 coil::vstring m_providerTypes;
01027 coil::vstring m_consumerTypes;
01035 bool m_littleEndian;
01043 ConnectorListeners m_listeners;
01044
01052 struct provider_cleanup;
01053
01061 struct connector_cleanup;
01062 };
01063 };
01064 #endif // RTC_RTCOUTPORTBASE_H