static void do_complete(void* owner, operation* base, const asio::error_code& result_ec, std::size_t bytes_transferred) { asio::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_recvfrom_op* o( static_cast<win_iocp_socket_recvfrom_op*>(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); ASIO_HANDLER_COMPLETION((o)); #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. if (owner) { buffer_sequence_adapter<asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); } #endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING) socket_ops::complete_iocp_recvfrom(o->cancel_token_, ec); // Record the size of the endpoint returned by the operation. o->endpoint_.resize(o->endpoint_size_); // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated // with the handler. Consequently, a local copy of the handler is required // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::binder2<Handler, asio::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); ASIO_HANDLER_INVOCATION_END; } }
/* **************************************************************************** * * Constructor - */ TEST(NotifyContextResponse, Constructor) { StatusCode sc(SccOk, "2"); NotifyContextResponse ncr(sc); utInit(); EXPECT_EQ(SccOk, ncr.responseCode.code); ncr.release(); StatusCode ec(SccOk, "4"); NotifyContextResponse ncr2(ec); EXPECT_EQ(SccOk, ncr2.responseCode.code); utExit(); }
std::string backtrace::trace_on_new_stack() const { if(frames_.empty()) return std::string(); if (0 == threads::get_self_ptr()) return trace(); lcos::local::futures_factory<std::string()> p( util::bind(stack_trace::get_symbols, &frames_.front(), frames_.size())); error_code ec(lightweight); p.apply(threads::thread_priority_default, threads::thread_stacksize_medium, ec); if (ec) return "<couldn't retrieve stack backtrace>"; return p.get_future().get(ec); }
DynLinArr<double> make_log_mesh_ec(double emin, double emax, long q) { mfunname( "DynLinArr< double > make_log_mesh_ec(double emin, double emax, long q)"); double rk = pow(emax / emin, (1.0 / double(q))); double er = emin; DynLinArr<double> ec(q); double e1; double e2 = er; for (long n = 0; n < q; n++) { e1 = e2; e2 = e2 * rk; ec[n] = (e1 + e2) * 0.5; } return ec; }
static void do_complete(io_service_impl* owner, operation* base, const lslboost::system::error_code& result_ec, std::size_t bytes_transferred) { lslboost::system::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_recv_op* o(static_cast<win_iocp_socket_recv_op*>(base)); ptr p = { lslboost::asio::detail::addressof(o->handler_), o, o }; BOOST_ASIO_HANDLER_COMPLETION((o)); #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. if (owner) { buffer_sequence_adapter<lslboost::asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); } #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) socket_ops::complete_iocp_recv(o->state_, o->cancel_token_, buffer_sequence_adapter<lslboost::asio::mutable_buffer, MutableBufferSequence>::all_empty(o->buffers_), ec, bytes_transferred); // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated // with the handler. Consequently, a local copy of the handler is required // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::binder2<Handler, lslboost::system::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = lslboost::asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); lslboost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); BOOST_ASIO_HANDLER_INVOCATION_END; } }
bfs::path getTempPath(const bfs::path& tempDir, const string& prefix) { bfs::path rval; bfs::path p = tempDir / bfs::path(prefix + "-XXXXXX"); char* tmpl = new char[p.string().size() + 1]; strcpy(tmpl, p.c_str()); char* s = ::mktemp(tmpl); if (!s) { boost::system::error_code ec(errno, boost::system::system_category()); throw bfs::filesystem_error("::mktemp fails", tempDir, bfs::path(prefix), ec); } rval = s; delete[] s; return rval; }
void LoopbackPhysicalLayerAsync::CheckForReadDispatch() { if(mReadSize > 0 && mWritten.size() > 0) { size_t num = (mReadSize < mWritten.size()) ? mReadSize : mWritten.size(); for(size_t i=0; i<num; ++i) { mpReadBuff[i] = mWritten.front(); mWritten.pop_front(); } mReadSize = 0; error_code ec(errc::success, get_generic_category()); mpService->post(bind(&LoopbackPhysicalLayerAsync::OnReadCallback, this, ec, mpReadBuff, num)); } }
static void do_complete(void* owner, operation* base, const boost::system::error_code& result_ec, std::size_t bytes_transferred) { boost::system::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_handle_read_op* o(static_cast<win_iocp_handle_read_op*>(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; handler_work<Handler, IoExecutor> w(o->handler_, o->io_executor_); BOOST_ASIO_HANDLER_COMPLETION((*o)); #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) if (owner) { // Check whether buffers are still valid. buffer_sequence_adapter<boost::asio::mutable_buffer, MutableBufferSequence>::validate(o->buffers_); } #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) // Map non-portable errors to their portable counterparts. if (ec.value() == ERROR_HANDLE_EOF) ec = boost::asio::error::eof; // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated // with the handler. Consequently, a local copy of the handler is required // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::binder2<Handler, boost::system::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = boost::asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); w.complete(handler, handler.handler_); BOOST_ASIO_HANDLER_INVOCATION_END; } }
bool PluginWebView::OnAttach() { EvtManagerTop& ec(wm.evtmgr); ec.link_a<String>("Webview.script"); ec.table["Webview.script"].ref<String>(); ec.append(new EvtCommand("Webview.Exec")); ec.append(new EvtCommand("Webview.Clear")); AttachEvent("Webview.Exec"); AttachEvent("Webview.Clear"); WndModelWvScript* pmdl=new WndModelWvScript(wm); ec.append(pmdl); ec.gp_beg("OtherWindow"); ec.gp_add(new EvtCommandShowModel("Webview.Script",pmdl)); ec.gp_end(); ec.gp_beg(_kT("Webview.Page")); ec.gp_add("Forward"); ec.gp_end(); ec.gp_beg("Menu.Extra"); ec.gp_add("Webview.Page"); ec.gp_end(); ec["Webview.Page"].flags.add(EvtCommand::FLAG_HIDE_UI); ec.gp_beg(_kT("tb.WebView")); ec.gp_add(new EvtCommandCtrl("WebView.URL","searchctrl",WndProperty().width(320))); ec.gp_add(new EvtCommand(_kT("WebView.Go"))); ec.gp_end(); AttachEvent("WebView.URL"); AttachEvent("WebView.Go"); ec.gp_beg("ToolBar.default"); ec.gp_add("tb.WebView"); ec.gp_end(); return true; }
/** * Catches an entity which is close to the given position 'pos'. * * @param pos A graphic coordinate. * @param level The level of resolving for iterating through the entity * container * @enType, only search for a particular entity type * @return Pointer to the entity or NULL. */ RS_Entity* RS_Snapper::catchEntity(const RS_Vector& pos, RS2::EntityType enType, RS2::ResolveLevel level) { RS_DEBUG->print("RS_Snapper::catchEntity"); // std::cout<<"RS_Snapper::catchEntity(): enType= "<<enType<<std::endl; // set default distance for points inside solids RS_EntityContainer ec(NULL,false); for(RS_Entity* en= container->firstEntity(level);en!=NULL;en=container->nextEntity(level)){ if(en->isVisible()==false) continue; if(en->rtti() != enType && RS2::isContainer(enType)){ //whether this entity is a member of member of the type enType RS_Entity* parent(en->getParent()); bool matchFound(false); while(parent != NULL) { // std::cout<<"RS_Snapper::catchEntity(): parent->rtti()="<<parent->rtti()<<" enType= "<<enType<<std::endl; if(parent->rtti() == enType) { matchFound=true; break; } parent=parent->getParent(); } if(matchFound==false) continue; } ec.addEntity(en); } if (ec.count() == 0 ) return NULL; double dist(0.); RS_Entity* entity = ec.getNearestEntity(pos, &dist, RS2::ResolveNone); int idx = -1; if (entity!=NULL && entity->getParent()!=NULL) { idx = entity->getParent()->findEntity(entity); } if (entity!=NULL && dist<=getSnapRange()) { // highlight: RS_DEBUG->print("RS_Snapper::catchEntity: found: %d", idx); return entity; } else { RS_DEBUG->print("RS_Snapper::catchEntity: not found"); return NULL; } }
void RS_ActionModifyOffset::mouseMoveEvent(QMouseEvent* e) { // RS_DEBUG->print("RS_ActionModifyOffset::mouseMoveEvent begin"); data->coord=snapPoint(e); RS_EntityContainer ec(nullptr,true); for(auto en: *container){ if(en->isSelected()) ec.addEntity(en->clone()); } if(ec.isEmpty()) return; RS_Modification m(ec, nullptr, false); m.offset(*data); deletePreview(); preview->addSelectionFrom(ec); drawPreview(); }
void PipeNode::doListen(const std::wstring & name) { HANDLE handle = CreateNamedPipeW((L"\\\\.\\pipe\\" + name).c_str(), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 0x1000, 0x1000, 0, NULL); pipe_.reset(new boost::asio::windows::stream_handle(ioService_, handle)); boost::asio::windows::overlapped_ptr overlapped(ioService_, boost::bind(&PipeNode::handleConnected, this, _1, name)); bool ok = ConnectNamedPipe(pipe_->native(), overlapped.get()) != FALSE; DWORD error = GetLastError(); if(!ok && error != ERROR_IO_PENDING) { boost::system::error_code ec(error, boost::asio::error::get_system_category()); overlapped.complete(ec, 0); } else { overlapped.release(); } }
/* **************************************************************************** * * response - * */ TEST(UpdateContextAvailabilitySubscriptionRequest, response) { UpdateContextAvailabilitySubscriptionResponse ucas; StatusCode ec(SccBadRequest, "Detail"); UpdateContextAvailabilitySubscriptionResponse ucas2(ec); std::string out; utInit(); EXPECT_EQ(ucas2.errorCode.code, SccBadRequest); ucas.subscriptionId.set("012345678901234567890123"); out = ucas.check(""); EXPECT_EQ("OK", out); utExit(); }
void main(void) { pr(); lev1(); choose(); system("cls"); pr(); gotoxy(1,11); printf("반드시 프로그램 경로까지 입력해야 하며( Ex. C:\\test.txt)"); gotoxy(1,12); printf("AEGIS프로그램과 같은 폴더내에 있는 경우는 경로를 생략해도 됩니다."); gotoxy(1,14); printf("※ 파일 이름에 띄어쓰기가 있는 경우에는 올바르게 실행되지 않습니다!"); gotoxy(1,8); printf("잠금 또는 잠금해제(암호화 또는 복호화)할 파일명(확장자 필수!!) : "); scanf("%s",&inf); ec(); }
// Constructor. pipe_select_interrupter() { int pipe_fds[2]; if (pipe(pipe_fds) == 0) { read_descriptor_ = pipe_fds[0]; ::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK); write_descriptor_ = pipe_fds[1]; ::fcntl(write_descriptor_, F_SETFL, O_NONBLOCK); } else { asio::error_code ec(errno, asio::error::get_system_category()); asio::system_error e(ec, "pipe_select_interrupter"); boost::throw_exception(e); } }
void QLCFixtureEditor::slotAddChannel() { EditChannel ec(this); bool ok = false; while (ok == false) { if (ec.exec() == QDialog::Accepted) { if (m_fixtureDef->channel(ec.channel()->name()) != NULL) { QMessageBox::warning(this, QString("Channel already exists"), QString("A channel by the name \"") + ec.channel()->name() + QString("\" already exists!")); ok = false; } else if (ec.channel()->name().length() == 0) { QMessageBox::warning(this, QString("Channel has no name"), QString("You must give the channel a descriptive name!")); ok = false; } else { /* Create a new channel to the fixture */ m_fixtureDef->addChannel( new QLCChannel(ec.channel())); refreshChannelList(); setModified(); ok = true; } } else { ok = true; } } }
int main() { std::vector<Node *> nodes; std::vector<Edge *> edges; N na("a"); N nb("b"); N nc("c"); N nd("d"); E ea(&na, &nb, 6); E eb(&nb, &nc, 5); E ec(&nc, &nd, 4); E ed(&nd, &na, 3); E ee(&na, &nc, 2); E ef(&nb, &nd, 1); nodes.push_back(&na); nodes.push_back(&nb); nodes.push_back(&nc); nodes.push_back(&nd); edges.push_back(&ea); edges.push_back(&eb); edges.push_back(&ec); edges.push_back(&ed); edges.push_back(&ee); edges.push_back(&ef); Kruskal k(nodes, edges); float w = k.solve(); std::cout << "Tree weight: " << std::endl << w << std::endl; std::cout << "Edges: " << std::endl; std::vector<Edge *> mst = k.getEdges(); for (std::vector<Edge *>::iterator it = mst.begin(); it != mst.end(); it++) { N *a = (N *) (*it)->a; N *b = (N *) (*it)->b; std::cout << a->name << " - " << b->name << std::endl; } return 0; }
/* **************************************************************************** * * constructors - */ TEST(SubscribeContextAvailabilityResponse, constructors) { SubscribeContextAvailabilityResponse* scar1 = new SubscribeContextAvailabilityResponse(); SubscribeContextAvailabilityResponse scar2("012345678901234567890123", "PT1S"); StatusCode ec(SccBadRequest, "Detail"); SubscribeContextAvailabilityResponse scar3("012345678901234567890124", ec); utInit(); EXPECT_EQ("", scar1->subscriptionId.get()); delete(scar1); EXPECT_EQ("012345678901234567890123", scar2.subscriptionId.get()); EXPECT_EQ("012345678901234567890124", scar3.subscriptionId.get()); EXPECT_EQ(SccBadRequest, scar3.errorCode.code); utExit(); }
static void do_complete(void* owner, operation* base, const boost::system::error_code& result_ec, std::size_t /*bytes_transferred*/) { boost::system::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_connect_op* o( static_cast<win_iocp_socket_connect_op*>(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; handler_work<Handler> w(o->handler_); if (owner) { if (o->connect_ex_) socket_ops::complete_iocp_connect(o->socket_, ec); else ec = o->ec_; } BOOST_ASIO_HANDLER_COMPLETION((*o)); // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated // with the handler. Consequently, a local copy of the handler is required // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::binder1<Handler, boost::system::error_code> handler(o->handler_, ec); p.h = boost::asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_)); w.complete(handler, handler.handler_); BOOST_ASIO_HANDLER_INVOCATION_END; } }
static void do_completion_impl(operation* op, DWORD last_error, size_t bytes_transferred) { // Take ownership of the operation object. typedef read_operation<MutableBufferSequence, Handler> op_type; op_type* handler_op(static_cast<op_type*>(op)); typedef handler_alloc_traits<Handler, op_type> alloc_traits; handler_ptr<alloc_traits> ptr(handler_op->handler_, handler_op); #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. typename MutableBufferSequence::const_iterator iter = handler_op->buffers_.begin(); typename MutableBufferSequence::const_iterator end = handler_op->buffers_.end(); while (iter != end) { boost::asio::mutable_buffer buffer(*iter); boost::asio::buffer_cast<char*>(buffer); ++iter; } #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) // Check for the end-of-file condition. boost::system::error_code ec(last_error, boost::asio::error::get_system_category()); if (!ec && bytes_transferred == 0 || last_error == ERROR_HANDLE_EOF) { ec = boost::asio::error::eof; } // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Handler handler(handler_op->handler_); // Free the memory associated with the handler. ptr.reset(); // Call the handler. boost_asio_handler_invoke_helpers::invoke( bind_handler(handler, ec, bytes_transferred), &handler); }
int main(int argc, char* argv[]) { //---------------------- //Command line parsing //---------------------- namespace po = boost::program_options; po::options_description desc; desc.add_options() ("help,h", "produce help message") ("verbose,v", "verbose mode") ("error-time,e", po::value<int>(), "set time before start reporting error") ("num-ent,n", po::value<int>(), "set max number of entities at the same time. Default 500, -1=inf") ("no-create,c", "never create entities, only subscribe and sen request to others") ("no-delete,d", "never delete entities, when max num entites is reached no new entities will be created, instead the existing entities will be continously updated"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if (vm.count("help")) { std::cout<<desc<<std::endl; return 0; } if (vm.count("error-time")) { Supervisor::TimeThreshold = vm["error-time"].as<int>(); } int numEnt = vm.count("num-ent")>0 ? numEnt=vm["num-ent"].as<int>() : 500; //default 500 entities bool deleteEnabled = vm.count("no-delete")<=0; bool createEnabled = vm.count("no-create")<=0; bool verbose = vm.count("verbose")>0; //---------------------- //Run program //---------------------- EntityCruncher ec(numEnt, createEnabled, deleteEnabled, verbose); ec.RunReactor(); return 0; }
bool statistics_counter<Statistic>::ensure_base_counter() { // lock here to avoid checking out multiple reference counted GIDs // from AGAS. This std::unique_lock<mutex_type> l(mtx_); if (!base_counter_id_) { // get or create the base counter error_code ec(lightweight); hpx::id_type base_counter_id; { // We need to unlock the lock here since get_counter might suspend util::unlock_guard<std::unique_lock<mutex_type> > unlock(l); base_counter_id = get_counter(base_counter_name_, ec); } // After reacquiring the lock, we need to check again if base_counter_id_ // hasn't been set yet if(!base_counter_id_) { base_counter_id_ = base_counter_id; } else { // If it was set already by a different thread, return true. return true; } if (HPX_UNLIKELY(ec || !base_counter_id_)) { // base counter could not be retrieved HPX_THROW_EXCEPTION(bad_parameter, "statistics_counter<Statistic>::evaluate_base_counter", boost::str(boost::format( "could not get or create performance counter: '%s'") % base_counter_name_) ); return false; } } return true; }
void base_event::event_fire(event id, const vector<event_callback_arg> args, bool async) const { if(!this->_events.count(id)) return; #ifndef QTCTREATOR thread tr([&]() { #else // a warning free work-around to un-used arg. static_cast<void>(async); #endif this->_mutex.lock(); auto vec = this->_events.at(id); for(event_handler& ec : vec) ec(args); this->_mutex.unlock(); #ifndef QTCTREATOR }); if(async) tr.detach(); else tr.join(); #endif }
template<class T> void AsyncEndpoint<T>::start() { registerEndpoint(); if(boost::shared_ptr<AsyncEndpoint<T> > activated = activateSession(this->shared_from_this())){ //Transfer session object over to old session activated->unregisterEndpoint(); { boost::mutex::scoped_lock lock(message_queueMutex); message_queue = std::deque<Message_ptr>(activated->message_queue); } log("Session reactivated"); } boost::system::error_code ec(0,boost::system::system_category()); handle_write(ec); isActive=true; aostream->async_read_some(boost::asio::buffer(data_, max_length), boost::bind(&AsyncEndpoint::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); }// NMEA-Protocol-Server
/* **************************************************************************** * * constructorsAndRender - * */ TEST(UnsubscribeContextAvailabilityResponse, constructorsAndRender) { UnsubscribeContextAvailabilityResponse ucar1; SubscriptionId subscriptionId; utInit(); subscriptionId.set("111122223333444455556666"); UnsubscribeContextAvailabilityResponse ucar2(subscriptionId); StatusCode ec(SccBadRequest, "D"); UnsubscribeContextAvailabilityResponse ucar3(ec); std::string out; EXPECT_EQ(0, ucar1.statusCode.code); EXPECT_EQ(subscriptionId.get(), ucar2.subscriptionId.get()); EXPECT_EQ(SccBadRequest, ucar3.statusCode.code); utExit(); }
/* **************************************************************************** * * response - */ TEST(UpdateContextAvailabilitySubscriptionRequest, response) { UpdateContextAvailabilitySubscriptionResponse ucas; StatusCode ec(SccBadRequest, "Detail"); UpdateContextAvailabilitySubscriptionResponse ucas2(ec); std::string out; const char* outfile1 = "ngsi9.updateContextAvailabilitySubscriptionResponse.response1.valid.xml"; const char* outfile2 = "ngsi9.updateContextAvailabilitySubscriptionResponse.response2.valid.xml"; const char* outfile3 = "ngsi9.updateContextAvailabilitySubscriptionResponse.response3.valid.xml"; const char* outfile4 = "ngsi9.updateContextAvailabilitySubscriptionResponse.response4.valid.xml"; utInit(); EXPECT_EQ(ucas2.errorCode.code, SccBadRequest); ucas.subscriptionId.set("012345678901234567890123"); out = ucas.check(UpdateContextAvailabilitySubscription, XML, "", "", 0); EXPECT_EQ("OK", out); out = ucas.render(UpdateContextAvailabilitySubscription, XML, "", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); ucas.errorCode.fill(SccBadRequest, "Detail"); out = ucas.render(UpdateContextAvailabilitySubscription, XML, "", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); ucas.errorCode.fill(SccNone); ucas.duration.set("ddd"); out = ucas.check(UpdateContextAvailabilitySubscription, XML, "", "", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); out = ucas.check(UpdateContextAvailabilitySubscription, XML, "", "predetected error", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile4)) << "Error getting test data from '" << outfile4 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); utExit(); }
/* **************************************************************************** * * constructors - */ TEST(UpdateContextSubscriptionResponse, constructors) { UpdateContextSubscriptionResponse ucsr1; StatusCode ec(SccBadRequest, "D"); UpdateContextSubscriptionResponse ucsr2(ec); std::string out; const char* outfile1 = "ngsi10.updateContextSubscriptionResponse.empty.valid.xml"; const char* outfile2 = "ngsi10.updateContextSubscriptionResponse.badRequest.valid.xml"; utInit(); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; out = ucsr1.render(UpdateContextSubscription, XML, ""); EXPECT_STREQ(expectedBuf, out.c_str()); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'"; out = ucsr2.render(UpdateContextSubscription, XML, ""); EXPECT_STREQ(expectedBuf, out.c_str()); utExit(); }
void QLCFixtureEditor::slotEditChannel() { QLCChannel* real = NULL; QTreeWidgetItem* item = NULL; // Initialize the dialog with the selected logical channel or // bail out if there is no current selection real = currentChannel(); if (real == NULL) return; EditChannel ec(this, real); if (ec.exec() == QDialog::Accepted) { if (m_fixtureDef->channel(ec.channel()->name()) != NULL && ec.channel()->name() != real->name()) { QMessageBox::warning(this, tr("Channel already exists"), tr("A channel by the name \"%1\" already exists!") .arg(ec.channel()->name())); } else if (ec.channel()->name().length() == 0) { QMessageBox::warning(this, tr("Channel has no name"), tr("You must give the channel a descriptive name!")); } else { // Copy the channel's contents to the real channel *real = *(ec.channel()); item = m_channelList->currentItem(); updateChannelItem(real, item); m_channelList->resizeColumnToContents(CH_COL_NAME); setModified(); } } }
bool PluginSearch::OnAttach() { EvtManagerTop& ec(wm.evtmgr); //DataPtrT<WndModelFindSearch> pevt(new WndModelFindSearch(wm)); //ec.append(pevt.get()); ec.append(new WndModelScript("Model.Search","scripting/ui/dlg_search.script"));//,WndModel::FLAG_AUTO_FIT|WndModel::FLAG_NO_CLOSE)); ec.gp_beg("CmdProc"); ec.gp_add(new EvtCmdShowSearch(wm,_kT("Find"),CmdProc::CP_FIND)); ec.gp_add(new EvtCmdShowSearch(wm,_kT("Replace"),CmdProc::CP_REPLACE)); ec.gp_add(new EvtCmdSearch(wm,_kT("Btn.Find"),CmdProc::CP_FIND)); ec.gp_add(new EvtCmdSearch(wm,_kT("Btn.Replace"),CmdProc::CP_REPLACE)); ec.gp_add(new EvtCmdSearch(wm,_kT("Btn.ReplaceAll"),CmdProc::CP_REPLACEALL)); ec.gp_end(); ec.append(new EvtCommand("search.replace")); IDat_search& data(IDat_search::current()); ec.gp_beg("search.group"); ec.link("search.text_old",data.text_old); ec.link("search.text_new",data.text_new); ec.link("search.case",data.flags,4); ec.link("search.word",data.flags,2); ec.link("search.regexp",data.flags,0x00200000); ec.gp_end(); ec["search.group"].flags.add(EvtBase::FLAG_RECURSIVE); AttachEvent("search.text_old"); AttachEvent("search.text_new"); AttachEvent("search.regexp"); AttachEvent("search.replace"); return true; }
vector<long> DividedHighwayMerger::_findCenterWays(shared_ptr<const Way> w1, shared_ptr<const Way> w2) { shared_ptr<OneWayFilter> owFilter(new OneWayFilter(false)); Status s; if (w1->getStatus() == Status::Unknown1) { s = Status::Unknown2; } else { s = Status::Unknown1; } shared_ptr<StatusFilter> statusFilter(new StatusFilter(s)); shared_ptr<ParallelWayFilter> parallelFilter(new ParallelWayFilter(_map, w1)); ElementConverter ec(_map); shared_ptr<LineString> ls2 = ec.convertToLineString(w2); if (DirectionFinder::isSimilarDirection(_map, w1, w2) == false) { ls2.reset(dynamic_cast<LineString*>(ls2->reverse())); } // calculate the center line of two ways. shared_ptr<LineString> center = LineStringAverager::average( ec.convertToLineString(w1), ls2); shared_ptr<WayBufferFilter> distanceFilter(new WayBufferFilter(_map, center, 0.0, (w1->getCircularError() + w2->getCircularError()) / 2.0, _matchPercent)); WayFilterChain filter; filter.addFilter(owFilter); filter.addFilter(statusFilter); filter.addFilter(parallelFilter); filter.addFilter(distanceFilter); return _map->filterWays(filter); }