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