00001
00013 #ifndef __RtcComposite_h__
00014 #define __RtcComposite_h__
00015
00016 #include "rtm/RtcBase.h"
00017
00018 namespace RTM {
00019
00020 class RtcCompositeBase
00021 : public RtcBase
00022 {
00023 public:
00027 RtcCompositeBase();
00028 RtcCompositeBase(RtcManager* manager);
00029 RtcCompositeBase(CORBA::ORB_ptr &orb, PortableServer::POA_ptr &poa);
00030
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00044
00045
00047
00048
00050
00051
00053
00054
00056
00057
00058
00059
00060
00062
00063
00064
00065
00066
00068
00069
00070
00071
00072
00073
00075
00076
00077
00079
00080
00081
00082 virtual RTCProfile* profile();
00083 virtual RTCConfiguration* configuration();
00084
00085
00086
00087
00088
00089
00090
00091
00092
00096
00097
00101 virtual RtmRes rtc_add_component(RTCBase_ptr comp);
00102
00106 virtual RtmRes rtc_delete_component(RTCBase_ptr comp);
00107
00111 virtual RtmRes rtc_replace_component(RTCBase_ptr comp1, RTCBase_ptr comp2);
00112
00116 virtual RtmRes rtc_replace_component_by_name(const char* name1, const char* name2);
00117
00121 virtual RTCBaseList* rtc_components();
00122
00126 virtual RTCBase_ptr rtc_get_component(const char* name);
00127
00132 virtual RtmRes rtc_attach_inport(InPort_ptr in_port);
00133
00139 virtual RtmRes rtc_attach_inport_by_name(RTCBase_ptr comp, const char* name);
00140
00145 virtual RtmRes rtc_detatch_inport(InPort_ptr in_port);
00146
00150 virtual RtmRes rtc_detatch_inport_by_name(const char* name);
00151
00156 virtual RtmRes rtc_attach_outport(OutPort_ptr out_port);
00157
00163 virtual RtmRes rtc_attach_outport_by_name(RTCBase_ptr comp, const char* name);
00164
00169 virtual RtmRes rtc_detatch_outport(OutPort_ptr out_port);
00170
00174 virtual RtmRes rtc_detatch_outport_by_name(const char* name);
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00191
00192
00197 virtual int open(void *args){return 0;};
00198
00203 virtual int svc(void){return 0;};
00204
00205
00206
00207
00208
00210
00211
00213
00214
00216
00217
00218 protected:
00220
00221
00223
00224
00226
00227
00228
00229 protected:
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 static const ComponentState RTC_UNKNOWN = RTM::RTComponent::RTC_UNKNOWN;
00266 static const ComponentState RTC_BORN = RTM::RTComponent::RTC_BORN;
00267 static const ComponentState RTC_INITIALIZING = RTM::RTComponent::RTC_INITIALIZING;
00268 static const ComponentState RTC_READY = RTM::RTComponent::RTC_READY;
00269 static const ComponentState RTC_STARTING = RTM::RTComponent::RTC_STARTING;
00270 static const ComponentState RTC_ACTIVE = RTM::RTComponent::RTC_ACTIVE;
00271 static const ComponentState RTC_STOPPING = RTM::RTComponent::RTC_STOPPING;
00272 static const ComponentState RTC_ABORTING = RTM::RTComponent::RTC_ABORTING;
00273 static const ComponentState RTC_ERROR = RTM::RTComponent::RTC_ERROR;
00274 static const ComponentState RTC_FATAL_ERROR = RTM::RTComponent::RTC_FATAL_ERROR;
00275 static const ComponentState RTC_EXITING = RTM::RTComponent::RTC_EXITING;
00276
00277
00278
00279
00280
00285 virtual RtmRes rtc_ready_entry(){};
00290 virtual RtmRes rtc_ready_do(){};
00295 virtual RtmRes rtc_ready_exit(){};
00296
00297
00298
00299
00304 virtual RtmRes rtc_active_entry(){};
00309 virtual RtmRes rtc_active_do(){};
00314 virtual RtmRes rtc_active_exit(){};
00315
00316
00317
00318
00323 virtual RtmRes rtc_error_entry(){};
00328 virtual RtmRes rtc_error_do(){};
00333 virtual RtmRes rtc_error_exit(){};
00334
00335
00336
00337
00342 virtual RtmRes rtc_fatal_entry(){};
00347 virtual RtmRes rtc_fatal_do(){};
00352 virtual RtmRes rtc_fatal_exit(){};
00353
00354
00355
00357
00361 virtual RtmRes rtc_init_entry(){};
00362
00367 virtual RtmRes rtc_starting_entry(){};
00368
00373 virtual RtmRes rtc_stopping_entry(){};
00374
00379 virtual RtmRes rtc_aborting_entry(){};
00380
00385 virtual RtmRes rtc_exiting_entry(){};
00386
00387
00388
00389
00390
00400 bool registerPort(InPortBase& in_ch);
00401
00410 bool deletePort(InPortBase& in_ch);
00411
00420 bool deleteInPortByName(char* ch_name);
00421
00422
00423
00424
00434 bool registerPort(OutPortBase& out_ch);
00435
00444 bool deletePort(OutPortBase& out_ch);
00445
00454 bool deleteOutPortByName(char* ch_name);
00455
00456
00457 private:
00461 class eq_comp_name
00462 {
00463 public:
00464 const string m_name;
00465 eq_comp_name(const char* name) : m_name(name){};
00466 bool operator()(RTCBase_var comp)
00467 {
00468 if (comp->_is_nil())
00469 {
00470 return false;
00471 }
00472
00473 RTCProfile_var profile = comp->profile();
00474 if (ACE_OS::strcmp(m_name.c_str(),
00475 CORBA::string_dup(profile->name))
00476 == 0)
00477 {
00478 return true;
00479 }
00480 return false;
00481 }
00482 };
00483
00487 class eq_comp
00488 {
00489 public:
00490 const RTCBase_var m_comp;
00491 eq_comp(const RTCBase_ptr comp) : m_comp(comp){};
00492 bool operator()(RTCBase_ptr comp)
00493 {
00494 if (m_comp->_is_nil())
00495 {
00496 return false;
00497 }
00498 return m_comp->_is_equivalent(comp);
00499 };
00500 };
00501
00502
00503 class eq_port_name
00504 {
00505 public:
00506 const string m_name;
00507 eq_port_name(const char* name) : m_name(name) {};
00508 bool operator()(InPort_ptr in_port)
00509 {
00510 if (in_port->_is_nil())
00511 {
00512 return false;
00513 }
00514
00515 PortProfile_var profile = in_port->profile();
00516 if (ACE_OS::strcmp(m_name.c_str(),
00517 CORBA::string_dup(profile->name))
00518 == 0)
00519 {
00520 return true;
00521 }
00522 return false;
00523 }
00524 bool operator()(OutPort_ptr out_port)
00525 {
00526 if (out_port->_is_nil())
00527 {
00528 return false;
00529 }
00530
00531 PortProfile_var profile = out_port->profile();
00532 if (ACE_OS::strcmp(m_name.c_str(),
00533 CORBA::string_dup(profile->name))
00534 == 0)
00535 {
00536 return true;
00537 }
00538 return false;
00539 }
00540
00541 };
00542
00546 class eq_port
00547 {
00548 public:
00549 const InPort_var m_inport;
00550 const OutPort_var m_outport;
00551 eq_port(const InPort_ptr port) : m_inport(port){};
00552 eq_port(const OutPort_ptr port) : m_outport(port){};
00553 bool operator()(InPort_ptr port)
00554 {
00555 if (m_inport->_is_nil())
00556 {
00557 return false;
00558 }
00559 return m_inport->_is_equivalent(port);
00560 };
00561 bool operator()(OutPort_ptr port)
00562 {
00563 if (m_outport->_is_nil())
00564 {
00565 return false;
00566 }
00567 return m_outport->_is_equivalent(port);
00568 };
00569 };
00570
00571
00572
00573
00574 protected:
00575 RTCProfile m_Profile;
00576 RTCConfiguration m_Configuration;
00577
00578 typedef list<RTCBase_ptr>::iterator Components_it;
00579
00581 struct Components
00582 {
00583 list<RTCBase_ptr> m_List;
00584 ACE_Thread_Mutex m_Mutex;
00585 };
00586 Components m_Components;
00587
00589 typedef list<InPort_ptr>::iterator InPorts_it;
00590
00592 typedef list<OutPort_ptr>::iterator OutPorts_it;
00593
00595 struct InPorts
00596 {
00597 list<InPort_ptr> m_List;
00598 ACE_Thread_Mutex m_Mutex;
00599 };
00600 InPorts m_InPorts;
00601
00603 struct OutPorts
00604 {
00605 list<OutPort_ptr> m_List;
00606 ACE_Thread_Mutex m_Mutex;
00607 };
00608 OutPorts m_OutPorts;
00609
00610 };
00611
00612 };
00613
00614 #endif // end of __RtcComposite_h_