本文整理汇总了C++中boost::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::bind方法的具体用法?C++ boost::bind怎么用?C++ boost::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUp
virtual void SetUp()
{
using namespace boost::asio::ip;
using boost::bind;
TimedSessionBase::SetUp();
netchng = transport.install_network_handler(bind(&SessionInitiator::handle_transport_connect,
this, _1, _2));
tcp::endpoint ep(address::from_string("127.0.0.1"), 9999);
acceptor.open(ep.protocol());
acceptor.set_option(tcp::socket::reuse_address(true));
acceptor.bind(ep);
acceptor.listen(1);
acceptor.async_accept(socket,
bind(&SessionInitiator::handle_transport_service_connect,
this,
boost::asio::placeholders::error));
transport.set_endpoint(ep);
ASSERT_NO_THROW(run_event_loop_until_connect());
ASSERT_TRUE(socket.is_open());
// wait for the greeting message
EXPECT_NO_THROW(run_event_loop_until_frame_received());
}
示例2: initialize
Error initialize()
{
if (!session::options().verifyInstallation())
{
// capture standard streams
Error error = initializeOutputCapture();
if (error)
return error;
}
// subscribe to events
using boost::bind;
using namespace module_context;
events().onClientInit.connect(bind(onClientInit));
events().onDetectChanges.connect(bind(onDetectChanges, _1));
// more initialization
using boost::bind;
ExecBlock initBlock ;
initBlock.addFunctions()
(bind(sourceModuleRFile, "SessionConsole.R"))
(bind(registerRpcMethod, "reset_console_actions", resetConsoleActions));
return initBlock.execute();
}
示例3: setCurrentPosition
void Button::setCurrentPosition (Position currentPosition) {
lock_guard<mutex> lock (_mutex);
if (currentPosition == _currentPosition) {
return;
}
_currentPosition = currentPosition;
ptime tNow = microsec_clock::local_time();
time_duration timeSinceLastCall = tNow - _positionUpdateTime;
if (timeSinceLastCall < _samplingCycle) {
time_duration timeToWait = _samplingCycle - timeSinceLastCall;
_samplingTimer.expires_from_now (timeToWait);
_samplingTimer.async_wait(bind(&Button::handleSampling, this, error));
} else {
_position = _currentPosition;
if (_position == Position::PRESSED) {
for (IListener* listener : _listeners) {
listener->buttonPressed (*this);
}
_buttonPressedDuration = milliseconds(0);
_buttonPressedCheckTimer.expires_from_now(_checkButtonPressedCycle);
_buttonPressedCheckTimer.async_wait(
bind(&Button::handleButtonPressed, this, error));
} else {
time_duration pressTime = tNow - _positionUpdateTime;
for (IListener* listener : _listeners) {
listener->buttonReleased (*this, pressTime);
}
}
_positionUpdateTime = tNow;
}
}
示例4: CreateClangTask
void ClangCompleter::CreateClangTask(
std::string filename,
int line,
int column,
std::vector< UnsavedFile > unsaved_files,
std::vector< std::string > flags ) {
latest_clang_results_.ResetWithNewLineAndColumn( line, column );
function< CompletionDatas() > candidates_for_location_functor =
bind( &ClangCompleter::CandidatesForLocationInFile,
boost::ref( *this ),
boost::move( filename ),
line,
column,
boost::move( unsaved_files ),
boost::move( flags ) );
shared_ptr< ClangPackagedTask > clang_packaged_task =
make_shared< ClangPackagedTask >();
clang_packaged_task->completions_task_ =
packaged_task< AsyncCompletions >(
bind( ReturnValueAsShared< std::vector< CompletionData > >,
candidates_for_location_functor ) );
clang_task_.Set( clang_packaged_task );
}
示例5: initialize
Error initialize()
{
// register postback handler for sumatra pdf
#ifdef _WIN32
std::string ignoredCommand; // assumes bash script invocation, we
// don't/can't use that for rsinverse
Error error = module_context::registerPostbackHandler("rsinverse",
rsinversePostback,
&ignoredCommand);
if (error)
return error ;
#endif
// install rpc methods
using boost::bind;
using namespace module_context;
ExecBlock initBlock ;
initBlock.addFunctions()
(bind(registerRpcMethod, "apply_forward_concordance", rpcApplyForwardConcordance))
(bind(registerRpcMethod, "apply_inverse_concordance", rpcApplyInverseConcordance))
(bind(registerRpcMethod, "synctex_forward_search", synctexForwardSearch))
(bind(registerRpcMethod, "synctex_inverse_search", synctexInverseSearch))
;
return initBlock.execute();
}
示例6: failed
void traversal_algorithm::failed(node_id const& id)
{
m_invoke_count--;
std::vector<result>::iterator i = std::find_if(
m_results.begin()
, m_results.end()
, bind(
std::equal_to<node_id>()
, bind(&result::id, _1)
, id
)
);
assert(i != m_results.end());
assert(i->flags & result::queried);
m_failed.insert(i->addr);
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(traversal) << "failed: " << i->id << " " << i->addr;
#endif
m_results.erase(i);
m_table.node_failed(id);
add_requests();
if (m_invoke_count == 0) done();
}
示例7: ToolBar
SimulationBar::SimulationBar()
: ToolBar(N_("SimulationBar"))
{
using boost::bind;
setVisibleByDefault(true);
addButton(QIcon(":/Body/icons/store-world-initial.png"),
_("Store body positions to the initial world state"))->
sigClicked().connect(bind(&SimulationBar::onStoreInitialClicked, this));
addButton(QIcon(":/Body/icons/restore-world-initial.png"),
_("Restore body positions from the initial world state"))->
sigClicked().connect(bind(&SimulationBar::onRestoreInitialClicked, this));
typedef boost::function<void(SimulatorItem* simulator)> Callback;
addButton(QIcon(":/Body/icons/start-simulation.png"), _("Start simulation from the beginning"))->
sigClicked().connect(bind(&SimulationBar::startSimulation, this, true));
addButton(QIcon(":/Body/icons/restart-simulation.png"),
_("Start simulation from the current state"))->
sigClicked().connect(bind(&SimulationBar::startSimulation, this, false));
addButton(QIcon(":/Body/icons/stop-simulation.png"), _("Stop simulation"))->
sigClicked().connect(bind(&SimulationBar::onStopSimulationClicked, this));
}
示例8: check_in_selection
//////////////////////////////////////////////////////////////////////////////
/// @brief
/// Returns if the string can be matched to an expression
///
/// @param input The string to be matched to a regex
/// @param expression The regex expression
///
/// @return bool
//////////////////////////////////////////////////////////////////////////////
bool Selector::check_in_selection( const std::string & input )
{
// The function pointer type of the overloaded match_regex we will use
// for matching.
typedef bool (*Regex_match_ptr)( const string &, const regex &,
match_flag_type);
// Set match flag to full match or partial match, whatever was selected.
match_flag_type match_type = match_default;
if ( !is_and_match )
{
// Check regex_match(input, ith expression, match_type) matches any
// of the expressions in selection list. We must cast regex_match to the
// overloaded function pointer type we are using.
return ( find_if( regex_selections.begin(), regex_selections.end(),
bind( static_cast<Regex_match_ptr>( regex_match ), input, _1,
match_type ) ) != regex_selections.end() );
}
else
{
return ( count_if( regex_selections.begin(), regex_selections.end(),
bind( static_cast<Regex_match_ptr>( regex_match ), input, _1,
match_type ) ) == regex_selections.size() );
}
} // End of Selector::check_in_selection( ... )
示例9: completeEmbeddedRInitialization
Error completeEmbeddedRInitialization(bool useInternet2)
{
// set memory limit
setMemoryLimit();
// use IE proxy settings if requested
boost::format fmt("suppressWarnings(utils::setInternet2(%1%))");
Error error = r::exec::executeString(boost::str(fmt % useInternet2));
if (error)
LOG_ERROR(error);
using boost::bind;
using namespace r::function_hook ;
ExecBlock block ;
block.addFunctions()
(bind(registerUnsupported, "loadhistory", "utils"))
(bind(registerUnsupported, "savehistory", "utils"))
(bind(registerUnsupported, "history", "utils"))
(bind(registerUnsupported, "timestamp", "utils"))
(bind(registerUnsupported, "winMenuAdd", "utils"))
(bind(registerUnsupported, "winMenuAddItem", "utils"))
(bind(registerUnsupported, "winMenuDel", "utils"))
(bind(registerUnsupported, "winMenuDelItem", "utils"))
(bind(registerUnsupported, "winMenuNames", "utils"))
(bind(registerUnsupported, "winMenuItems", "utils"));
return block.execute();
}
示例10: add_requests
void traversal_algorithm::add_requests()
{
while (m_invoke_count < m_branch_factor)
{
// Find the first node that hasn't already been queried.
// TODO: Better heuristic
std::vector<result>::iterator i = std::find_if(
m_results.begin()
, last_iterator()
, bind(
&bitwise_nand
, bind(&result::flags, _1)
, (unsigned char)result::queried
)
);
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(traversal) << "nodes left (" << this << "): " << (last_iterator() - i);
#endif
if (i == last_iterator()) break;
try
{
invoke(i->id, i->addr);
++m_invoke_count;
i->flags |= result::queried;
}
catch (std::exception& e) {}
}
}
示例11: catch
void dht_tracker::start(entry const& bootstrap)
{
std::vector<udp::endpoint> initial_nodes;
if (bootstrap.type() == entry::dictionary_t)
{
try
{
if (entry const* nodes = bootstrap.find_key("nodes"))
read_endpoint_list<udp::endpoint>(nodes, initial_nodes);
} catch (std::exception&) {}
}
error_code ec;
m_timer.expires_from_now(seconds(1), ec);
m_timer.async_wait(bind(&dht_tracker::tick, self(), _1));
m_connection_timer.expires_from_now(seconds(10), ec);
m_connection_timer.async_wait(
bind(&dht_tracker::connection_timeout, self(), _1));
m_refresh_timer.expires_from_now(seconds(5), ec);
m_refresh_timer.async_wait(bind(&dht_tracker::refresh_timeout, self(), _1));
m_dht.bootstrap(initial_nodes, boost::bind(&dht_tracker::on_bootstrap, self()));
}
示例12: getLoggedInUser
UserData ClientServiceImpl::getLoggedInUser() const{
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
return _currentData.getLoggedInUser();
}
示例13: CreateSortingTask
// Copy-ctor for unique_future is private in C++03 mode so we need to take it as
// an out param
void ClangCompleter::CreateSortingTask(
const std::string &query,
unique_future< AsyncCompletions > &future ) {
// Careful! The code in this function may burn your eyes.
function< CompletionDatas( const CompletionDatas & ) >
sort_candidates_for_query_functor =
bind( &ClangCompleter::SortCandidatesForQuery,
boost::ref( *this ),
query,
_1 );
function< CompletionDatas() > operate_on_completion_data_functor =
bind( &ClangResultsCache::OperateOnCompletionDatas< CompletionDatas >,
boost::cref( latest_clang_results_ ),
boost::move( sort_candidates_for_query_functor ) );
shared_ptr< packaged_task< AsyncCompletions > > task =
make_shared< packaged_task< AsyncCompletions > >(
bind( ReturnValueAsShared< std::vector< CompletionData > >,
boost::move( operate_on_completion_data_functor ) ) );
future = task->get_future();
sorting_task_.Set( task );
}
示例14: update_map
void upnp::update_map(rootdevice& d, int i)
{
TORRENT_ASSERT(d.magic == 1337);
TORRENT_ASSERT(i < int(d.mapping.size()));
TORRENT_ASSERT(d.mapping.size() == m_mappings.size());
if (d.upnp_connection) return;
mapping_t& m = d.mapping[i];
if (m.action == mapping_t::action_none
|| m.protocol == none)
{
char msg[200];
snprintf(msg, sizeof(msg), "mapping %u does not need updating, skipping", i);
log(msg);
m.action = mapping_t::action_none;
next(d, i);
return;
}
TORRENT_ASSERT(!d.upnp_connection);
TORRENT_ASSERT(d.service_namespace);
char msg[200];
snprintf(msg, sizeof(msg), "connecting to %s", d.hostname.c_str());
log(msg);
if (m.action == mapping_t::action_add)
{
if (m.failcount > 5)
{
m.action = mapping_t::action_none;
// giving up
next(d, i);
return;
}
if (d.upnp_connection) d.upnp_connection->close();
d.upnp_connection.reset(new http_connection(m_io_service
, m_cc, bind(&upnp::on_upnp_map_response, self(), _1, _2
, boost::ref(d), i, _5), true
, bind(&upnp::create_port_mapping, self(), _1, boost::ref(d), i)));
d.upnp_connection->start(d.hostname, to_string(d.port).elems
, seconds(10), 1);
}
else if (m.action == mapping_t::action_delete)
{
if (d.upnp_connection) d.upnp_connection->close();
d.upnp_connection.reset(new http_connection(m_io_service
, m_cc, bind(&upnp::on_upnp_unmap_response, self(), _1, _2
, boost::ref(d), i, _5), true
, bind(&upnp::delete_port_mapping, self(), boost::ref(d), i)));
d.upnp_connection->start(d.hostname, to_string(d.port).elems
, seconds(10), 1);
}
m.action = mapping_t::action_none;
}
示例15: getGroupsInvsCount
size_t ClientServiceImpl::getGroupsInvsCount() const{
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
NotificationsData nftnDta = _currentData.getNotificationsData();
return nftnDta.getGroupsInvsCount();
}