예제 #1
0
        /// <summary>
        /// This operation deletes an IDomainParticipant.
        /// </summary>
        /// <remarks>
        /// An IDomainParticipant cannot
        /// be deleted when it has any attached Entity objects. When the operation is called
        /// on a IDomainParticipant with existing Entity objects, the operation returns
        /// DDS.ReturnCode PreconditionNotMet.
        /// </remarks>
        /// @param a_participant The IDomainParticipant that is to be deleted.
        /// @return DDS.ReturnCode Ok - The IDomainParticipant is deleted
        /// @return DDS.ReturnCode Error - An internal error has occurred
        /// @return DDS.ReturnCode BadParameter - The given IDomainParticipant is not valid
        /// @return DDS.ReturnCode OutOfResources - The Data Distribution Service ran out of
        ///                                         resources to complete this operation.
        /// @return DDS.ReturnCode PreconditionNotMet - The IDomainParticipant contains one
        ///                                             or more Entity objects.
        public ReturnCode DeleteParticipant(IDomainParticipant a_participant)
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            ReportStack.Start();
            DomainParticipant participant = a_participant as DomainParticipant;

            if (participant != null)
            {
                lock (singleton_lock)
                {
                    if (participantList.Remove(participant))
                    {
                        result = participant.wlReq_deinit();
                        if (result != DDS.ReturnCode.Ok)
                        {
                            participantList.Add(participant);
                        }
                    }
                    else
                    {
                        /* Since there is only one DomainParticipantFactory, the participant
                         * has to be created by this one. If we can't find it anymore, it
                         * must have beel deleted already.
                         */
                        result = DDS.ReturnCode.BadParameter;
                        ReportStack.Report(result, "DomainParticipant was already deleted.");
                    }
                }
            }
            else
            {
                result = ReturnCode.BadParameter;
                ReportStack.Report(result, "Participant parameter 'a_participant' is null.");
            }

            ReportStack.Flush(null, result != DDS.ReturnCode.Ok);
            return(result);
        }