当前位置: 首页>>代码示例>>C++>>正文


C++ boost::optional类代码示例

本文整理汇总了C++中boost::optional的典型用法代码示例。如果您正苦于以下问题:C++ optional类的具体用法?C++ optional怎么用?C++ optional使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了optional类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NetworkImagingRemoteHandler

 NetworkImagingRemoteHandler(vrpn_ConnectionPtr const &conn,
                             std::string const &deviceName,
                             boost::optional<OSVR_ChannelCount> sensor,
                             common::InterfaceList &ifaces)
     : m_dev(common::createClientDevice(deviceName, conn)),
       m_interfaces(ifaces), m_all(!sensor.is_initialized()),
       m_sensor(sensor) {
     auto imaging = common::ImagingComponent::create();
     m_dev->addComponent(imaging);
     imaging->registerImageHandler(
         [&](common::ImageData const &data,
             util::time::TimeValue const &timestamp) {
             m_handleImage(data, timestamp);
         });
     OSVR_DEV_VERBOSE("Constructed an ImagingHandler for "
                      << deviceName);
 }
开发者ID:jimbo00000,项目名称:OSVR-Core,代码行数:17,代码来源:ImagingRemoteFactory.cpp

示例2: evaluate

    /**
     * This method evaluates the path at a given time and returns the target
     * position and velocity of the robot.
     *
     * @param t Time (in seconds) since the robot started the path. Throws an
     *     exception if t<0
     * @return A MotionInstant containing the position and velocity at the given
     *     time if @t is within the range of the path.  If @t is not within the
     *     time range of this path, this method returns boost::none.
     */
    virtual boost::optional<RobotInstant> evaluate(
        RJ::Seconds t) const override {
        if (!path) {
            return boost::none;
        }

        boost::optional<RobotInstant> instant = path->evaluate(t);
        if (!angleFunction) {
            return instant;
        } else {
            if (instant) {
                instant->angle = angleFunction->operator()(instant->motion);
                return instant;
            } else {
                return boost::none;
            }
        }
    }
开发者ID:echin98,项目名称:robocup-software,代码行数:28,代码来源:Path.hpp

示例3: parse_bbox

osmium::Box parse_osmium_t::parse_bbox(const boost::optional<std::string> &bbox)
{
    double minx, maxx, miny, maxy;
    int n = sscanf(bbox->c_str(), "%lf,%lf,%lf,%lf",
                   &minx, &miny, &maxx, &maxy);
    if (n != 4)
        throw std::runtime_error("Bounding box must be specified like: minlon,minlat,maxlon,maxlat\n");

    if (maxx <= minx)
        throw std::runtime_error("Bounding box failed due to maxlon <= minlon\n");

    if (maxy <= miny)
        throw std::runtime_error("Bounding box failed due to maxlat <= minlat\n");

    fprintf(stderr, "Applying Bounding box: %f,%f to %f,%f\n", minx, miny, maxx, maxy);

    return osmium::Box(minx, miny, maxx, maxy);
}
开发者ID:tomhughes,项目名称:osm2pgsql,代码行数:18,代码来源:parse-osmium.cpp

示例4: installNewBattleInterface

void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback)
{
	boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
	PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);

	if(!color)
		privilegedBattleEventReceivers.push_back(battleInterface);

	battleints[colorUsed] = battleInterface;

	if(needCallback)
	{
		logGlobal->trace("\tInitializing the battle interface for player %s", *color);
		auto cbc = std::make_shared<CBattleCallback>(color, this);
		battleCallbacks[colorUsed] = cbc;
		battleInterface->init(cbc);
	}
}
开发者ID:vcmi,项目名称:vcmi,代码行数:18,代码来源:Client.cpp

示例5: installNewPlayerInterface

