DataLinkSet.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
00009 #include "DataLinkSet.h"
00010 #include "DataLinkSet_rch.h"
00011 
00012 #include "dds/DCPS/GuidConverter.h"
00013 #include "dds/DCPS/Util.h"
00014 #include "TransportImpl.h"
00015 #include "TransportSendListener.h"
00016 
00017 #include "EntryExit.h"
00018 
00019 #if !defined (__ACE_INLINE__)
00020 #include "DataLinkSet.inl"
00021 #endif /* __ACE_INLINE__ */
00022 
00023 //TBD: The number of chunks in send control cached allocator and map
00024 //     entry allocator are hard coded for now. These values will be
00025 //     configured when we implement the dds configurations.
00026 
00027 /// The number of chuncks in send control cached allocator per pub/sub.
00028 #define NUM_SEND_CONTROL_ELEMENT_CHUNKS 20
00029 
00030 OpenDDS::DCPS::DataLinkSet::DataLinkSet()
00031   : send_control_element_allocator_(NUM_SEND_CONTROL_ELEMENT_CHUNKS)
00032   , send_response_listener_("DataLinkSet")
00033 {
00034   DBG_ENTRY_LVL("DataLinkSet","DataLinkSet",6);
00035 
00036   if (OpenDDS::DCPS::Transport_debug_level > 3) {
00037     ACE_DEBUG((LM_DEBUG, "(%P|%t) DataLinkSet send_control_element_allocator %x with %d chunks\n",
00038                &send_control_element_allocator_, NUM_SEND_CONTROL_ELEMENT_CHUNKS));
00039   }
00040 }
00041 
00042 OpenDDS::DCPS::DataLinkSet::~DataLinkSet()
00043 {
00044   DBG_ENTRY_LVL("DataLinkSet","~DataLinkSet",6);
00045 }
00046 
00047 int
00048 OpenDDS::DCPS::DataLinkSet::insert_link(DataLink* link)
00049 {
00050   DBG_ENTRY_LVL("DataLinkSet","insert_link",6);
00051   DataLink_rch mylink(link, false);
00052   GuardType guard(this->lock_);
00053   return OpenDDS::DCPS::bind(map_, mylink->id(), mylink);
00054 }
00055 
00056 void
00057 OpenDDS::DCPS::DataLinkSet::remove_link(const DataLink_rch& link)
00058 {
00059   DBG_ENTRY_LVL("DataLinkSet", "remove_link", 6);
00060   GuardType guard1(this->lock_);
00061   if (unbind(map_, link->id()) != 0) {
00062     // Just report to the log that we tried.
00063     VDBG((LM_DEBUG,
00064           ACE_TEXT("(%P|%t) DataLinkSet::remove_links: ")
00065           ACE_TEXT("link_id %d not found in map.\n"),
00066           link->id()));
00067   }
00068 }
00069 
00070 OpenDDS::DCPS::DataLinkSet*
00071 OpenDDS::DCPS::DataLinkSet::select_links(const RepoId* remoteIds,
00072                                          const CORBA::ULong num_targets)
00073 {
00074   DBG_ENTRY_LVL("DataLinkSet","select_links",6);
00075 
00076   DataLinkSet_rch selected_links = new DataLinkSet();
00077   GuardType guard(this->lock_);
00078   for (MapType::iterator itr = map_.begin();
00079        itr != map_.end();
00080        ++itr) {
00081     for (CORBA::ULong i = 0; i < num_targets; ++i) {
00082       if (itr->second->is_target(remoteIds[i])) {
00083         OpenDDS::DCPS::bind(selected_links->map_,
00084              itr->second->id(), itr->second);
00085         break;
00086       }
00087     }
00088   }
00089 
00090   return selected_links._retn();
00091 }
00092 
00093 bool
00094 OpenDDS::DCPS::DataLinkSet::empty()
00095 {
00096   GuardType guard(this->lock_);
00097 
00098   return map_.empty();
00099 }

Generated on Fri Feb 12 20:05:19 2016 for OpenDDS by  doxygen 1.4.7