本文整理汇总了C++中boost::optional::is_initialized方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::is_initialized方法的具体用法?C++ optional::is_initialized怎么用?C++ optional::is_initialized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::is_initialized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator ()(Shuttler& shuttle, const boost::optional<T>& value,
unsigned int version) const {
shuttle.Shuttle("is_initialized", value.is_initialized());
if(value.is_initialized()) {
shuttle.Shuttle("value", *value);
}
}
示例2: ReplaceIndexesInTemplate
std::string OCLKernelBase::ReplaceIndexesInTemplate(const std::string& tmpl, boost::optional<int> inputIndex, boost::optional<int> layerIndex)
{
string result = tmpl;
if (inputIndex.is_initialized()) boost::replace_all(result, "{i}", to_string(inputIndex.get()));
if (layerIndex.is_initialized()) boost::replace_all(result, "{l}", to_string(layerIndex.get()));
return result;
}
示例3: VRPNAnalogHandler
VRPNAnalogHandler(vrpn_ConnectionPtr const &conn, const char *src,
boost::optional<int> sensor,
common::InterfaceList &ifaces)
: m_remote(new vrpn_Analog_Remote(src, conn.get())),
m_interfaces(ifaces), m_all(!sensor.is_initialized()) {
m_remote->register_change_handler(this, &VRPNAnalogHandler::handle);
OSVR_DEV_VERBOSE("Constructed an AnalogHandler for " << src);
if (sensor.is_initialized()) {
m_sensors.setValue(*sensor);
}
}
示例4: flush
Status FTDCFileWriter::flush(const boost::optional<ConstDataRange>& range, Date_t date) {
if (!range.is_initialized()) {
if (_compressor.hasDataToFlush()) {
auto swBuf = _compressor.getCompressedSamples();
if (!swBuf.isOK()) {
return swBuf.getStatus();
}
BSONObj o = FTDCBSONUtil::createBSONMetricChunkDocument(std::get<0>(swBuf.getValue()),
std::get<1>(swBuf.getValue()));
Status s = writeArchiveFileBuffer({o.objdata(), static_cast<size_t>(o.objsize())});
if (!s.isOK()) {
return s;
}
}
} else {
BSONObj o = FTDCBSONUtil::createBSONMetricChunkDocument(range.get(), date);
Status s = writeArchiveFileBuffer({o.objdata(), static_cast<size_t>(o.objsize())});
if (!s.isOK()) {
return s;
}
}
boost::filesystem::remove(_interimFile);
return Status::OK();
}
示例5: getTransactionHash
Hash TransactionImpl::getTransactionHash() const {
if (!transactionHash.is_initialized()) {
transactionHash = getObjectHash(transaction);
}
return transactionHash.get();
}
示例6: CheckNextEvent
/*
* Check that next received event contains specific values.
*
* @param key Key.
* @param oldVal Old value.
* @param val Current value.
*/
void CheckNextEvent(const K& key, boost::optional<V> oldVal, boost::optional<V> val)
{
CacheEntryEvent<K, V> event;
bool success = eventQueue.Pull(event, boost::chrono::seconds(1));
BOOST_REQUIRE(success);
BOOST_CHECK_EQUAL(event.GetKey(), key);
BOOST_CHECK_EQUAL(event.HasOldValue(), oldVal.is_initialized());
BOOST_CHECK_EQUAL(event.HasValue(), val.is_initialized());
if (oldVal && event.HasOldValue())
BOOST_CHECK_EQUAL(event.GetOldValue().value, oldVal->value);
if (val && event.HasValue())
BOOST_CHECK_EQUAL(event.GetValue().value, val->value);
}
示例7:
void SetIfInitialized( boost::log::settings& settings,
const std::string& label,
boost::optional<const std::string&> value )
{
if( value.is_initialized() )
{
settings[label] = value.get();
}
}
示例8: save
void save(
Archive & ar,
const boost::optional<T> & t,
const unsigned int /*version*/
){
const bool tflag = t.is_initialized();
ar << boost::serialization::make_nvp("initialized", tflag);
if (tflag){
if(3 < ar.get_library_version()){
const int v = version<T>::value;
ar << boost::serialization::make_nvp("item_version", v);
}
ar << boost::serialization::make_nvp("value", *t);
}
}
示例9: ConnectToService
bool C1WireForWindows::IsAvailable()
{
#ifdef _DEBUG
return false;
#endif
static boost::optional<bool> IsAvailable;
if (IsAvailable.is_initialized())
return IsAvailable.get();
// Make a connection only to know if 1-wire is avalaible
SOCKET theSocket = ConnectToService();
if (theSocket == INVALID_SOCKET)
{
IsAvailable=false;
return false;
}
// Request
Json::Value reqRoot;
reqRoot["IsAvailable"]="";
Json::FastWriter writer;
// Send request and wait for answer
std::string answer = ::SendAndReceive(theSocket,writer.write(reqRoot));
// Answer processing
if (answer.empty())
{
IsAvailable=false;
DisconnectFromService(theSocket);
return false;
}
Json::Value ansRoot;
Json::Reader reader;
if (!reader.parse(answer,ansRoot))
{
IsAvailable=false;
DisconnectFromService(theSocket);
return false;
}
DisconnectFromService(theSocket);
IsAvailable=ansRoot.get("Available",false).asBool();
return IsAvailable.get();
}
示例10: validate
void validate(boost::optional<ConstDataRange> cdr) {
std::vector<BSONObj> list;
if (cdr.is_initialized()) {
auto sw = _decompressor.uncompress(cdr.get());
ASSERT_TRUE(sw.isOK());
list = sw.getValue();
} else {
auto swBuf = _compressor.getCompressedSamples();
ASSERT_TRUE(swBuf.isOK());
auto sw = _decompressor.uncompress(std::get<0>(swBuf.getValue()));
ASSERT_TRUE(sw.isOK());
list = sw.getValue();
}
ValidateDocumentList(list, _docs);
}
示例11: receiveLocalizations
void ProgressMeter::receiveLocalizations(const EngineResult& er)
{
if ( er.forImage+1*camera::frame > max ) {
max = er.forImage+1*camera::frame;
DEBUG("Progress at " << max);
if ( length.is_initialized() ) {
boost::units::quantity<camera::time,float>
diff = (max - first);
DEBUG("Diff is " << diff);
float ratio = diff / *length;
DEBUG("Ratio is " << ratio << " at progress " << progress());
progress.setValue( std::min( round(ratio / 0.01), 99.0 ) * 0.01 );
} else {
progress.setValue( (er.forImage / (10*camera::frame)) % 100 / 100.0 );
}
}
}
示例12: process
void Remote::process(const Coordinate & pos, boost::optional<floatCoordinate> normal) {
//distance vector
floatCoordinate deltaPos = pos - state->viewerState->currentPosition;
const float jumpThreshold = 0.5f * Dataset::current().cubeEdgeLength * state->M * Dataset::current().magnification;//approximately inside sc
if (deltaPos.length() > jumpThreshold) {
state->viewer->setPosition(pos);
} else if (pos != state->viewerState->currentPosition) {
rotate = normal.is_initialized();
normal = normal.get_value_or({});
targetPos = pos;
recenteringOffset = pos - state->viewerState->currentPosition;
elapsed.restart();
timer.start(ms);
state->viewer->userMoveClear();
remoteWalk();
}
}
示例13: NetworkDirectionRemoteHandler
NetworkDirectionRemoteHandler(vrpn_ConnectionPtr const &conn,
std::string const &deviceName,
boost::optional<OSVR_ChannelCount> sensor,
common::InterfaceList &ifaces)
: m_dev(common::createClientDevice(deviceName, conn)),
m_internals(ifaces), m_all(!sensor.is_initialized()),
m_sensor(sensor) {
auto direction = common::DirectionComponent::create();
m_dev->addComponent(direction);
direction->registerDirectionHandler(
[&](common::DirectionData const &data,
util::time::TimeValue const ×tamp) {
m_handleDirection(data, timestamp);
});
OSVR_DEV_VERBOSE("Constructed an Direction Handler for "
<< deviceName);
}
示例14: add
/**
* Add a new entry in the Link Responde Pool.
*
* @param user MIH source identifier.
* @param tid The transaction identifier.
* @param link_scan_rsp_list The link scan response list.
* @param link_ac_result The link action result
*/
void link_response_pool::add(mih::octet_string user,
uint16 tid,
boost::optional<mih::link_scan_rsp_list> link_scan_rsp_list,
mih::link_ac_result link_ac_result)
{
pending_link_response p;
p.user.assign(user);
p.tid = tid;
action ac;
if(link_scan_rsp_list.is_initialized()) {
ac.link_scan_rsp_list = link_scan_rsp_list;
}
ac.link_ac_result = link_ac_result;
p.response = ac;
boost::mutex::scoped_lock lock(_mutex);
_cpool.push_back(p);
}
示例15: UpdateTextureFilters
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
void TextureManager::UpdateTextureFilters(boost::optional<TextureFilterMode> oldMode)
{
#ifdef GLEW_EXT_texture_filter_anisotropic
GLfloat aniLevelVal(0.0f);
if(m_currTexFilterMode == eAnisotropic)
{
aniLevelVal = InterpolateFloat(m_anisotropicLinearLevel, 0.0f, m_maxAnisotropicValue);
}
#endif
GF_CLEAR_GL_ERROR();
for(ElementMap::iterator i = m_elementsMap.begin(), end = m_elementsMap.end(); i != end; ++i)
{
GLenum currTarget(((*i).second).m_glTarget);
if(currTarget != GL_TEXTURE_RECTANGLE)
{
Bind(((*i).second).m_id, currTarget);
glTexParameteri(currTarget, GL_TEXTURE_MIN_FILTER, m_currMinFilter);
GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
glTexParameteri(currTarget, GL_TEXTURE_MAG_FILTER, m_currMagFilter);
GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
#ifdef GLEW_EXT_texture_filter_anisotropic
if(m_currTexFilterMode == eAnisotropic)
{
glTexParameterf(currTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniLevelVal);
GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
}
else if(oldMode.is_initialized() && *oldMode == eAnisotropic)
{
// Turn down ani level if we are switching away from it.
glTexParameterf(currTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0.0f);
GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
}
#endif
}
}
}