ShmemInst.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "ShmemInst.h"
00009 #include "ShmemLoader.h"
00010
00011 #include "ace/Configuration.h"
00012 #include "ace/OS_NS_unistd.h"
00013
00014 #include "dds/DCPS/transport/framework/NetworkAddress.h"
00015
00016 #include <iostream>
00017 #include <sstream>
00018
00019 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 namespace OpenDDS {
00022 namespace DCPS {
00023
00024 ShmemInst::ShmemInst(const std::string& name)
00025 : TransportInst("shmem", name)
00026 , pool_size_(16 * 1024 * 1024)
00027 , datalink_control_size_(4 * 1024)
00028 , hostname_(get_fully_qualified_hostname())
00029 {
00030 std::ostringstream pool;
00031 pool << "OpenDDS-" << ACE_OS::getpid() << '-' << this->name();
00032 poolname_ = pool.str();
00033
00034 }
00035
00036 TransportImpl_rch
00037 ShmemInst::new_impl()
00038 {
00039 return make_rch<ShmemTransport>(ref(*this));
00040 }
00041
00042 int
00043 ShmemInst::load(ACE_Configuration_Heap& cf,
00044 ACE_Configuration_Section_Key& sect)
00045 {
00046 TransportInst::load(cf, sect);
00047
00048 GET_CONFIG_VALUE(cf, sect, ACE_TEXT("pool_size"), pool_size_, size_t)
00049 GET_CONFIG_VALUE(cf, sect, ACE_TEXT("datalink_control_size"),
00050 datalink_control_size_, size_t)
00051 return 0;
00052 }
00053
00054 OPENDDS_STRING
00055 ShmemInst::dump_to_str() const
00056 {
00057 std::ostringstream os;
00058 os << TransportInst::dump_to_str() << std::endl;
00059 os << formatNameForDump("pool_size") << pool_size_ << "\n"
00060 << formatNameForDump("datalink_control_size") << datalink_control_size_
00061 << std::endl;
00062 return OPENDDS_STRING(os.str());
00063 }
00064
00065 size_t
00066 ShmemInst::populate_locator(OpenDDS::DCPS::TransportLocator& info) const
00067 {
00068 info.transport_type = "shmem";
00069
00070 const size_t len = hostname_.size() + 1 + poolname_.size();
00071 info.data.length(static_cast<CORBA::ULong>(len));
00072
00073 CORBA::Octet* buff = info.data.get_buffer();
00074 std::memcpy(buff, hostname_.c_str(), hostname_.size());
00075 buff += hostname_.size();
00076
00077 *(buff++) = 0;
00078 std::memcpy(buff, poolname_.c_str(), poolname_.size());
00079
00080 return 1;
00081 }
00082
00083 }
00084 }
00085
00086 OPENDDS_END_VERSIONED_NAMESPACE_DECL