00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef INTERFACE_CONNECT_RT_COMPONENT_CLASS
00011 #define INTERFACE_CONNECT_RT_COMPONENT_CLASS
00012
00013 #include "RTCompControl.h"
00014
00016
00017
00018
00019 struct RTCompSet
00020 {
00021 RTC::CorbaConsumer<RTC::RTObject> con;
00022 int numOfPort;
00023 RTC::PortList_var pList;
00024
00026 RTCompSet():con(),numOfPort(-1),pList(){};
00028 RTCompSet(const RTCompSet& src):con(src.con),numOfPort(src.numOfPort),pList(src.pList){};
00030 ~RTCompSet(){};
00032 RTCompSet& operator=(const RTCompSet& right)
00033 {
00034 con = right.con;
00035 numOfPort = right.numOfPort;
00036 pList = right.pList;
00037 return *this;
00038 };
00039 };
00040
00042
00052 class RTCompConnect : public ORBvarManager
00053 {
00054 public:
00056 RTCompConnect(
00057 std::string CorbaServeName
00058 ,long CorbaPort=-1
00059 );
00060
00062 RTCompConnect(
00063 const RTCompConnect& src
00064 );
00065
00067 virtual ~RTCompConnect();
00068
00070
00074 void SetNameServer(std::string ServerName ,long OmniPort=-1);
00075
00077
00082 void SetNameServer(const int num, std::string ServerName, long OmniPort=-1);
00083
00085
00090 bool SetPort( const int num, std::string ComponentName, std::string PortName );
00091
00093
00098 bool SetPort( const int num,std::string ComponentName,int PortNumber);
00099
00101
00106 bool SetPort(const int num, RTC::PortList_var *plist, std::string PortName);
00107
00109
00114 bool SetPort(const int num, RTC::PortList *plist,int PortNumber);
00115
00117
00122 bool SetFoundPort( const int num, std::string ComponentName, std::string PortName );
00123
00124
00126
00131 bool Connect( std::string ConnectionName, std::string subs_type="Flush",std::string period ="" );
00132
00134 bool isConnect();
00135
00137 bool DisConnect(
00138 std::string ConnectionName
00139 );
00140
00142 RTCompConnect& operator=(
00143 const RTCompConnect& right
00144 );
00145
00146 private:
00147 RTC::CorbaNaming m_nameserver0;
00148 RTC::CorbaNaming m_nameserver1;
00149 RTCompSet m_port[2];
00150 std::string m_connect_id;
00151
00152 protected:
00154
00157 RTC::CorbaNaming* GetNameServer(const int num);
00158
00160
00165 void SetPortList (
00166 RTCompSet *port
00167 ,std::string &ComponentName
00168 ,RTC::CorbaNaming *NameServer
00169 );
00170
00172
00176 bool SetPortName (RTCompSet *port, std::string &PortName);
00177
00179
00183 bool SetPortNumber(RTCompSet *port, int &PortNumber);
00184
00186
00191 bool FindPortName(RTCompSet *port, std::string PortName, bool noConnectionPort = true);
00192
00194
00199 std::string NameAndPort2str(std::string name, long port)
00200 {
00201 if(port!=-1)
00202 {
00203 char PortStr[6];
00204 sprintf(PortStr,":%ld",port);
00205 name += PortStr;
00206 }
00207 return name;
00208 };
00209
00210 };
00211
00212 #endif