void CClient::installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color, bool battlecb)
{
	boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
	PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);

	if(!color)
		privilegedGameEventReceivers.push_back(gameInterface);

	playerint[colorUsed] = gameInterface;

	logGlobal->trace("\tInitializing the interface for player %s", colorUsed);
	auto cb = std::make_shared<CCallback>(gs, color, this);
	callbacks[colorUsed] = cb;
	battleCallbacks[colorUsed] = cb;
	gameInterface->init(cb);

	installNewBattleInterface(gameInterface, color, battlecb);
}
开发者ID:vcmi,项目名称:vcmi,代码行数:18,代码来源:Client.cpp

示例6: transactionFromSQL

Transaction::pointer Transaction::transactionFromSQL (
    boost::optional<std::uint64_t> const& ledgerSeq,
    boost::optional<std::string> const& status,
    Blob const& rawTxn,
    Validate validate)
{
    std::uint32_t const inLedger =
        rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or (0));

    SerialIter it (makeSlice(rawTxn));
    auto txn = std::make_shared<STTx> (it);
    std::string reason;
    auto tr = std::make_shared<Transaction> (txn, validate, reason);

    tr->setStatus (sqlTransactionStatus (status));
    tr->setLedger (inLedger);
    return tr;
}
开发者ID:referjs,项目名称:rippled,代码行数:18,代码来源:Transaction.cpp

示例7: 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);
}
开发者ID:ATNoG,项目名称:EMICOM,代码行数:27,代码来源:link_response_pool.cpp

示例8: setPeopleperSpaceFloorArea

 bool PeopleDefinition_Impl::setPeopleperSpaceFloorArea(boost::optional<double> peopleperSpaceFloorArea) {
   bool result = false;
   if (peopleperSpaceFloorArea) {
     result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea,peopleperSpaceFloorArea.get());
     if (result) {
       result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "People/Area");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::NumberofPeople, "");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::SpaceFloorAreaperPerson, "");
       OS_ASSERT(result);                
     }      
   } else {
     if (istringEqual("People/Area", this->numberofPeopleCalculationMethod())){
       result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea, 0.0);
     }
   }
   return result;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:19,代码来源:PeopleDefinition.cpp

示例9: setSpaceFloorAreaperPerson

 bool PeopleDefinition_Impl::setSpaceFloorAreaperPerson(boost::optional<double> spaceFloorAreaperPerson) {
   bool result(false);
   if (spaceFloorAreaperPerson) {
     result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson,spaceFloorAreaperPerson.get());
     if (result) {
       result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "Area/Person");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::NumberofPeople, "");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::PeopleperSpaceFloorArea, "");
       OS_ASSERT(result);      
     }
   } else {
     if (istringEqual("Area/Person", this->numberofPeopleCalculationMethod())){
       result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson, 0.0);
     }
   }
   return result;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:19,代码来源:PeopleDefinition.cpp

示例10: appendAsCommand

