OpenDDS::DCPS::DomainParticipantFactoryImpl Class Reference

Implements the OpenDDS::DCPS::DomainParticipantFactory interfaces. More...

#include <DomainParticipantFactoryImpl.h>

Inheritance diagram for OpenDDS::DCPS::DomainParticipantFactoryImpl:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::DomainParticipantFactoryImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

typedef OPENDDS_SET (RcHandle< DomainParticipantImpl >) DPSet
typedef OPENDDS_MAP (DDS::DomainId_t, DPSet) DPMap
 DomainParticipantFactoryImpl ()
virtual ~DomainParticipantFactoryImpl ()
virtual DDS::DomainParticipant_ptr create_participant (DDS::DomainId_t domainId, const DDS::DomainParticipantQos &qos, DDS::DomainParticipantListener_ptr a_listener, DDS::StatusMask mask)
virtual DDS::ReturnCode_t delete_participant (DDS::DomainParticipant_ptr a_participant)
virtual DDS::DomainParticipant_ptr lookup_participant (DDS::DomainId_t domainId)
virtual DDS::ReturnCode_t set_default_participant_qos (const DDS::DomainParticipantQos &qos)
virtual DDS::ReturnCode_t get_default_participant_qos (DDS::DomainParticipantQos &qos)
virtual
DDS::DomainParticipantFactory_ptr 
get_instance ()
virtual DDS::ReturnCode_t set_qos (const DDS::DomainParticipantFactoryQos &qos)
virtual DDS::ReturnCode_t get_qos (DDS::DomainParticipantFactoryQos &qos)
const DPMap & participants () const
 Expose the participants for reading.
void cleanup ()

Private Attributes

DDS::DomainParticipantFactoryQos qos_
DDS::DomainParticipantQos default_participant_qos_
 The default qos value of DomainParticipant.
DPMap participants_
 The collection of domain participants.
ACE_Recursive_Thread_Mutex participants_protector_

Detailed Description

Implements the OpenDDS::DCPS::DomainParticipantFactory interfaces.

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 40 of file DomainParticipantFactoryImpl.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::DomainParticipantFactoryImpl::DomainParticipantFactoryImpl (  ) 

Definition at line 24 of file DomainParticipantFactoryImpl.cpp.

00025   : qos_(TheServiceParticipant->initial_DomainParticipantFactoryQos()),
00026     default_participant_qos_(TheServiceParticipant->initial_DomainParticipantQos())
00027 {
00028 }

OpenDDS::DCPS::DomainParticipantFactoryImpl::~DomainParticipantFactoryImpl (  )  [virtual]

Definition at line 30 of file DomainParticipantFactoryImpl.cpp.

References OpenDDS::DCPS::DCPS_debug_level, and LM_DEBUG.

00031 {
00032   if (DCPS_debug_level > 0) {
00033     ACE_DEBUG((LM_DEBUG,
00034                "%T (%P|%t) DomainParticipantFactoryImpl::"
00035                "~DomainParticipantFactoryImpl()\n"));
00036   }
00037 }


Member Function Documentation

void OpenDDS::DCPS::DomainParticipantFactoryImpl::cleanup ( void   ) 

Definition at line 281 of file DomainParticipantFactoryImpl.cpp.

References participants_.

00282 {
00283   DPMap::iterator itr;
00284   for (itr = participants_.begin(); itr != participants_.end(); ++itr) {
00285     DPSet& dp_set = itr->second;
00286     DPSet::iterator dp_set_itr;
00287     for (dp_set_itr = dp_set.begin(); dp_set_itr != dp_set.end(); ++dp_set_itr) {
00288       (*dp_set_itr)->delete_contained_entities();
00289     }
00290   }
00291 }

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 40 of file DomainParticipantFactoryImpl.cpp.

References CORBA::LocalObject::_nil(), OpenDDS::DCPS::RcHandle< T >::_retn(), ACE_TEXT(), OpenDDS::DCPS::Qos_Helper::consistent(), DDS::DomainParticipantFactoryQos::entity_factory, get_default_participant_qos(), LM_ERROR, PARTICIPANT_QOS_DEFAULT, participants_, participants_protector_, qos_, DDS::RETCODE_OK, and OpenDDS::DCPS::Qos_Helper::valid().

