43 std::unique_ptr<NEMLayerStack> & pNEMLayerStack,
44 bool bExternalTransport):
45 pNEMLayerStack_(
std::move(pNEMLayerStack)),
47 bExternalTransport_{bExternalTransport},
49 NEMNetworkAdapter_{
id}
51 pNEMLayerStack_->connectLayers(&NEMNetworkAdapter_,&NEMOTAAdapter_);
58 if(bExternalTransport_)
65 "IPv4 or IPv6 NEM Platform Service endpoint.");
67 configRegistrar.registerNonNumeric<
INETAddr>(
"transportendpoint",
70 "IPv4 or IPv6 Transport endpoint.");
73 pNEMLayerStack_->initialize(registrar);
78 for(
const auto & item : update)
80 if(item.first ==
"platformendpoint")
82 platformEndpointAddr_ = item.second[0].asINETAddr();
86 "NEM %03hu NEMImpl::configure platformendpoint: %s",
88 platformEndpointAddr_.
str().c_str());
91 else if(item.first ==
"transportendpoint")
93 transportEndpointAddr_ = item.second[0].asINETAddr();
97 "NEM %03hu NEMImpl::configure transportendpoint: %s",
99 transportEndpointAddr_.
str().c_str());
103 throw makeException<ConfigureException>(
"NEMImpl::configure: " 104 "Unexpected configuration item %s",
112 NEMOTAAdapter_.
open();
114 if(bExternalTransport_)
118 NEMNetworkAdapter_.
open(platformEndpointAddr_,transportEndpointAddr_);
126 pNEMLayerStack_->start();
131 pNEMLayerStack_->postStart();
136 if(bExternalTransport_)
138 NEMNetworkAdapter_.
close();
141 NEMOTAAdapter_.
close();
143 pNEMLayerStack_->stop();
149 pNEMLayerStack_->destroy();
void postStart() override
The Registrar interface provides access to all of the emulator registrars.
NEMId getNEMId() const override
virtual ConfigurationRegistrar & configurationRegistrar()=0
void registerNonNumeric(const std::string &sName, const ConfigurationProperties &properties=ConfigurationProperties::NONE, const std::initializer_list< T > &values={}, const std::string &sUsage="", std::size_t minOccurs=1, std::size_t maxOccurs=1, const std::string &sRegexPattern={})
NEMImpl(NEMId id, std::unique_ptr< NEMLayerStack > &pNEMLayerStack, bool bExternalTransport)
Exception thrown during open/establishment of network adapter connection.
const char * what() const
std::string str(bool bWithPort=true) const
void open(const INETAddr &localAddress, const INETAddr &remoteAddress)
void initialize(Registrar ®istrar) override
Component start exception is used to indicate an exception during transition to the start state...
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
void configure(const ConfigurationUpdate &update) override
#define LOGGER_STANDARD_LOGGING(logger, level, fmt, args...)
static LogService * instance()