EntityImpl.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  * Distributed under the OpenDDS License.
00004  * See: http://www.opendds.org/license.html
00005  */
00006 
00007 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
00008 #include "EntityImpl.h"
00009 #include "StatusConditionImpl.h"
00010 #include "dds/DCPS/transport/framework/TransportConfig.h"
00011 
00012 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 namespace OpenDDS {
00015 namespace DCPS {
00016 
00017 EntityImpl::EntityImpl()
00018   : enabled_(false),
00019     entity_deleted_(false),
00020     status_changes_(0),
00021     status_condition_(new StatusConditionImpl(this))
00022 {
00023 }
00024 
00025 EntityImpl::~EntityImpl()
00026 {
00027 }
00028 
00029 DDS::ReturnCode_t
00030 EntityImpl::set_enabled()
00031 {
00032   enabled_ = true;
00033 
00034   return DDS::RETCODE_OK;
00035 }
00036 
00037 bool
00038 EntityImpl::is_enabled() const
00039 {
00040   return this->enabled_.value();
00041 }
00042 
00043 DDS::StatusCondition_ptr
00044 EntityImpl::get_statuscondition()
00045 {
00046   return DDS::StatusCondition::_duplicate(status_condition_);
00047 }
00048 
00049 DDS::StatusMask
00050 EntityImpl::get_status_changes()
00051 {
00052   ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, 0);
00053   return status_changes_;
00054 }
00055 
00056 void
00057 EntityImpl::set_status_changed_flag(
00058   DDS::StatusKind status,
00059   bool status_changed_flag)
00060 {
00061   ACE_GUARD(ACE_Thread_Mutex, g, lock_);
00062 
00063   if (status_changed_flag) {
00064     status_changes_ |= status;
00065 
00066   } else {
00067     status_changes_ &= ~status;
00068   }
00069 }
00070 
00071 void
00072 EntityImpl::set_deleted(bool state)
00073 {
00074   entity_deleted_ = state;
00075 }
00076 
00077 bool
00078 EntityImpl::get_deleted()
00079 {
00080   return this->entity_deleted_.value();
00081 }
00082 
00083 void
00084 EntityImpl::notify_status_condition()
00085 {
00086   StatusConditionImpl* sci =
00087     dynamic_cast<StatusConditionImpl*>(status_condition_.in());
00088   if (sci) {
00089     sci->signal_all();
00090   } else {
00091     ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ")
00092       ACE_TEXT("EntityImpl::notify_status_condition: ")
00093       ACE_TEXT("failed to obtain the StatusConditionImpl.\n")));
00094   }
00095 }
00096 
00097 void
00098 EntityImpl::transport_config(const TransportConfig_rch& cfg)
00099 {
00100   ACE_GUARD(ACE_Thread_Mutex, g, lock_);
00101   transport_config_ = cfg;
00102 }
00103 
00104 TransportConfig_rch
00105 EntityImpl::transport_config() const
00106 {
00107   ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, TransportConfig_rch());
00108   return transport_config_;
00109 }
00110 
00111 } // namespace DCPS
00112 } // namespace OpenDDS
00113 
00114 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1