void CommitChunkMigrationRequest::appendAsCommand(
    BSONObjBuilder* builder,
    const NamespaceString& nss,
    const ShardId& fromShard,
    const ShardId& toShard,
    const ChunkType& migratedChunkType,
    const boost::optional<ChunkType>& controlChunkType) {
    invariant(builder->asTempObj().isEmpty());
    invariant(nss.isValid());

    builder->append(kConfigSvrCommitChunkMigration, nss.ns());
    builder->append(kFromShard, fromShard.toString());
    builder->append(kToShard, toShard.toString());
    builder->append(kMigratedChunk, migratedChunkType.toBSON());

    if (controlChunkType) {
        builder->append(kControlChunk, controlChunkType->toBSON());
    }
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:19,代码来源:commit_chunk_migration_request_type.cpp

示例11: createJacobianAssembler

std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler(
    boost::optional<BaseLib::ConfigTree> const& config)
{
    if (!config)
        return std::unique_ptr<AbstractJacobianAssembler>(
            new AnalyticalJacobianAssembler);

    //! \ogs_file_param{process__jacobian_assembler__type}
    auto const type = config->peekConfigParameter<std::string>("type");

    if (type == "Analytical") {
        config->ignoreConfigParameter("type");
        return std::unique_ptr<AbstractJacobianAssembler>(
            new AnalyticalJacobianAssembler);
    } else if (type == "CentralDifferences") {
        return createCentralDifferencesJacobianAssembler(*config);
    }

    OGS_FATAL("Unknown Jacobian assembler type: `%s'.", type.c_str());
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例12: display_template_info

void display_template_info(const Glib::RefPtr<Gst::PadTemplate> &tpl,
                           const Glib::RefPtr<Gtk::TreeStore> &model, const Gtk::TreeModelColumn<Glib::ustring> &col_name,
                           const Gtk::TreeModelColumn<Glib::ustring> &col_value, boost::optional<const Gtk::TreeModel::Row&> parent_row)
{
    Gtk::TreeRow row;
    if (parent_row)
    {
        row = APPEND_SUB_ROW(_("Template"), tpl->get_name_template(), parent_row.get());
    }
    else
    {
        row = *(model->append());
        row[col_name] = _("Template");
        row[col_value] = tpl->get_name_template();
    }
    APPEND_SUB_ROW(_("Presence"), get_presence_str(tpl->get_presence()), row);
    APPEND_SUB_ROW(_("Direction"), get_direction_str(tpl->get_direction()), row);
    row = APPEND_SUB_ROW("Caps", "", row);
    display_caps(tpl->get_caps(), model, col_name, col_value, row);
}
开发者ID:GNOME,项目名称:gst-debugger,代码行数:20,代码来源:ui_utils.cpp

示例13: dataFrameTest

  void dataFrameTest(IOBuf* body, uint32_t dataLen,
                     boost::optional<uint8_t> padLen) {
    uint32_t frameLen = uint32_t(dataLen);
    if (padLen) {
      frameLen += 1 + padLen.get();
    }
    if (frameLen > kMaxFramePayloadLength) {
      EXPECT_DEATH_NO_CORE(writeData(queue_, body->clone(), 1, padLen,
                                     false), ".*");
    } else {
      writeData(queue_, body->clone(), 1, padLen, false);

      FrameHeader outHeader;
      std::unique_ptr<IOBuf> outBuf;
      parse(&parseData, outHeader, outBuf);

      EXPECT_EQ(outBuf->moveToFbString(), body->moveToFbString());
    }
    queue_.move(); // reset everything
  }
开发者ID:ImportantProjects,项目名称:proxygen,代码行数:20,代码来源:HTTP2FramerTest.cpp

示例14:

Vector OrientedPlane3DirectionPrior::evaluateError(const OrientedPlane3& plane,
    boost::optional<Matrix&> H) const {

  if (H) {
    Matrix H_p;
    Unit3 n_hat_p = measured_p_.normal();
    Unit3 n_hat_q = plane.normal();
    Vector e = n_hat_p.error(n_hat_q, H_p);
    H->resize(2, 3);
    H->block<2, 2>(0, 0) << H_p;
    H->block<2, 1>(0, 2) << Matrix::Zero(2, 1);
    return e;
  } else {
    Unit3 n_hat_p = measured_p_.normal();
    Unit3 n_hat_q = plane.normal();
    Vector e = n_hat_p.error(n_hat_q);
    return e;
  }

}
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:20,代码来源:OrientedPlane3Factor.cpp

示例15: load

void load(
    Archive & ar, 
    boost::optional< T > & t, 
    const unsigned int /*version*/
){
    bool tflag;
    ar >> boost::serialization::make_nvp("initialized", tflag);
    if (tflag){
        boost::serialization::item_version_type item_version(0);
        boost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(boost::archive::library_version_type(3) < library_version){
            // item_version is handled as an attribute so it doesnt need an NVP
           ar >> BOOST_SERIALIZATION_NVP(item_version);
        }
        detail::stack_construct<Archive, T> aux(ar, item_version);
        ar >> boost::serialization::make_nvp("value", aux.reference());
        t.reset(aux.reference());
    }
开发者ID:CasparCG,项目名称:Client,代码行数:20,代码来源:optional.hpp


注:本文中的boost::optional类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。