本文整理汇总了C++中ControlParameters::getFlagBit方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlParameters::getFlagBit方法的具体用法?C++ ControlParameters::getFlagBit怎么用?C++ ControlParameters::getFlagBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlParameters
的用法示例。
在下文中一共展示了ControlParameters::getFlagBit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
updateLinkServiceOptions(Face& face, const ControlParameters& parameters)
{
auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
if (linkService == nullptr) {
return;
}
auto options = linkService->getOptions();
if (parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
face.getScope() == ndn::nfd::FACE_SCOPE_LOCAL) {
options.allowLocalFields = parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED);
}
if (parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)) {
options.reliabilityOptions.isEnabled = parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED);
}
if (parameters.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)) {
options.allowCongestionMarking = parameters.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED);
}
if (parameters.hasBaseCongestionMarkingInterval()) {
options.baseCongestionMarkingInterval = parameters.getBaseCongestionMarkingInterval();
}
if (parameters.hasDefaultCongestionThreshold()) {
options.defaultCongestionThreshold = parameters.getDefaultCongestionThreshold();
}
linkService->setOptions(options);
}
示例2: makeCreateFaceResponse
void
FaceManager::afterCreateFaceSuccess(const shared_ptr<Face>& face,
const ControlParameters& parameters,
const ndn::mgmt::CommandContinuation& done)
{
if (face->getId() != face::INVALID_FACEID) { // Face already exists
NFD_LOG_TRACE("Attempted to create duplicate face of " << face->getId());
ControlParameters response = makeCreateFaceResponse(*face);
done(ControlResponse(409, "Face with remote URI already exists").setBody(response.wireEncode()));
return;
}
// If scope non-local and flags set to enable local fields, request shouldn't
// have made it this far
BOOST_ASSERT(face->getScope() == ndn::nfd::FACE_SCOPE_LOCAL ||
!parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) ||
(parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
!parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)));
m_faceTable.add(face);
ControlParameters response = makeCreateFaceResponse(*face);
done(ControlResponse(200, "OK").setBody(response.wireEncode()));
}
示例3: done
void
FaceManager::createFace(const ControlParameters& parameters,
const ndn::mgmt::CommandContinuation& done)
{
FaceUri remoteUri;
if (!remoteUri.parse(parameters.getUri())) {
NFD_LOG_TRACE("failed to parse remote URI: " << parameters.getUri());
done(ControlResponse(400, "Malformed command"));
return;
}
if (!remoteUri.isCanonical()) {
NFD_LOG_TRACE("received non-canonical remote URI: " << remoteUri.toString());
done(ControlResponse(400, "Non-canonical remote URI"));
return;
}
optional<FaceUri> localUri;
if (parameters.hasLocalUri()) {
localUri = FaceUri{};
if (!localUri->parse(parameters.getLocalUri())) {
NFD_LOG_TRACE("failed to parse local URI: " << parameters.getLocalUri());
done(ControlResponse(400, "Malformed command"));
return;
}
if (!localUri->isCanonical()) {
NFD_LOG_TRACE("received non-canonical local URI: " << localUri->toString());
done(ControlResponse(400, "Non-canonical local URI"));
return;
}
}
face::ProtocolFactory* factory = m_faceSystem.getFactoryByScheme(remoteUri.getScheme());
if (factory == nullptr) {
NFD_LOG_TRACE("received create request for unsupported protocol: " << remoteUri.getScheme());
done(ControlResponse(406, "Unsupported protocol"));
return;
}
face::FaceParams faceParams;
faceParams.persistency = parameters.getFacePersistency();
if (parameters.hasBaseCongestionMarkingInterval()) {
faceParams.baseCongestionMarkingInterval = parameters.getBaseCongestionMarkingInterval();
}
if (parameters.hasDefaultCongestionThreshold()) {
faceParams.defaultCongestionThreshold = parameters.getDefaultCongestionThreshold();
}
if (parameters.hasMtu()) {
faceParams.mtu = parameters.getMtu();
}
faceParams.wantLocalFields = parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED);
faceParams.wantLpReliability = parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED) &&
parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED);
if (parameters.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)) {
faceParams.wantCongestionMarking = parameters.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED);
}
try {
factory->createFace({remoteUri, localUri, faceParams},
[this, parameters, done] (const auto& face) {
this->afterCreateFaceSuccess(face, parameters, done);
},
[done] (uint32_t status, const std::string& reason) {
NFD_LOG_DEBUG("Face creation failed: " << reason);
done(ControlResponse(status, reason));
});
}
catch (const std::runtime_error& error) {
NFD_LOG_ERROR("Face creation failed: " << error.what());
done(ControlResponse(500, "Face creation failed due to internal error"));
return;
}
catch (const std::logic_error& error) {
NFD_LOG_ERROR("Face creation failed: " << error.what());
done(ControlResponse(500, "Face creation failed due to internal error"));
return;
}
}