44 std::unique_ptr<NEMLayerStack> & pNEMLayerStack,
45 bool bExternalTransport):
46 pNEMLayerStack_(
std::move(pNEMLayerStack)),
48 bExternalTransport_{bExternalTransport},
50 NEMNetworkAdapter_{
id}
52 pNEMLayerStack_->connectLayers(&NEMNetworkAdapter_,&NEMOTAAdapter_);
59 if(bExternalTransport_)
66 "IPv4 or IPv6 NEM Platform Service endpoint.");
68 configRegistrar.registerNonNumeric<
INETAddr>(
"transportendpoint",
71 "IPv4 or IPv6 Transport endpoint.");
73 configRegistrar.registerNonNumeric<std::string>(
"protocol",
76 "Defines the protocl used for communictation:" 83 pNEMLayerStack_->initialize(registrar);
88 for(
const auto & item : update)
90 if(item.first ==
"platformendpoint")
92 platformEndpointAddr_ = item.second[0].asINETAddr();
96 "NEM %03hu NEMImpl::configure platformendpoint: %s",
98 platformEndpointAddr_.
str().c_str());
101 else if(item.first ==
"transportendpoint")
103 transportEndpointAddr_ = item.second[0].asINETAddr();
107 "NEM %03hu NEMImpl::configure transportendpoint: %s",
109 transportEndpointAddr_.
str().c_str());
111 else if(item.first ==
"protocol")
113 std::string sProtocol{item.second[0].asString()};
115 protocol_ = sProtocol ==
"udp" ?
121 "NEM %03hu NEMImpl::configure %s: %s",
128 throw makeException<ConfigureException>(
"NEMImpl::configure: " 129 "Unexpected configuration item %s",
137 NEMOTAAdapter_.
open();
139 if(bExternalTransport_)
143 NEMNetworkAdapter_.
open(platformEndpointAddr_,
144 transportEndpointAddr_,
153 pNEMLayerStack_->start();
158 pNEMLayerStack_->postStart();
163 if(bExternalTransport_)
165 NEMNetworkAdapter_.
close();
168 NEMOTAAdapter_.
close();
170 pNEMLayerStack_->stop();
176 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)
void open(const INETAddr &localAddress, const INETAddr &remoteAddress, Protocol protocol)
Exception thrown during open/establishment of network adapter connection.
const char * what() const
std::string str(bool bWithPort=true) const
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()