void AssignOperatorSignatureCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. if (getLangOpts().CPlusPlus) { const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType( pointee(unless(isConstQualified()), hasDeclaration(equalsBoundNode("class")))))); const auto IsSelf = qualType(anyOf( hasDeclaration(equalsBoundNode("class")), referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))); const auto IsSelfAssign = methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())), hasName("operator="), ofClass(recordDecl().bind("class")), hasParameter(0, parmVarDecl(hasType(IsSelf)))) .bind("method"); Finder->addMatcher( methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"), this); const auto BadSelf = referenceType( anyOf(lValueReferenceType(pointee(unless(isConstQualified()))), rValueReferenceType(pointee(isConstQualified())))); Finder->addMatcher( methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf)))) .bind("ArgumentType"), this); Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this); } }
void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) { registerMatchersImpl(Finder, functionDecl(isExternC(), returns(isInteger()), hasName("socket"), hasParameter(0, hasType(isInteger())), hasParameter(1, hasType(isInteger())), hasParameter(2, hasType(isInteger())))); }
void FoldInitTypeCheck::registerMatchers(MatchFinder *Finder) { // We match functions of interest and bind the iterator and init value types. // Note: Right now we check only builtin types. const auto BuiltinTypeWithId = [](const char *ID) { return hasCanonicalType(builtinType().bind(ID)); }; const auto IteratorWithValueType = [&BuiltinTypeWithId](const char *ID) { return anyOf( // Pointer types. pointsTo(BuiltinTypeWithId(ID)), // Iterator types. recordType(hasDeclaration(has(typedefNameDecl( hasName("value_type"), hasType(BuiltinTypeWithId(ID))))))); }; const auto IteratorParam = parmVarDecl( hasType(hasCanonicalType(IteratorWithValueType("IterValueType")))); const auto Iterator2Param = parmVarDecl( hasType(hasCanonicalType(IteratorWithValueType("Iter2ValueType")))); const auto InitParam = parmVarDecl(hasType(BuiltinTypeWithId("InitType"))); // std::accumulate, std::reduce. Finder->addMatcher( callExpr(callee(functionDecl( hasAnyName("::std::accumulate", "::std::reduce"), hasParameter(0, IteratorParam), hasParameter(2, InitParam))), argumentCountIs(3)) .bind("Call"), this); // std::inner_product. Finder->addMatcher( callExpr(callee(functionDecl(hasName("::std::inner_product"), hasParameter(0, IteratorParam), hasParameter(2, Iterator2Param), hasParameter(3, InitParam))), argumentCountIs(4)) .bind("Call"), this); // std::reduce with a policy. Finder->addMatcher( callExpr(callee(functionDecl(hasName("::std::reduce"), hasParameter(1, IteratorParam), hasParameter(3, InitParam))), argumentCountIs(4)) .bind("Call"), this); // std::inner_product with a policy. Finder->addMatcher( callExpr(callee(functionDecl(hasName("::std::inner_product"), hasParameter(1, IteratorParam), hasParameter(3, Iterator2Param), hasParameter(4, InitParam))), argumentCountIs(5)) .bind("Call"), this); }
void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) { auto SockAddrPointerType = hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr")))); auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t")))); registerMatchersImpl(Finder, functionDecl(returns(isInteger()), hasName("accept"), hasParameter(0, hasType(isInteger())), hasParameter(1, SockAddrPointerType), hasParameter(2, SockLenPointerType))); }
void UnconventionalAssignOperatorCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. if (!getLangOpts().CPlusPlus) return; const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType( pointee(unless(isConstQualified()), anyOf(autoType(), hasDeclaration(equalsBoundNode("class"))))))); const auto IsSelf = qualType( anyOf(hasDeclaration(equalsBoundNode("class")), referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))); const auto IsAssign = cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())), hasName("operator="), ofClass(recordDecl().bind("class"))) .bind("method"); const auto IsSelfAssign = cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf)))) .bind("method"); Finder->addMatcher( cxxMethodDecl(IsAssign, unless(HasGoodReturnType)).bind("ReturnType"), this); const auto BadSelf = referenceType( anyOf(lValueReferenceType(pointee(unless(isConstQualified()))), rValueReferenceType(pointee(isConstQualified())))); Finder->addMatcher( cxxMethodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf)))) .bind("ArgumentType"), this); Finder->addMatcher( cxxMethodDecl(IsSelfAssign, anyOf(isConst(), isVirtual())).bind("cv"), this); const auto IsBadReturnStatement = returnStmt(unless(has(ignoringParenImpCasts( anyOf(unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())), cxxOperatorCallExpr(argumentCountIs(1), callee(unresolvedLookupExpr()), hasArgument(0, cxxThisExpr()))))))); const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType); Finder->addMatcher(returnStmt(IsBadReturnStatement, forFunction(IsGoodAssign)) .bind("returnStmt"), this); }
bool ParameterReflection::addEvent(std::string const& name, std::string const& expression) { if (hasParameter(name)) { CONTROLIT_ERROR << "Parameter " << name << " already exists in " << getInstanceName(); return false; } Event event; event.name = name; event.condition.SetExpr(expression); event.condition.SetVarFactory(VariableFactory<ParameterReflection>, this); event.condition.DefineNameChars("0123456789_." "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); event.enabled = true; events.push_back(event); // Record event as a new parameter addParameter(name, new double(0.0)); PRINT_INFO("Added event '" << name << "', expression '" << expression << "'"); return true; }
void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) { // Forwarding references require C++11 or later. if (!getLangOpts().CPlusPlus11) return; auto ForwardingRefParm = parmVarDecl( hasType(qualType(rValueReferenceType(), references(templateTypeParmType(hasDeclaration( templateTypeParmDecl().bind("type-parm-decl")))), unless(references(isConstQualified()))))) .bind("parm-var"); DeclarationMatcher findOverload = cxxConstructorDecl( hasParameter(0, ForwardingRefParm), unless(hasAnyParameter( // No warning: enable_if as constructor parameter. parmVarDecl(hasType(isEnableIf())))), unless(hasParent(functionTemplateDecl(has(templateTypeParmDecl( // No warning: enable_if as type parameter. hasDefaultArgument(isEnableIf()))))))) .bind("ctor"); Finder->addMatcher(findOverload, this); }
Parameter *Parameters::getParameter(const char *name) { char upperName[256]; upperString(upperName,name); if(!hasParameter(upperName)) return NULL; return m_map[upperName]; }
unsigned int AmConfigReader::getParameterInt(const string& param, unsigned int defval) const { unsigned int result=0; if(!hasParameter(param) || str2i(getParameter(param),result)) return defval; else return result; }
void VariableSet::addParameter(QString name, double value) { if (hasParameter(name)) { DBGA("Parameter " << name.latin1() << " already present!"); assert(0); return; } mParameters.push_back(SearchParameter(name, value)); }
int isMacro(MacroTable* macroTable, char* name){ int i; //strcat(name,":"); for(i=0;i<macroTable->last_; i++){ if(findLabelName(macroTable,name) != -1){ if(hasParameter(macroTable,name)==1) return 2; else return 1; } } return 0; }
void UseToStringCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) return; Finder->addMatcher( callExpr( hasDeclaration(functionDecl( returns(hasDeclaration(classTemplateSpecializationDecl( hasName("std::basic_string"), hasTemplateArgument(0, templateArgument().bind("char_type"))))), hasName("boost::lexical_cast"), hasParameter(0, hasType(qualType(has(substTemplateTypeParmType( isStrictlyInteger()))))))), argumentCountIs(1), unless(isInTemplateInstantiation())) .bind("to_string"), this); }
int AmConfigReader::loadFile(const string& path) { FILE* fp = fopen(path.c_str(),"r"); if(!fp){ WARN("could not open configuration file '%s': %s\n", path.c_str(),strerror(errno)); return -1; } int lc = 0; int ls = 0; char lb[MAX_CONFIG_LINE] = {'\0'}; char *c,*key_beg,*key_end,*val_beg,*val_end,*inc_beg,*inc_end; c=key_beg=key_end=val_beg=val_end=inc_beg=inc_end=0; while(!feof(fp) && ((ls = fifo_get_line(fp, lb, MAX_CONFIG_LINE)) != -1)){ c=key_beg=key_end=val_beg=val_end=0; lc++; c = lb; TRIM(c); if(IS_EOL(*c)) continue; if (*c == '@') { /* process included config file */ c++; TRIM(c); inc_beg = c++; while( !IS_EOL(*c) && !IS_SPACE(*c) ) c++; inc_end = c; string fname = string(inc_beg,inc_end-inc_beg); if (fname.length() && fname[0] != '/') fname = AmConfig::ModConfigPath + fname; if(loadFile(fname)) goto error; continue; } key_beg = c; while( (*c != '=') && !IS_SPACE(*c) ) c++; key_end = c; if(IS_SPACE(*c)) TRIM(c); else if( !(c - key_beg) ) goto syntax_error; if(*c != '=') goto syntax_error; c++; TRIM(c); if(*c == '"'){ char last_c = ' '; val_beg = ++c; while( ((*c != '"') || (last_c == '\\')) && (*c != '\0') ) { last_c = *c; c++; } if(*c == '\0') goto syntax_error; val_end = c; } else { val_beg = c; while( !IS_EOL(*c) && !IS_SPACE(*c) ) c++; val_end = c; } if((key_beg < key_end) && (val_beg <= val_end)) { string keyname = string(key_beg,key_end-key_beg); string val = string(val_beg,val_end-val_beg); if (hasParameter(keyname)) { WARN("while loading '%s': overwriting configuration " "'%s' value '%s' with '%s'\n", path.c_str(), keyname.c_str(), getParameter(keyname).c_str(), val.c_str()); } keys[keyname] = val; // small hack to make include work with right path if (keyname == "plugin_config_path") AmConfig::ModConfigPath = val; } else goto syntax_error; } fclose(fp); return 0; syntax_error: ERROR("syntax error line %i in %s\n",lc,path.c_str()); error: fclose(fp); return -1; }
int AmConfigReader::loadString(const char* cfg_lines, size_t cfg_len) { int lc = 0; int ls = 0; char lb[MAX_CONFIG_LINE] = {'\0'}; char *c,*key_beg,*key_end,*val_beg,*val_end,*inc_beg,*inc_end; const char* cursor = cfg_lines; const char* cfg_end = cursor + cfg_len; c=key_beg=key_end=val_beg=val_end=inc_beg=inc_end=0; while((cursor < cfg_end) && ((ls = str_get_line(&cursor, cfg_end, lb, MAX_CONFIG_LINE)) != -1)){ c=key_beg=key_end=val_beg=val_end=0; lc++; c = lb; TRIM(c); if(IS_EOL(*c)) continue; key_beg = c; while( (*c != '=') && !IS_SPACE(*c) ) c++; key_end = c; if(IS_SPACE(*c)) TRIM(c); else if( !(c - key_beg) ) goto syntax_error; if(*c != '=') goto syntax_error; c++; TRIM(c); if(*c == '"'){ char last_c = ' '; val_beg = ++c; while( ((*c != '"') || (last_c == '\\')) && (*c != '\0') ) { last_c = *c; c++; } if(*c == '\0') goto syntax_error; val_end = c; } else { val_beg = c; while( !IS_EOL(*c) && !IS_SPACE(*c) ) c++; val_end = c; } if((key_beg < key_end) && (val_beg <= val_end)) { string keyname = string(key_beg,key_end-key_beg); string val = string(val_beg,val_end-val_beg); if (hasParameter(keyname)) { WARN("while loading string: overwriting configuration " "'%s' value '%s' with '%s'\n", keyname.c_str(), getParameter(keyname).c_str(), val.c_str()); } keys[keyname] = val; } else goto syntax_error; } return 0; syntax_error: ERROR("syntax error line %i\n",lc); return -1; }
void gamehsp::setMaterialDefaultBinding( Material* material, int icolor, int matopt ) { // These parameters are normally set in a .material file but this example sets them programmatically. // Bind the uniform "u_worldViewProjectionMatrix" to use the WORLD_VIEW_PROJECTION_MATRIX from the scene's active camera and the node that the model belongs to. // material->getParameter("u_worldViewProjectionMatrix")->setValue( _camera->getWorldViewProjectionMatrix() ); // material->getParameter("u_inverseTransposeWorldViewMatrix")->setValue( _camera->getInverseTransposeWorldViewMatrix() ); // material->getParameter("u_cameraPosition")->setValue( _camera->getTranslation() ); // material->getParameter("u_worldViewProjectionMatrix")->bindValue( _camera, &Node::getWorldViewProjectionMatrix ); // material->getParameter("u_inverseTransposeWorldViewMatrix")->bindValue( _camera, &Node::getInverseTransposeWorldViewMatrix ); // material->getParameter("u_cameraPosition")->bindValue( _camera, &Node::getTranslation ); if ( hasParameter( material, "u_cameraPosition" ) ) material->setParameterAutoBinding("u_cameraPosition", "CAMERA_WORLD_POSITION"); if ( hasParameter( material, "u_worldViewProjectionMatrix" ) ) material->setParameterAutoBinding("u_worldViewProjectionMatrix", "WORLD_VIEW_PROJECTION_MATRIX"); if ( hasParameter( material, "u_inverseTransposeWorldViewMatrix" ) ) material->setParameterAutoBinding("u_inverseTransposeWorldViewMatrix", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX"); Vector4 color; Node *light_node; if ( _curlight < 0 ) { // カレントライトなし(シーンを参照) if ( hasParameter( material, "u_ambientColor" ) ) material->setParameterAutoBinding("u_ambientColor", "SCENE_AMBIENT_COLOR"); if ( hasParameter( material, "u_lightDirection" ) ) material->setParameterAutoBinding("u_lightDirection", "SCENE_LIGHT_DIRECTION"); if ( hasParameter( material, "u_lightColor" ) ) material->setParameterAutoBinding("u_lightColor", "SCENE_LIGHT_COLOR"); } else { // カレントライトを反映させる gpobj *lgt; lgt = getObj( _curlight ); light_node = lgt->_node; // ライトの方向設定 if ( hasParameter( material, "u_lightDirection" ) ) material->getParameter("u_lightDirection")->bindValue(light_node, &Node::getForwardVectorView); // ライトの色設定 // (リアルタイムに変更を反映させる場合は再設定が必要。現在は未対応) Vector3 *vambient; vambient = (Vector3 *)&lgt->_vec[GPOBJ_USERVEC_WORK]; if ( hasParameter( material, "u_lightColor" ) ) material->getParameter("u_lightColor")->setValue(light_node->getLight()->getColor()); if ( hasParameter( material, "u_ambientColor" ) ) material->getParameter("u_ambientColor")->setValue( vambient ); } //material->setParameterAutoBinding("u_ambientColor", "SCENE_AMBIENT_COLOR"); //material->setParameterAutoBinding("u_lightDirection", "SCENE_LIGHT_DIRECTION"); //material->setParameterAutoBinding("u_lightColor", "SCENE_LIGHT_COLOR"); colorVector3( icolor, color ); if ( hasParameter( material, "u_diffuseColor" ) ) material->getParameter("u_diffuseColor")->setValue(color); gameplay::MaterialParameter *prm_modalpha; if ( hasParameter( material, "u_modulateAlpha" ) ) prm_modalpha = material->getParameter("u_modulateAlpha"); if ( prm_modalpha ) { prm_modalpha->setValue( 1.0f ); } RenderState::StateBlock *state; state = material->getStateBlock(); state->setCullFace( (( matopt & GPOBJ_MATOPT_NOCULL )==0) ); state->setDepthTest( (( matopt & GPOBJ_MATOPT_NOZTEST )==0) ); state->setDepthWrite( (( matopt & GPOBJ_MATOPT_NOZWRITE )==0) ); state->setBlend(true); if ( matopt & GPOBJ_MATOPT_BLENDADD ) { state->setBlendSrc(RenderState::BLEND_SRC_ALPHA); state->setBlendDst(RenderState::BLEND_ONE); } else { state->setBlendSrc(RenderState::BLEND_SRC_ALPHA); state->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA); } }
int main(int argc, char** argv){ /* no image entered into stdin */ if(argc < 1){ printw("Image file must be entered as standard input!\n"); endwin(); exit(-1); } WINDOW* win = initscr(); start_color(); if(!has_colors()){ printf("No color available!"); endwin(); exit(-1); } /* original array of original image */ struct pixel* dataArray; /* array after being averaged */ struct pixel* averagedArray; /* file not found */ FILE* fp; if(!(fp = fopen(argv[1],"rb"))){ printw("File not found\n"); exit(-1); } unsigned int dataOffset = getDataOffset(fp); unsigned int height = getHeight(fp); unsigned int width = getWidth(fp); unsigned int size = height*width; printw("%d",dataOffset); dataArray = malloc(sizeof(struct pixel) * size); dataArray = getDataArray(fp, dataOffset, size); averagedArray = getAveragedArray(dataArray, size, height, width); /*printArray(dataArray, size, height, width); printArray(averagedArray, ceil(ceil(size/8)/14), height/14, width/8);*/ /*printColor(averagedArray, ceil(ceil(size/8)/14));*/ if(!can_change_color || hasParameter(argc, argv, "-8")){ displayImageColor(averagedArray,ceil(ceil(size/8)/17),ceil(width/8),ceil(height/17)); } else if(can_change_color() && hasParameter(argc, argv, "-bw")){ displayImageGreyScale(averagedArray,ceil(ceil(size/8)/17), ceil(width/8), ceil(height/17)); } else if(can_change_color()){ displayImage16Color(averagedArray,ceil(ceil(size/8)/17),ceil(width/8),ceil(height/17)); } free(dataArray); free(averagedArray); refresh(); getch(); endwin(); }
bool AbstractExpression::initParamShortCircuits() { return (m_hasParameter = hasParameter()); }
bool contentTypeField::hasReportType() const { return hasParameter("report-type"); }
bool contentTypeField::hasCharset() const { return hasParameter("charset"); }
bool contentTypeField::hasBoundary() const { return hasParameter("boundary"); }
void CloexecDupCheck::registerMatchers(MatchFinder *Finder) { registerMatchersImpl(Finder, functionDecl(returns(isInteger()), hasName("dup"), hasParameter(0, hasType(isInteger())))); }
/** * Clear the vector of strings and then add pairs of strings giving information * about the specified point, x, y. The first string in a pair should * generally be a string describing the value being presented and the second * string should contain the value. * * @param x The x-coordinate of the point of interest in the data. * @param y The y-coordinate of the point of interest in the data. * @param list Vector that will be filled out with the information strings. */ void MatrixWSDataSource::getInfoList( double x, double y, std::vector<std::string> &list ) { // First get the info that is always available for any matrix workspace list.clear(); int row = (int)y; restrictRow( row ); const ISpectrum* spec = m_matWs->getSpectrum( row ); double spec_num = spec->getSpectrumNo(); SVUtils::PushNameValue( "Spec Num", 8, 0, spec_num, list ); std::string x_label = ""; Unit_sptr& old_unit = m_matWs->getAxis(0)->unit(); if ( old_unit != 0 ) { x_label = old_unit->caption(); SVUtils::PushNameValue( x_label, 8, 3, x, list ); } std::set<detid_t> ids = spec->getDetectorIDs(); if ( !ids.empty() ) { list.push_back("Det ID"); const int64_t id = static_cast<int64_t>(*(ids.begin())); list.push_back(boost::lexical_cast<std::string>(id)); } /* Now try to do various unit conversions to get equivalent info */ /* first make sure we can get the needed information */ if ( !(m_instrument && m_source && m_sample) ) { return; } try { if ( old_unit == 0 ) { g_log.debug("No UNITS on MatrixWorkspace X-axis"); return; } auto det = m_matWs->getDetector( row ); if ( det == 0 ) { g_log.debug() << "No DETECTOR for row " << row << " in MatrixWorkspace" << std::endl; return; } double l1 = m_source->getDistance(*m_sample); double l2 = 0.0; double two_theta = 0.0; double azi = 0.0; if ( det->isMonitor() ) { l2 = det->getDistance(*m_source); l2 = l2-l1; } else { l2 = det->getDistance(*m_sample); two_theta = m_matWs->detectorTwoTheta(det); azi = det->getPhi(); } SVUtils::PushNameValue( "L2", 8, 4, l2, list ); SVUtils::PushNameValue( "TwoTheta", 8, 2, two_theta*180./M_PI, list ); SVUtils::PushNameValue( "Azimuthal", 8, 2, azi*180./M_PI, list ); /* For now, only support diffractometers and monitors. */ /* We need a portable way to determine emode and */ /* and efixed that will work for any matrix workspace! */ int emode = 0; double efixed = 0.0; double delta = 0.0; // First try to get emode & efixed from the user if ( m_emodeHandler != NULL ) { efixed = m_emodeHandler->getEFixed(); if ( efixed != 0 ) { emode = m_emodeHandler->getEMode(); if ( emode == 0 ) { g_log.information("EMode invalid, spectrometer needed if emode != 0"); g_log.information("Assuming Direct Geometry Spectrometer...."); emode = 1; } } } // Did NOT get emode & efixed from user, try getting direct geometry information from the run object if ( efixed == 0 ) { const API::Run & run = m_matWs->run(); if ( run.hasProperty("Ei") ) { Kernel::Property* prop = run.getProperty("Ei"); efixed = boost::lexical_cast<double,std::string>(prop->value()); emode = 1; // only correct if direct geometry } else if ( run.hasProperty("EnergyRequested") ) { Kernel::Property* prop = run.getProperty("EnergyRequested"); efixed = boost::lexical_cast<double,std::string>(prop->value()); emode = 1; } else if ( run.hasProperty("EnergyEstimate") ) { Kernel::Property* prop = run.getProperty("EnergyEstimate"); efixed = boost::lexical_cast<double,std::string>(prop->value()); emode = 1; } } // Finally, try getting indirect geometry information from the detector object if ( efixed == 0 ) { if ( !(det->isMonitor() && det->hasParameter("Efixed"))) { try { const ParameterMap& pmap = m_matWs->constInstrumentParameters(); Parameter_sptr par = pmap.getRecursive(det.get(),"Efixed"); if (par) { efixed = par->value<double>(); emode = 2; } } catch ( std::runtime_error& ) { g_log.debug() << "Failed to get Efixed from detector ID: " << det->getID() << " in MatrixWSDataSource" << std::endl; efixed = 0; } } } if ( efixed == 0 ) emode = 0; if ( m_emodeHandler != NULL ) { m_emodeHandler -> setEFixed( efixed ); m_emodeHandler -> setEMode ( emode ); } double tof = old_unit->convertSingleToTOF( x, l1, l2, two_theta, emode, efixed, delta ); if ( ! (x_label == "Time-of-flight") ) SVUtils::PushNameValue( "Time-of-flight", 8, 1, tof, list ); if ( ! (x_label == "Wavelength") ) { const Unit_sptr& wl_unit = UnitFactory::Instance().create("Wavelength"); double wavelength = wl_unit->convertSingleFromTOF( tof, l1, l2, two_theta, emode, efixed, delta ); SVUtils::PushNameValue( "Wavelength", 8, 4, wavelength, list ); } if ( ! (x_label == "Energy") ) { const Unit_sptr& e_unit = UnitFactory::Instance().create("Energy"); double energy = e_unit->convertSingleFromTOF( tof, l1, l2, two_theta, emode, efixed, delta ); SVUtils::PushNameValue( "Energy", 8, 4, energy, list ); } if ( (! (x_label == "d-Spacing")) && (two_theta != 0.0) && ( emode == 0 ) ) { const Unit_sptr& d_unit = UnitFactory::Instance().create("dSpacing"); double d_spacing = d_unit->convertSingleFromTOF( tof, l1, l2, two_theta, emode, efixed, delta ); SVUtils::PushNameValue( "d-Spacing", 8, 4, d_spacing, list ); } if ( (! (x_label == "q")) && (two_theta != 0.0) ) { const Unit_sptr& q_unit=UnitFactory::Instance().create("MomentumTransfer"); double mag_q = q_unit->convertSingleFromTOF( tof, l1, l2, two_theta, emode, efixed, delta ); SVUtils::PushNameValue( "|Q|", 8, 4, mag_q, list ); } if ( (! (x_label == "DeltaE")) && (two_theta != 0.0) && ( emode != 0 ) ) { const Unit_sptr& deltaE_unit=UnitFactory::Instance().create("DeltaE"); double delta_E = deltaE_unit->convertSingleFromTOF( tof, l1, l2, two_theta, emode, efixed, delta ); SVUtils::PushNameValue( "DeltaE", 8, 4, delta_E, list ); } } catch (std::exception & e) { g_log.debug() << "Failed to get information from Workspace:" << e.what() << std::endl; } }