示例#1
0
 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
0
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;
}
        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
0
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
0
  Hash TransactionImpl::getTransactionHash() const {
    if (!transactionHash.is_initialized()) {
      transactionHash = getObjectHash(transaction);
    }

    return transactionHash.get();   
  }
    /*
     * 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
0
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
0
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
0
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
0
    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
0
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
0
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
0
 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 &timestamp) {
             m_handleDirection(data, timestamp);
         });
     OSVR_DEV_VERBOSE("Constructed an Direction Handler for "
                      << deviceName);
 }
示例#14
0
/**
 * 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
0
	// /////////////////////////////////////////////////////////////////
	//
	// /////////////////////////////////////////////////////////////////
	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
			}
		}
	}
示例#16
0
void save(
    Archive & ar,
    const boost::optional< T > & t,
    const unsigned int /*version*/
){
    // It is an inherent limitation to the serialization of optional.hpp
    // that the underlying type must be either a pointer or must have a
    // default constructor.  It's possible that this could change sometime
    // in the future, but for now, one will have to work around it.  This can
    // be done by serialization the optional<T> as optional<T *>
    #if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
        BOOST_STATIC_ASSERT(
            boost::serialization::detail::is_default_constructible<T>::value
            || boost::is_pointer<T>::value
        );
    #endif
    const bool tflag = t.is_initialized();
    ar << boost::serialization::make_nvp("initialized", tflag);
    if (tflag){
        ar << boost::serialization::make_nvp("value", *t);
    }
}
示例#17
0
void set(const std::string& name,
         const std::string& value,
         const http::Request& request,
         const boost::posix_time::time_duration& validDuration,
         const boost::optional<boost::gregorian::days>& cookieExpiresDays,
         const std::string& path,
         http::Response* pResponse)
{
   // create secure cookie
   http::Cookie cookie = createSecureCookie(name,
                                            value,
                                            request,
                                            validDuration,
                                            path);

   // expire from browser as requested
   if (cookieExpiresDays.is_initialized())
      cookie.setExpires(*cookieExpiresDays);

   // add to response
   pResponse->addCookie(cookie);
}
示例#18
0
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){
        const boost::serialization::item_version_type item_version(version< T >::value);
        #if 0
        const boost::archive::library_version_type library_version(
            ar.get_library_version()
        };
        if(boost::archive::library_version_type(3) < library_version){
            ar << BOOST_SERIALIZATION_NVP(item_version);
        }
        #else
            ar << BOOST_SERIALIZATION_NVP(item_version);
        #endif
        ar << boost::serialization::make_nvp("value", *t);
    }
}
示例#19
0
 void TransactionImpl::invalidateHash() {
   if (transactionHash.is_initialized()) {
     transactionHash = decltype(transactionHash)();
   }
 }
示例#20
0
 ref_t dereference() const
 {
     BOOST_ASSERT(m_state.is_initialized());
     return *m_state;
 }
示例#21
0
 void increment()
 {
     BOOST_ASSERT(m_state.is_initialized());
     m_state = m_next(m_state.get());
 }
示例#22
0
 bool more() const { return g.is_initialized(); }
示例#23
0
 bool is_end() const
 {
     return !m_state.is_initialized();
 }
示例#24
0
文件: Flag.cpp 项目: zillians/mud
void add_option_string_optional(Flag* flag, const std::wstring& key, const boost::optional<std::wstring>& value)
{
	flag->addOption(key, value.is_initialized() ? new FlagOption(*value) : new FlagOption());
}