OSystem::OSystem() : m_layer(), m_lib_loader() { m_layer.reset(); m_lib_loader.reset(); #ifdef CF_HAVE_DLOPEN if ( is_null( m_lib_loader ) ) m_lib_loader.reset( new PosixDlopenLibLoader() ); #endif #ifdef CF_OS_LINUX if ( is_null( m_layer ) ) m_layer.reset( new Linux::OSystemLayer() ); #else #ifdef CF_OS_MACOSX if ( is_null( m_layer ) ) m_layer.reset( new MacOSX::OSystemLayer() ); #else #ifdef CF_OS_WINDOWS if ( is_null( m_layer ) ) m_layer.reset( new Win32::OSystemLayer() ); if ( is_null( m_lib_loader ) ) m_lib_loader.reset( new Win32::LibLoader() ); #else #error "Unkown operating system: not Windows, MacOSX or Linux" #endif #endif #endif cf_assert ( is_not_null( m_layer ) ); cf_assert ( is_not_null( m_lib_loader ) ); std::vector< boost::filesystem::path > default_paths(1, boost::filesystem::path(CF_BUILD_DIR) / boost::filesystem::path("dso")); m_lib_loader->set_search_paths(default_paths); }
void TwoSstarImplementation::step() { if ( is_null(m_pde) ) throw SetupError( FromHere(), "pde not configured" ); if ( is_null(m_pde->time()) ) throw SetupError(FromHere(), "Time was not set"); if ( is_null(m_pde->solution()) ) throw SetupError(FromHere(), "Solution was not set"); if ( is_null(m_time_step_computer) ) throw SetupError(FromHere(), "Time step computer was not set"); Time& time = *m_pde->time(); m_time_step_computer->options().set("wave_speed",m_pde->wave_speed()); m_time_step_computer->options().set("time_step",m_dt); Field& U = *m_pde->solution(); Field& R = *m_pde->rhs(); Field& H = *m_dt; Field& U0 = *m_backup; const Real T0 = time.current_time(); const Uint nb_eqs = m_pde->nb_eqs(); Real dt = 0; for (Uint stage=0; stage<m_coeffs->nb_stages(); ++stage) { // Set time and iteration for this stage time.dt() = dt; time.current_time() = T0 + m_coeffs->gamma(stage) * dt; // Set boundary condition m_pde->bc()->execute(); // Compute right-hand-side m_pde->rhs_computer()->compute_rhs(*m_pde->rhs(),*m_pde->wave_speed()); // Compute time step and backup solution if (stage == 0) { m_time_step_computer->execute(); U0 = U; dt = time.dt(); } // Do post-processing to the rhs if ( is_not_null( m_pre_update ) ) m_pre_update->execute(); // Update solution const Real one_minus_alpha = 1. - m_coeffs->alpha(stage); for (Uint pt=0; pt<U.size(); ++pt) { for (Uint eq=0; eq<nb_eqs; ++eq) { U[pt][eq] = one_minus_alpha*U0[pt][eq] + m_coeffs->alpha(stage)*U[pt][eq] + m_coeffs->beta(stage)*H[pt][0]*R[pt][eq]; } } U.synchronize(); // Do post-processing to the stage solution if ( is_not_null( m_post_update ) ) m_post_update->execute(); } time.current_time() = T0; }
void GraphicalArrayTest::initTestCase() { GraphicalArray * value = new GraphicalArray(); QVERIFY( is_not_null( findLineEdit(value) ) ); QVERIFY( is_not_null( findRemoveButton(value) ) ); QVERIFY( is_not_null( findListView(value) ) ); QVERIFY( is_not_null( findModel(value) ) ); delete value; }
void change_elements() { connectivity = elements().handle<mesh::Elements>()->geometry_space().connectivity().handle< mesh::Connectivity >(); coordinates = elements().geometry_fields().coordinates().handle< mesh::Field >(); cf3_assert( is_not_null(connectivity) ); cf3_assert( is_not_null(coordinates) ); solution = csolution; residual = cresidual; wave_speed = cwave_speed; }
void CPlotXY::convergence_history( SignalArgs & args ) { if( is_not_null(m_data.get()) ) { SignalFrame reply = args.create_reply( uri() ); SignalFrame& options = reply.map( Protocol::Tags::key_options() ); // std::vector<Real> data(8000); CTable<Real>& table = *m_data.get(); std::vector<std::string> labels = list_of<std::string>("x")("y")("z")("u")("v")("w")("p")("t"); add_multi_array_in(options.main_map, "Table", m_data->array(), ";", labels); // for(Uint row = 0 ; row < 1000 ; ++row) // { // for(Uint col = 0 ; col < 8 ; ++col) // data[ (row * 8) + col ] = table[row][col]; // } // XmlNode node = options.add("Table", data, " ; "); // node.set_attribute("dimensions", "8"); } else throw SetupError( FromHere(), "Data to plot not setup" ); }
void update_parameters() { if(is_not_null(m_ml_parameters)) m_self.remove_component("MLParameters"); m_ml_parameters = m_self.create_component<ParameterList>("MLParameters"); m_ml_parameters->mark_basic(); m_ml_parameters->set_parameter_list(*m_ml_parameter_list); if(is_not_null(m_solver_parameters)) m_self.remove_component("SolverParameters"); m_solver_parameters = m_self.create_component<ParameterList>("SolverParameters"); m_solver_parameters->mark_basic(); m_solver_parameters->set_parameter_list(*m_solver_parameter_list); }
void FaceConnectivity::compute_face( const mesh::Faces& faces, const Uint face_idx) { if (m_face.comp != &faces || m_face.idx != face_idx) { m_face = Entity(faces,face_idx); cf3_assert( is_not_null( m_face.comp->connectivity_face2cell() ) ); const mesh::FaceCellConnectivity& cell_connectivity = *m_face.comp->connectivity_face2cell(); cf3_assert( m_face.idx < cell_connectivity.size() ); m_orientation = MATCHED; m_rotation = 0; m_cells[LEFT] = cell_connectivity.connectivity()[m_face.idx][LEFT]; m_cells_rotation[LEFT] = cell_connectivity.cell_rotation()[m_face.idx][LEFT]; m_cells_orientation[LEFT] = cell_connectivity.cell_orientation()[m_face.idx][LEFT]; m_cells_face_nb[LEFT] = cell_connectivity.face_number()[m_face.idx][LEFT]; m_is_bdry_face = cell_connectivity.is_bdry_face()[m_face.idx]; if (m_is_bdry_face == false) { m_cells[RIGHT] = cell_connectivity.connectivity()[m_face.idx][RIGHT]; m_cells_rotation[RIGHT] = cell_connectivity.cell_rotation()[m_face.idx][RIGHT]; m_cells_orientation[RIGHT] = cell_connectivity.cell_orientation()[m_face.idx][RIGHT]; m_cells_face_nb[RIGHT] = cell_connectivity.face_number()[m_face.idx][RIGHT]; } } }
int TreeNode::child_count() const { if( is_not_null(m_node) ) return m_node->count_children(); else return 0; }
oraub8 SqlLob::length() { if(!is_not_null()) return 0; bool done = false; oraub8 len; while(!done) { sword res = OCICALL(OCILobGetLength2(_conn._svc_ctx, _conn._env._errh, _loc, &len)); if( res != OCI_SUCCESS ) { sb4 errorcode; sword res2 = OCICALL(OCIErrorGet(_conn._env._errh, 1, NULL, &errorcode, NULL, 0, OCI_HTYPE_ERROR)); assert(res2 == OCI_SUCCESS); if(errorcode == 3127) // ORA-03127: no new operations allowed until the active operation ends { std::cerr << "ORA-03127: no new operations allowed until the active operation ends" << std::endl; MSLEEP(100); } else { oci_check_error(__TROTL_HERE__, _conn._env._errh, res); } } else { done = true; } } return len; };
void GraphicalArrayTest::test_setValidator() { QValidator * validator = new QIntValidator(); GraphicalArray * value = new GraphicalArray( validator ); QLineEdit * lineEdit = findLineEdit(value); QVERIFY( is_not_null(lineEdit) ); // 1. validator objects should be the same QCOMPARE( lineEdit->validator(), validator ); // 2. try to set a null validator value->setValidator(nullptr); QCOMPARE( lineEdit->validator(), (QValidator*) nullptr ); delete validator; validator = new QDoubleValidator(nullptr); // 3. set a new validator value->setValidator(validator); QCOMPARE( lineEdit->validator(), validator ); delete validator; delete value; }
Notifier::Notifier( const Handle<common::PE::Manager>& manager ) : m_manager(manager) { cf3_assert( is_not_null(manager) ); m_observed_queue = m_manager->notification_queue(); }
typename LIB::Ptr library () { const std::string lname = LIB::library_namespace(); //instead of LIB::type_name(); Component::Ptr clib = get_child_ptr(lname); typename LIB::Ptr lib; if ( is_null(clib) ) // doesnt exist so build it { CF::Common::TypeInfo::instance().regist< LIB >( lname ); lib = create_component_ptr< LIB >(lname); cf_assert( is_not_null(lib) ); return lib; } // try to convert existing ptr to LIB::Ptr and return it lib = clib->as_ptr<LIB>(); if( is_null(lib) ) // conversion failed throw CastingFailed( FromHere(), "Found component in CLibraries with name " + lname + " but is not the actual library " + LIB::type_name() ); return lib; }
void ServerNetworkComm::close() { if( is_not_null(m_io_service) ) { m_io_service->stop(); } }
PECommPattern& CField::parallelize() { if ( is_not_null( m_comm_pattern ) ) // return if already parallel return *m_comm_pattern; // Extract gid from the nodes.glb_idx() for only the nodes in the region the fields will use. const CList<Uint>& nodes = used_nodes(); std::vector<Uint> gid; std::vector<Uint> rank; gid.reserve(nodes.size()); rank.reserve(nodes.size()); CMesh& mesh = find_parent_component<CMesh>(*this); boost_foreach (const Uint node, nodes.array()) { cf_assert_desc(to_str(node)+">="+to_str(mesh.nodes().glb_idx().size()), node < mesh.nodes().glb_idx().size()); cf_assert_desc(to_str(node)+">="+to_str(mesh.nodes().rank().size()), node < mesh.nodes().rank().size()); gid.push_back(mesh.nodes().glb_idx()[node]); rank.push_back(mesh.nodes().rank()[node]); } // create the comm pattern and setup the pattern m_comm_pattern = mesh.create_component_ptr<PECommPattern>("comm_pattern_node_based"); m_comm_pattern->insert("gid",gid,1,false); m_comm_pattern->setup(m_comm_pattern->get_child("gid").as_ptr<PEObjectWrapper>(),rank); return parallelize_with(*m_comm_pattern); }
void GraphicalIntTest::test_setValue() { GraphicalInt * value = new GraphicalInt(false); QDoubleSpinBox * spinBox = findSpinBox(value); QVERIFY( is_not_null(spinBox) ); // // 1. check with ints // QVERIFY( value->setValue(-1456) ); QCOMPARE( int(spinBox->value()), -1456 ); QVERIFY( value->setValue(215468548) ); QCOMPARE( int(spinBox->value()), 215468548 ); // // 2. check with other types // QVERIFY( !value->setValue(3.141592) ); QCOMPARE( int(spinBox->value()), 215468548 ); QVERIFY( !value->setValue(true) ); QCOMPARE( int(spinBox->value()), 215468548 ); QVERIFY( !value->setValue("789654123") ); QCOMPARE( int(spinBox->value()), 215468548 ); delete value; }
TreeNode * TreeNode::child(int rowNumber) { TreeNode * child = nullptr; if( is_not_null(m_node) ) { // if the TreeNode corresponding to this child has already been created, // it is returned... if (rowNumber >= 0 && rowNumber < child_count()) child = m_child_nodes.at(rowNumber); // ...otherwise, if the index is valid, it is created and returned... if(child == nullptr && rowNumber>= 0 && rowNumber < child_count()) { Handle< CNode > childNode; childNode = m_node->child(rowNumber); child = new TreeNode(childNode, this, rowNumber); m_child_nodes.replace(rowNumber, child); } } // ...if the index is not valid, return a nullptr pointer return child; }
void GraphicalUintTest::initTestCase() { GraphicalInt * value = new GraphicalInt(false); QVERIFY( is_not_null( findSpinBox(value) ) ); delete value; }
TreeNode::~TreeNode() { if( is_not_null( m_parent ) ) m_parent->remove_child( this ); while(!m_child_nodes.isEmpty()) delete m_child_nodes.takeLast(); }
void GraphicalDoubleTest::initTestCase() { GraphicalDouble * value = new GraphicalDouble(); QVERIFY( is_not_null( findLineEdit(value) ) ); delete value; }
void GraphicalBoolTest::initTestCase() { GraphicalBool * value = new GraphicalBool(); QVERIFY( is_not_null( findCheckBox(value) ) ); delete value; }
Link& Link::link_to ( Component& lnkto ) { if (is_not_null(lnkto.handle<Link>())) throw SetupError(FromHere(), "Cannot link a Link to another Link"); m_link_component = lnkto.handle(); return *this; }
bool UnaryOpExpression::preCompute(const Variant& value, Variant &result) { bool ret = true; try { g_context->setThrowAllErrors(true); auto add = RuntimeOption::IntsOverflowToInts ? cellAdd : cellAddO; auto sub = RuntimeOption::IntsOverflowToInts ? cellSub : cellSubO; switch(m_op) { case '!': result = (!toBoolean(value)); break; case '+': cellSet(add(make_tv<KindOfInt64>(0), *value.asCell()), *result.asCell()); break; case '-': cellSet(sub(make_tv<KindOfInt64>(0), *value.asCell()), *result.asCell()); break; case '~': tvSet(*value.asCell(), *result.asTypedValue()); cellBitNot(*result.asCell()); break; case '@': result = value; break; case T_INT_CAST: result = value.toInt64(); break; case T_DOUBLE_CAST: result = toDouble(value); break; case T_STRING_CAST: result = toString(value); break; case T_BOOL_CAST: result = toBoolean(value); break; case T_EMPTY: result = !toBoolean(value); break; case T_ISSET: result = is_not_null(value); break; case T_INC: case T_DEC: assert(false); default: ret = false; break; } } catch (...) { ret = false; } g_context->setThrowAllErrors(false); return ret; }
void GraphicalBoolTest::test_setValue() { GraphicalBool * value = new GraphicalBool(false); QCheckBox * checkbox = findCheckBox(value); QVERIFY( is_not_null(checkbox) ); // // 1. check with bool values // QVERIFY( value->setValue(true) ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->originalValue().toBool() ); QVERIFY( value->setValue(false) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->originalValue().toBool() ); // // 2. check with strings (those supported by CF::Common::from_str<bool>()) // QVERIFY( value->setValue("true") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("false") ); QVERIFY( !checkbox->isChecked() ); QVERIFY( value->setValue("on") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("off") ); QVERIFY( !checkbox->isChecked() ); QVERIFY( value->setValue("1") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("0") ); QVERIFY( !checkbox->isChecked() ); GUI_CHECK_THROW( value->setValue("ThisIsNotABoolValue"), ParsingFailed ); QVERIFY( !checkbox->isChecked() ); // state should not have changed // // 3. check with other types // QVERIFY( !value->setValue(12) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->setValue(3.141592) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->setValue(-456) ); QVERIFY( !checkbox->isChecked() ); delete value; }
void GraphicalBoolTest::test_constructor() { GraphicalBool * value = new GraphicalBool(false); QCheckBox * checkbox = findCheckBox(value); // 1. value is false, the checkbox should be unchecked QVERIFY( is_not_null(checkbox) ); QVERIFY( !checkbox->isChecked() ); delete value; value = new GraphicalBool(true); checkbox = findCheckBox(value); // 2. value is true, the checkbox should be checked QVERIFY( is_not_null(checkbox) ); QVERIFY( checkbox->isChecked() ); delete value; }
void NetworkQueue::dispatch_signal( const std::string & target, const URI & receiver, SignalArgs &args ) { args.options().flush(); Transaction * transaction = send( args, LOW ); if( is_not_null(transaction) ) transaction->from_script = true; }
void GraphicalDoubleTest::test_constructor() { GraphicalDouble * value = new GraphicalDouble(); QLineEdit * lineEdit = findLineEdit(value); // 1. value is 0.0 (note: converting 0.0 to string gives "0") QVERIFY( is_not_null(lineEdit) ); QCOMPARE( lineEdit->text(), QString("0") ); delete value; value = new GraphicalDouble(3.151492); lineEdit = findLineEdit(value); // 2. value is pi QVERIFY( is_not_null(lineEdit) ); QCOMPARE( lineEdit->text(), QString("3.151492") ); delete value; }
void GraphicalArrayTest::test_constructor() { GraphicalArray * value = new GraphicalArray(); QStringListModel * model = findModel(value); // 1. value is empty, the line edit should be empty as well QVERIFY( is_not_null(model) ); QVERIFY( model->stringList().empty() ); delete value; QIntValidator * validator = new QIntValidator(); value = new GraphicalArray( validator ); QLineEdit * lineEdit = findLineEdit(value); // 2. validator objects should be the same QVERIFY( is_not_null(lineEdit) ); QCOMPARE( lineEdit->validator(), validator ); delete value; delete validator; }
bool SignatureDialog::show( XmlNode & sig, const QString & title, bool block ) { cf3_assert( sig.is_valid() ); XmlNode node( sig.content->first_node() ); QString name; std::string str; rapidxml::xml_node<> * n = sig.content->parent()->parent()->parent()->parent(); if(is_not_null(n)) XML::to_string( n, str ); m_ok_clicked = false; this->setWindowTitle(title); m_data_layout->clear_options(); for( ; node.is_valid() ; node.content = node.content->next_sibling()) { m_data_layout->add( SignalOptions::xml_to_option(node) ); name = node.content->first_attribute( Protocol::Tags::attr_key() )->value(); m_nodes[name] = node; } if( m_data_layout->has_options() ) { if(block) { m_is_blocking = true; this->exec(); } else { m_is_blocking = false; this->setModal(true); this->setVisible(true); } } else { m_ok_clicked = true; emit finished(QDialog::Accepted); } return m_ok_clicked; }
void GraphicalIntTest::test_constructor() { GraphicalInt * value = new GraphicalInt(false); QDoubleSpinBox * spinBox = findSpinBox(value); QVERIFY( is_not_null(spinBox) ); // 1. check the range QCOMPARE( spinBox->minimum(), Consts::int_min() ); QCOMPARE( spinBox->maximum(), Consts::int_max() ); // 2. value is empty, the line edit should be empty as well QCOMPARE( int(spinBox->value()), 0 ); delete value; value = new GraphicalInt(false, 1456); spinBox = findSpinBox(value); // 3. value is not empty QVERIFY( is_not_null(spinBox) ); QCOMPARE( int(spinBox->value()), 1456 ); delete value; }
CSolver& CModel::create_solver( const std::string& builder) { std::string solver_name = Builder::extract_reduced_name(builder); boost::shared_ptr< CSolver > solver = boost::algorithm::contains( builder, "." ) ? build_component_abstract_type< solver::CSolver >( builder, solver_name ) : build_component_abstract_type_reduced< solver::CSolver >( builder, solver_name ); add_component(solver); if(is_not_null(m_implementation->m_physics)) solver->configure_option_recursively(Tags::physical_model(), m_implementation->m_physics); return *solver; }