00045 {
00046   DDS::DomainParticipantQos par_qos = qos;
00047 
00048   if (par_qos == PARTICIPANT_QOS_DEFAULT) {
00049     get_default_participant_qos(par_qos);
00050   }
00051 
00052   if (!Qos_Helper::valid(par_qos)) {
00053     ACE_ERROR((LM_ERROR,
00054                ACE_TEXT("(%P|%t) ERROR: ")
00055                ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ")
00056                ACE_TEXT("invalid qos.\n")));
00057     return DDS::DomainParticipant::_nil();
00058   }
00059 
00060   if (!Qos_Helper::consistent(par_qos)) {
00061     ACE_ERROR((LM_ERROR,
00062                ACE_TEXT("(%P|%t) ERROR: ")
00063                ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ")
00064                ACE_TEXT("inconsistent qos.\n")));
00065     return DDS::DomainParticipant::_nil();
00066   }
00067 
00068   RcHandle<DomainParticipantImpl> dp =
00069     make_rch<DomainParticipantImpl>(this, domainId, par_qos, a_listener, mask);
00070 
00071   if (qos_.entity_factory.autoenable_created_entities) {
00072     if (dp->enable() != DDS::RETCODE_OK) {
00073       ACE_ERROR((LM_ERROR,
00074                  ACE_TEXT("(%P|%t) ERROR: ")
00075                  ACE_TEXT("DomainParticipantFactoryImpl::create_participant, ")
00076                  ACE_TEXT("unable to enable DomainParticipant.\n")));
00077       return DDS::DomainParticipant::_nil();
00078     }
00079   }
00080 
00081   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00082                    tao_mon,
00083                    this->participants_protector_,
00084                    DDS::DomainParticipant::_nil());
00085 
00086   participants_[domainId].insert(dp);
00087   return dp._retn();
00088 }

Here is the call graph for this function:

DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::delete_participant ( DDS::DomainParticipant_ptr  a_participant  )  [virtual]

Definition at line 91 of file DomainParticipantFactoryImpl.cpp.

References ACE_TEXT(), OpenDDS::DCPS::DomainParticipantImpl::delete_contained_entities(), OpenDDS::DCPS::find(), OpenDDS::DCPS::DomainParticipantImpl::get_domain_id(), OpenDDS::DCPS::DomainParticipantImpl::get_id(), OpenDDS::DCPS::DomainParticipantImpl::is_clean(), CORBA::is_nil(), LM_DEBUG, LM_ERROR, OPENDDS_STRING, participants_, participants_protector_, OpenDDS::DCPS::rchandle_from(), OpenDDS::DCPS::remove(), DDS::RETCODE_BAD_PARAMETER, DDS::RETCODE_ERROR, DDS::RETCODE_OK, DDS::RETCODE_PRECONDITION_NOT_MET, TheServiceParticipant, and OpenDDS::DCPS::unbind().

