#include <DomainParticipantFactoryImpl.h>
Inheritance diagram for OpenDDS::DCPS::DomainParticipantFactoryImpl:
This class acts as factory of the DomainParticipant.
See the DDS specification, OMG formal/04-12-02, for a description of the interface this class is implementing.
Definition at line 39 of file DomainParticipantFactoryImpl.h.
typedef Objref_Servant_Pair<DomainParticipantImpl, DDS::DomainParticipant, DDS::DomainParticipant_ptr, DDS::DomainParticipant_var> OpenDDS::DCPS::DomainParticipantFactoryImpl::Participant_Pair |
Definition at line 44 of file DomainParticipantFactoryImpl.h.
OpenDDS::DCPS::DomainParticipantFactoryImpl::DomainParticipantFactoryImpl | ( | ) |
Constructor
Definition at line 22 of file DomainParticipantFactoryImpl.cpp.
00023 : qos_(TheServiceParticipant->initial_DomainParticipantFactoryQos()), 00024 default_participant_qos_(TheServiceParticipant->initial_DomainParticipantQos()) 00025 { 00026 }
OpenDDS::DCPS::DomainParticipantFactoryImpl::~DomainParticipantFactoryImpl | ( | ) | [virtual] |
Destructor
Definition at line 29 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::DCPS_debug_level.
00030 { 00031 if (DCPS_debug_level > 0) { 00032 ACE_DEBUG((LM_DEBUG, 00033 "%T (%P|%t) DomainParticipantFactoryImpl::" 00034 "~DomainParticipantFactoryImpl()\n")); 00035 } 00036 }
DDS::DomainParticipant_ptr OpenDDS::DCPS::DomainParticipantFactoryImpl::create_participant | ( | DDS::DomainId_t | domainId, | |
const DDS::DomainParticipantQos & | qos, | |||
DDS::DomainParticipantListener_ptr | a_listener, | |||
DDS::StatusMask | mask | |||
) | [virtual] |
Definition at line 39 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::bind(), OpenDDS::DCPS::Qos_Helper::consistent(), OpenDDS::DCPS::DomainParticipantImpl::enable(), DDS::DomainParticipantFactoryQos::entity_factory, OpenDDS::DCPS::AddDomainStatus::federated, OpenDDS::DCPS::find(), OpenDDS::DCPS::GUID_UNKNOWN, OpenDDS::DCPS::AddDomainStatus::id, OpenDDS::DCPS::insert(), OpenDDS::DCPS::RcHandle< T >::is_nil(), NO_DUP, participants_, qos_, OpenDDS::DCPS::DomainParticipantImpl::set_object_reference(), TheServiceParticipant, and OpenDDS::DCPS::Qos_Helper::valid().
00044 { 00045 if (!Qos_Helper::valid(qos)) { 00046 ACE_ERROR((LM_ERROR, 00047 ACE_TEXT("(%P|%t) ERROR: ") 00048 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00049 ACE_TEXT("invalid qos.\n"))); 00050 return DDS::DomainParticipant::_nil(); 00051 } 00052 00053 if (!Qos_Helper::consistent(qos)) { 00054 ACE_ERROR((LM_ERROR, 00055 ACE_TEXT("(%P|%t) ERROR: ") 00056 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00057 ACE_TEXT("inconsistent qos.\n"))); 00058 return DDS::DomainParticipant::_nil(); 00059 } 00060 00061 Discovery_rch disco = TheServiceParticipant->get_discovery(domainId); 00062 00063 if (disco.is_nil()) { 00064 ACE_ERROR((LM_ERROR, 00065 ACE_TEXT("(%P|%t) ERROR: ") 00066 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00067 ACE_TEXT("no repository found for domainId: %d.\n"), domainId)); 00068 return DDS::DomainParticipant::_nil(); 00069 } 00070 00071 const AddDomainStatus value = 00072 disco->add_domain_participant(domainId, qos); 00073 00074 if (value.id == GUID_UNKNOWN) { 00075 ACE_ERROR((LM_ERROR, 00076 ACE_TEXT("(%P|%t) ERROR: ") 00077 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00078 ACE_TEXT("add_domain_participant returned invalid id.\n"))); 00079 return DDS::DomainParticipant::_nil(); 00080 } 00081 00082 DomainParticipantImpl* dp; 00083 00084 ACE_NEW_RETURN(dp, 00085 DomainParticipantImpl(this, domainId, value.id, qos, a_listener, 00086 mask, value.federated), 00087 DDS::DomainParticipant::_nil()); 00088 00089 DDS::DomainParticipant_ptr dp_obj(dp); 00090 00091 if (CORBA::is_nil(dp_obj)) { 00092 ACE_ERROR((LM_ERROR, 00093 ACE_TEXT("(%P|%t) ERROR: ") 00094 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00095 ACE_TEXT("nil DomainParticipant.\n"))); 00096 return DDS::DomainParticipant::_nil(); 00097 } 00098 00099 // Set the participant object reference before enable since it's 00100 // needed for the built in topics during enable. 00101 dp->set_object_reference(dp_obj); //xxx no change 00102 00103 if (qos_.entity_factory.autoenable_created_entities == 1) { 00104 dp->enable(); 00105 } 00106 00107 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00108 tao_mon, 00109 this->participants_protector_, 00110 DDS::DomainParticipant::_nil()); 00111 00112 // the Pair will also act as a guard against leaking the 00113 // new DomainParticipantImpl (NO_DUP, so this takes over mem) 00114 Participant_Pair pair(dp, dp_obj, NO_DUP); 00115 00116 DPSet* entry; 00117 00118 if (find(participants_, domainId, entry) == -1) { 00119 DPSet set; 00120 00121 if (OpenDDS::DCPS::insert(set, pair) == -1) { 00122 ACE_ERROR((LM_ERROR, 00123 ACE_TEXT("(%P|%t) ERROR: ") 00124 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00125 ACE_TEXT(" %p.\n"), 00126 ACE_TEXT("insert"))); 00127 return DDS::DomainParticipant::_nil(); 00128 } 00129 00130 if (OpenDDS::DCPS::bind(participants_, domainId, set) == -1) { 00131 ACE_ERROR((LM_ERROR, 00132 ACE_TEXT("(%P|%t) ERROR: ") 00133 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00134 ACE_TEXT(" %p.\n"), 00135 ACE_TEXT("bind"))); 00136 return DDS::DomainParticipant::_nil(); 00137 } 00138 00139 } else { 00140 if (OpenDDS::DCPS::insert(*entry, pair) == -1) { 00141 ACE_ERROR((LM_ERROR, 00142 ACE_TEXT("(%P|%t) ERROR: ") 00143 ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ") 00144 ACE_TEXT(" %p.\n"), 00145 ACE_TEXT("insert"))); 00146 return DDS::DomainParticipant::_nil(); 00147 } 00148 } 00149 00150 //xxx still ref_count = 1 00151 00152 return DDS::DomainParticipant::_duplicate(dp_obj); //xxx still 2 (obj 3->4) 00153 } //xxx obj 4->3
DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::delete_participant | ( | DDS::DomainParticipant_ptr | a_participant | ) | [virtual] |
Definition at line 156 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::DomainParticipantImpl::delete_contained_entities(), DUP, OpenDDS::DCPS::find(), OpenDDS::DCPS::DomainParticipantImpl::get_domain_id(), OpenDDS::DCPS::DomainParticipantImpl::get_id(), OpenDDS::DCPS::DomainParticipantImpl::is_clean(), OPENDDS_STRING, participants_, OpenDDS::DCPS::remove(), DDS::RETCODE_BAD_PARAMETER, DDS::RETCODE_ERROR, DDS::RETCODE_OK, DDS::RETCODE_PRECONDITION_NOT_MET, TheServiceParticipant, and OpenDDS::DCPS::unbind().
00158 { 00159 00160 //xxx rc = 4 00161 if (CORBA::is_nil(a_participant)) { 00162 ACE_ERROR_RETURN((LM_ERROR, 00163 ACE_TEXT("(%P|%t) ERROR: ") 00164 ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ") 00165 ACE_TEXT("Nil participant.\n")), 00166 DDS::RETCODE_BAD_PARAMETER); 00167 } 00168 00169 // The servant's ref count should be 2 at this point, one referenced 00170 // by the poa and the other referenced by the map. 00171 DomainParticipantImpl* the_servant 00172 = dynamic_cast<DomainParticipantImpl*>(a_participant); 00173 00174 //xxx servant rc = 4 (servant::DP::Entity::ServantBase::ref_count_ 00175 if (the_servant->is_clean() == 0) { 00176 RepoId id = the_servant->get_id(); 00177 GuidConverter converter(id); 00178 ACE_DEBUG((LM_DEBUG, // not an ERROR, tests may be doing this on purpose 00179 ACE_TEXT("(%P|%t) WARNING: ") 00180 ACE_TEXT("DomainParticipantFactoryImpl::delete_participant: ") 00181 ACE_TEXT("the participant %C is not empty.\n"), 00182 OPENDDS_STRING(converter).c_str())); 00183 00184 return DDS::RETCODE_PRECONDITION_NOT_MET; 00185 } 00186 00187 DDS::DomainId_t domain_id = the_servant->get_domain_id(); 00188 RepoId dp_id = the_servant->get_id(); 00189 00190 DPSet* entry = 0; 00191 00192 if (find(participants_, domain_id, entry) == -1) { 00193 GuidConverter converter(dp_id); 00194 ACE_ERROR_RETURN((LM_ERROR, 00195 ACE_TEXT("(%P|%t) ERROR: ") 00196 ACE_TEXT("DomainParticipantFactoryImpl::delete_participant: ") 00197 ACE_TEXT("%p domain_id=%d dp_id=%s.\n"), 00198 ACE_TEXT("find"), 00199 domain_id, 00200 OPENDDS_STRING(converter).c_str()), DDS::RETCODE_ERROR); 00201 00202 } else { 00203 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00204 tao_mon, 00205 this->participants_protector_, 00206 DDS::RETCODE_ERROR); 00207 00208 DDS::ReturnCode_t result 00209 = the_servant->delete_contained_entities(); 00210 00211 //xxx still rc=4 00212 if (result != DDS::RETCODE_OK) { 00213 return result; 00214 } 00215 00216 Participant_Pair pair(the_servant, a_participant, DUP); 00217 00218 if (OpenDDS::DCPS::remove(*entry, pair) == -1) { 00219 ACE_ERROR_RETURN((LM_ERROR, 00220 ACE_TEXT("(%P|%t) ERROR: ") 00221 ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ") 00222 ACE_TEXT(" %p.\n"), 00223 ACE_TEXT("remove")), 00224 DDS::RETCODE_ERROR); 00225 } 00226 00227 //xxx now obj rc=5 and servant rc=4 00228 if (entry->empty()) { 00229 if (unbind(participants_, domain_id) == -1) { 00230 ACE_ERROR_RETURN((LM_ERROR, 00231 ACE_TEXT("(%P|%t) ERROR: ") 00232 ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ") 00233 ACE_TEXT(" %p.\n"), 00234 ACE_TEXT("unbind")), 00235 DDS::RETCODE_ERROR); 00236 } 00237 } //xxx now obj rc = 4 00238 }//xxx now obj rc = 3 00239 00240 Discovery_rch disco = TheServiceParticipant->get_discovery(domain_id); 00241 if (!disco->remove_domain_participant(domain_id, 00242 dp_id)) { 00243 ACE_ERROR_RETURN((LM_ERROR, 00244 ACE_TEXT("(%P|%t) ERROR: ") 00245 ACE_TEXT("could not remove domain participant.\n")), 00246 DDS::RETCODE_ERROR); 00247 } 00248 return DDS::RETCODE_OK; 00249 }
DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::get_default_participant_qos | ( | DDS::DomainParticipantQos & | qos | ) | [virtual] |
Definition at line 296 of file DomainParticipantFactoryImpl.cpp.
References default_participant_qos_, and DDS::RETCODE_OK.
00298 { 00299 qos = default_participant_qos_; 00300 return DDS::RETCODE_OK; 00301 }
DDS::DomainParticipantFactory_ptr OpenDDS::DCPS::DomainParticipantFactoryImpl::get_instance | ( | ) | [virtual] |
Implements DDS::DomainParticipantFactory.
Definition at line 304 of file DomainParticipantFactoryImpl.cpp.
References TheParticipantFactory.
00305 { 00306 return TheParticipantFactory; 00307 }
DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::get_qos | ( | DDS::DomainParticipantFactoryQos & | qos | ) | [virtual] |
Definition at line 325 of file DomainParticipantFactoryImpl.cpp.
References qos_, and DDS::RETCODE_OK.
00327 { 00328 qos = this->qos_; 00329 return DDS::RETCODE_OK; 00330 }
DDS::DomainParticipant_ptr OpenDDS::DCPS::DomainParticipantFactoryImpl::lookup_participant | ( | DDS::DomainId_t | domainId | ) | [virtual] |
Definition at line 252 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::find(), and participants_.
00254 { 00255 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00256 tao_mon, 00257 this->participants_protector_, 00258 DDS::DomainParticipant::_nil()); 00259 00260 DPSet* entry; 00261 00262 if (find(participants_, domainId, entry) == -1) { 00263 if (DCPS_debug_level >= 1) { 00264 ACE_DEBUG((LM_DEBUG, 00265 ACE_TEXT("(%P|%t) ") 00266 ACE_TEXT("DomainParticipantFactoryImpl::lookup_participant, ") 00267 ACE_TEXT(" not found for domain %d.\n"), 00268 domainId)); 00269 } 00270 00271 return DDS::DomainParticipant::_nil(); 00272 00273 } else { 00274 // No specification about which participant will return. We just return the first 00275 // object. 00276 // Note: We are not duplicate the object ref, so a delete call is not needed. 00277 return DDS::DomainParticipant::_duplicate((*(entry->begin())).obj_.in()); 00278 } 00279 }
typedef OpenDDS::DCPS::DomainParticipantFactoryImpl::OPENDDS_MAP | ( | DDS::DomainId_t | , | |
DPSet | ||||
) |
typedef OpenDDS::DCPS::DomainParticipantFactoryImpl::OPENDDS_SET | ( | Participant_Pair | ) |
const DomainParticipantFactoryImpl::DPMap & OpenDDS::DCPS::DomainParticipantFactoryImpl::participants | ( | ) | const |
Expose the participants for reading.
Definition at line 333 of file DomainParticipantFactoryImpl.cpp.
References participants_.
Referenced by OpenDDS::DCPS::Service_Participant::set_repo_domain().
00334 { 00335 return this->participants_; 00336 }
DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::set_default_participant_qos | ( | const DDS::DomainParticipantQos & | qos | ) | [virtual] |
Definition at line 282 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::Qos_Helper::consistent(), default_participant_qos_, DDS::RETCODE_INCONSISTENT_POLICY, DDS::RETCODE_OK, and OpenDDS::DCPS::Qos_Helper::valid().
00284 { 00285 if (Qos_Helper::valid(qos) 00286 && Qos_Helper::consistent(qos)) { 00287 default_participant_qos_ = qos; 00288 return DDS::RETCODE_OK; 00289 00290 } else { 00291 return DDS::RETCODE_INCONSISTENT_POLICY; 00292 } 00293 }
DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::set_qos | ( | const DDS::DomainParticipantFactoryQos & | qos | ) | [virtual] |
Definition at line 310 of file DomainParticipantFactoryImpl.cpp.
References OpenDDS::DCPS::Qos_Helper::changeable(), OpenDDS::DCPS::Qos_Helper::consistent(), qos_, DDS::RETCODE_INCONSISTENT_POLICY, DDS::RETCODE_OK, and OpenDDS::DCPS::Qos_Helper::valid().
00312 { 00313 if (Qos_Helper::valid(qos) && Qos_Helper::consistent(qos)) { 00314 if (!(qos_ == qos) && Qos_Helper::changeable(qos_, qos)) 00315 qos_ = qos; 00316 00317 return DDS::RETCODE_OK; 00318 00319 } else { 00320 return DDS::RETCODE_INCONSISTENT_POLICY; 00321 } 00322 }
DDS::DomainParticipantQos OpenDDS::DCPS::DomainParticipantFactoryImpl::default_participant_qos_ [private] |
The default qos value of DomainParticipant.
Definition at line 88 of file DomainParticipantFactoryImpl.h.
Referenced by get_default_participant_qos(), and set_default_participant_qos().
DPMap OpenDDS::DCPS::DomainParticipantFactoryImpl::participants_ [private] |
The collection of domain participants.
Definition at line 91 of file DomainParticipantFactoryImpl.h.
Referenced by create_participant(), delete_participant(), lookup_participant(), and participants().
ACE_Recursive_Thread_Mutex OpenDDS::DCPS::DomainParticipantFactoryImpl::participants_protector_ [private] |
Protect the participant collection. Use recursive mutex to allow nested acquisition and release of a mutex that occurs in the same thread.
Definition at line 96 of file DomainParticipantFactoryImpl.h.
Definition at line 85 of file DomainParticipantFactoryImpl.h.
Referenced by create_participant(), get_qos(), and set_qos().