00093 {
00094 
00095 //xxx rc = 4
00096   if (CORBA::is_nil(a_participant)) {
00097     ACE_ERROR_RETURN((LM_ERROR,
00098                       ACE_TEXT("(%P|%t) ERROR: ")
00099                       ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ")
00100                       ACE_TEXT("Nil participant.\n")),
00101                      DDS::RETCODE_BAD_PARAMETER);
00102   }
00103 
00104   // The servant's ref count should be 2 at this point, one referenced
00105   // by the poa and the other referenced by the map.
00106   DomainParticipantImpl* the_servant
00107   = dynamic_cast<DomainParticipantImpl*>(a_participant);
00108 
00109   if (!the_servant) {
00110     ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ")
00111       ACE_TEXT("DomainParticipantFactoryImpl::delete_participant: ")
00112       ACE_TEXT("failed to obtain the DomainParticipantImpl.\n")));
00113 
00114     return DDS::RETCODE_ERROR;
00115   }
00116 
00117   RcHandle<DomainParticipantImpl> servant_rch = rchandle_from(the_servant);
00118 
00119   //xxx servant rc = 4 (servant::DP::Entity::ServantBase::ref_count_
00120   if (!the_servant->is_clean()) {
00121     RepoId id = the_servant->get_id();
00122     GuidConverter converter(id);
00123     ACE_DEBUG((LM_DEBUG, // not an ERROR, tests may be doing this on purpose
00124                ACE_TEXT("(%P|%t) WARNING: ")
00125                ACE_TEXT("DomainParticipantFactoryImpl::delete_participant: ")
00126                ACE_TEXT("the participant %C is not empty.\n"),
00127                OPENDDS_STRING(converter).c_str()));
00128 
00129     return DDS::RETCODE_PRECONDITION_NOT_MET;
00130   }
00131 
00132   const DDS::DomainId_t domain_id = the_servant->get_domain_id();
00133   RepoId dp_id = the_servant->get_id();
00134 
00135   DPSet* entry = 0;
00136 
00137   if (find(participants_, domain_id, entry) == -1) {
00138     GuidConverter converter(dp_id);
00139     ACE_ERROR_RETURN((LM_ERROR,
00140                       ACE_TEXT("(%P|%t) ERROR: ")
00141                       ACE_TEXT("DomainParticipantFactoryImpl::delete_participant: ")
00142                       ACE_TEXT("%p domain_id=%d dp_id=%C.\n"),
00143                       ACE_TEXT("find"),
00144                       domain_id,
00145                       OPENDDS_STRING(converter).c_str()), DDS::RETCODE_ERROR);
00146 
00147   } else {
00148     ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00149                      tao_mon,
00150                      this->participants_protector_,
00151                      DDS::RETCODE_ERROR);
00152 
00153     DDS::ReturnCode_t result
00154     = the_servant->delete_contained_entities();
00155 
00156     if (result != DDS::RETCODE_OK) {
00157       return result;
00158     }
00159 
00160     if (OpenDDS::DCPS::remove(*entry, servant_rch) == -1) {
00161       ACE_ERROR_RETURN((LM_ERROR,
00162                         ACE_TEXT("(%P|%t) ERROR: ")
00163                         ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ")
00164                         ACE_TEXT(" %p.\n"),
00165                         ACE_TEXT("remove")),
00166                        DDS::RETCODE_ERROR);
00167     }
00168 
00169     if (entry->empty()) {
00170       if (unbind(participants_, domain_id) == -1) {
00171         ACE_ERROR_RETURN((LM_ERROR,
00172                           ACE_TEXT("(%P|%t) ERROR: ")
00173                           ACE_TEXT("DomainParticipantFactoryImpl::delete_participant, ")
00174                           ACE_TEXT(" %p.\n"),
00175                           ACE_TEXT("unbind")),
00176                          DDS::RETCODE_ERROR);
00177       }
00178     }
00179   }
00180 
00181   Discovery_rch disco = TheServiceParticipant->get_discovery(domain_id);
00182   if (disco) {
00183     if (!disco->remove_domain_participant(domain_id,
00184                                           dp_id)) {
00185       ACE_ERROR_RETURN((LM_ERROR,
00186                         ACE_TEXT("(%P|%t) ERROR: ")
00187                         ACE_TEXT("could not remove domain participant.\n")),
00188                        DDS::RETCODE_ERROR);
00189     }
00190   }
00191   return DDS::RETCODE_OK;
00192 }

Here is the call graph for this function:

DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::get_default_participant_qos ( DDS::DomainParticipantQos qos  )  [virtual]

Definition at line 239 of file DomainParticipantFactoryImpl.cpp.

References default_participant_qos_, and DDS::RETCODE_OK.

Referenced by create_participant().

00241 {
00242   qos = default_participant_qos_;
00243   return DDS::RETCODE_OK;
00244 }

Here is the caller graph for this function:

DDS::DomainParticipantFactory_ptr OpenDDS::DCPS::DomainParticipantFactoryImpl::get_instance (  )  [virtual]

Implements DDS::DomainParticipantFactory.

Definition at line 247 of file DomainParticipantFactoryImpl.cpp.

References TheParticipantFactory.

00248 {
00249   return TheParticipantFactory;
00250 }

DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::get_qos ( DDS::DomainParticipantFactoryQos qos  )  [virtual]

Definition at line 268 of file DomainParticipantFactoryImpl.cpp.

References qos_, and DDS::RETCODE_OK.

00270 {
00271   qos = this->qos_;
00272   return DDS::RETCODE_OK;
00273 }

DDS::DomainParticipant_ptr OpenDDS::DCPS::DomainParticipantFactoryImpl::lookup_participant ( DDS::DomainId_t  domainId  )  [virtual]

Definition at line 195 of file DomainParticipantFactoryImpl.cpp.

References CORBA::LocalObject::_duplicate(), CORBA::LocalObject::_nil(), ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::find(), LM_DEBUG, participants_, and participants_protector_.

00197 {
00198   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00199                    tao_mon,
00200                    this->participants_protector_,
00201                    DDS::DomainParticipant::_nil());
00202 
00203   DPSet* entry;
00204 
00205   if (find(participants_, domainId, entry) == -1) {
00206     if (DCPS_debug_level >= 1) {
00207       ACE_DEBUG((LM_DEBUG,
00208                  ACE_TEXT("(%P|%t) ")
00209                  ACE_TEXT("DomainParticipantFactoryImpl::lookup_participant, ")
00210                  ACE_TEXT(" not found for domain %d.\n"),
00211                  domainId));
00212     }
00213 
00214     return DDS::DomainParticipant::_nil();
00215 
00216   } else {
00217     // No specification about which participant will return. We just return the first
00218     // object.
00219     // Note: We are not duplicate the object ref, so a delete call is not needed.
00220     return DDS::DomainParticipant::_duplicate(entry->begin()->in());
00221   }
00222 }

Here is the call graph for this function:

typedef OpenDDS::DCPS::DomainParticipantFactoryImpl::OPENDDS_MAP ( DDS::DomainId_t  ,
DPSet   
)
typedef OpenDDS::DCPS::DomainParticipantFactoryImpl::OPENDDS_SET ( RcHandle< DomainParticipantImpl  ) 
const DomainParticipantFactoryImpl::DPMap & OpenDDS::DCPS::DomainParticipantFactoryImpl::participants (  )  const

Expose the participants for reading.

Definition at line 276 of file DomainParticipantFactoryImpl.cpp.

References participants_.

00277 {
00278   return this->participants_;
00279 }

DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::set_default_participant_qos ( const DDS::DomainParticipantQos qos  )  [virtual]

Definition at line 225 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().

00227 {
00228   if (Qos_Helper::valid(qos)
00229       && Qos_Helper::consistent(qos)) {
00230     default_participant_qos_ = qos;
00231     return DDS::RETCODE_OK;
00232 
00233   } else {
00234     return DDS::RETCODE_INCONSISTENT_POLICY;
00235   }
00236 }

Here is the call graph for this function:

DDS::ReturnCode_t OpenDDS::DCPS::DomainParticipantFactoryImpl::set_qos ( const DDS::DomainParticipantFactoryQos qos  )  [virtual]

Definition at line 253 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().

00255 {
00256   if (Qos_Helper::valid(qos) && Qos_Helper::consistent(qos)) {
00257     if (!(qos_ == qos) && Qos_Helper::changeable(qos_, qos))
00258       qos_ = qos;
00259 
00260     return DDS::RETCODE_OK;
00261 
00262   } else {
00263     return DDS::RETCODE_INCONSISTENT_POLICY;
00264   }
00265 }

Here is the call graph for this function:


Member Data Documentation

The default qos value of DomainParticipant.

Definition at line 87 of file DomainParticipantFactoryImpl.h.

Referenced by get_default_participant_qos(), and set_default_participant_qos().

The collection of domain participants.

Definition at line 90 of file DomainParticipantFactoryImpl.h.

Referenced by cleanup(), create_participant(), delete_participant(), lookup_participant(), and participants().

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 95 of file DomainParticipantFactoryImpl.h.

Referenced by create_participant(), delete_participant(), and lookup_participant().

Definition at line 84 of file DomainParticipantFactoryImpl.h.

Referenced by create_participant(), get_qos(), and set_qos().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1