Exemplo n.º 1
0
void RootManager::uninitializeRootObject()
{
    SLM_TRACE_FUNC();
    SLM_WARN_IF("(Hack) Sorry, the OSR must be initialized to uninitialize it. ToDo => transform in assert", ! getDefault()->m_isRootInitialized );
    if ( getDefault()->m_isRootInitialized )
    {
        // Setting initialization to false
        getDefault()->m_isRootInitialized = false ;

        assert( getDefault()->m_rootObjectConfigurationName.first ) ;
        // Stop services reported in m_rootObjectConfiguration before stopping everything

        //::fwServices::stopAndUnregister(getDefault()->m_rootObjectConfiguration) ;
        getDefault()->m_ctm->stopAndDestroy();

        OSLM_WARN_IF("Sorry, few services still exist before erasing root object ( cf debug following message )"
                << std::endl << ::fwServices::OSR::getRegistryInformation(),
                ! ::fwServices::OSR::getKSContainer().empty());

        //::fwServices::GlobalEventManager::getDefault()->clearMessages();

        SLM_TRACE("uninitializeRootObject : Reset the last shared_ptr on root object.");

        // Reset the root object: involve complete m_container clearing
        //getDefault()->m_rootObject.reset();
        //assert( getDefault()->m_rootObject.use_count() == 0 );

//        ::fwRuntime::profile::Profile::sptr profile = ::fwRuntime::profile::getCurrentProfile();
//        SLM_TRACE("Stopping Profile");
//        profile->stop();
//        SLM_TRACE("Profile Stopped");
    }
}
Exemplo n.º 2
0
RenderType intToRenderType(const int mode)
{
    if (mode < 0 || mode >= RENDER_LAST)
        return getDefault();

    if (mode != RENDER_SOFTWARE
#if defined(USE_OPENGL) && defined(ANDROID) && defined(USE_SDL2)
        && mode != RENDER_GLES_OPENGL
        && mode != RENDER_SDL2_DEFAULT)
#elif defined(USE_OPENGL) && defined(ANDROID) && !defined(USE_SDL2)
        && mode != RENDER_GLES_OPENGL)
#elif defined(USE_OPENGL) && !defined(ANDROID) && defined(USE_SDL2)
        && mode != RENDER_NORMAL_OPENGL
        && mode != RENDER_MODERN_OPENGL
        && mode != RENDER_SAFE_OPENGL
        && mode != RENDER_GLES_OPENGL
        && mode != RENDER_SDL2_DEFAULT)
#elif !defined(USE_OPENGL) && defined(USE_SDL2)
        && mode != RENDER_SDL2_DEFAULT)
#elif !defined(USE_OPENGL) && !defined(USE_SDL2)
        )
#elif defined(USE_OPENGL) && !defined(ANDROID) && !defined(USE_SDL2)
        && mode != RENDER_NORMAL_OPENGL
        && mode != RENDER_MODERN_OPENGL
        && mode != RENDER_SAFE_OPENGL
        && mode != RENDER_GLES_OPENGL)
#endif
    {
        return getDefault();
    }

    return static_cast<RenderType>(mode);
}
Exemplo n.º 3
0
void RootManager::initializeRootObject()
{
    SLM_ASSERT("Sorry, the OSR is already initialized.", ! getDefault()->m_isRootInitialized );
    SLM_ASSERT("Sorry, configuration name parameter is not initialized.", getDefault()->m_rootObjectConfigurationName.first );
    SLM_ASSERT("Sorry, configuration file parameter is not initialized.", getDefault()->m_rootObjectConfigurationFile.first );

    // ToDo Correct this hack
    // Load another "pseudo" bundle
    ::boost::filesystem::path filePath ( getDefault()->m_rootObjectConfigurationFile.second );
    SPTR(::fwRuntime::Bundle) configBundle = ::fwRuntime::io::BundleDescriptorReader::createBundleFromXmlPlugin( filePath );
    ::fwRuntime::Runtime::getDefault()->addBundle( configBundle );
    configBundle->setEnable( true );

    // Validate bundle
    ::fwRuntime::Bundle::ExtensionConstIterator iter = configBundle->extensionsBegin();
    while( iter != configBundle->extensionsEnd() )
    {
        ::fwRuntime::Extension::Validity isValid = (*iter)->validate();
        OSLM_FATAL_IF("Sorry, extension " << (*iter)->getIdentifier() << " is not valid.", isValid == ::fwRuntime::Extension::Invalid );
        iter++;
    }

    // Register service config
    getDefault()->m_ctm = AppConfigManager::New();
    ::fwRuntime::ConfigurationElement::csptr config = ::fwServices::registry::AppConfig::getDefault()->getStandardConfig( getDefault()->m_rootObjectConfigurationName.second );
    getDefault()->m_ctm->setConfig( ::fwRuntime::ConfigurationElement::constCast( config ) );
    getDefault()->m_ctm->launch();
    getDefault()->m_isRootInitialized = true;
}
void
SoTextureCoordinateBindingElement::init(SoState *)
//
////////////////////////////////////////////////////////////////////////
{
    data = getDefault();
}
Exemplo n.º 5
0
std::string colors::Colors::toString(colors::ColorEnum color)
{
	std::string color_name;
	switch (color)
	{
		case ORANGE:
			color_name = "ORANGE";
			break;
		case YELLOW:
			color_name = "YELLOW";
			break;
		case BLUE:
			color_name = "BLUE";
			break;
		case GREEN:
			color_name = "GREEN";
			break;
		case RED:
			color_name = "RED";
			break;
		case BLACK:
			color_name = "BLACK";
			break;
		case PINK:
			color_name = "PINK";
			break;
		case PURPLE:
			color_name = "PURPLE";
			break;
		default:
			color_name = toString(getDefault());
	}
	return color_name;
}
Exemplo n.º 6
0
int colors::Colors::toCode(colors::ColorEnum color)
{
	int color_code;
	switch (color)
	{
		case ORANGE:
			color_code = 0;
			break;
		case YELLOW:
			color_code = 1;
			break;
		case BLUE:
			color_code = 2;
			break;
		case GREEN:
			color_code = 3;
			break;
		case RED:
			color_code = 4;
			break;
		case BLACK:
			color_code = 5;
			break;
		case PINK:
			color_code = 6;
			break;
		case PURPLE:
			color_code = 7;
			break;
		default:			
			color_code = toCode(getDefault());
	}
	return color_code;
}
Exemplo n.º 7
0
 bool ParserIntItem::equal(const ParserIntItem& other) const
 {
     if (ParserItem::equal(other) && (getDefault() == other.getDefault()))
         return true;
     else
         return false;
 }
Exemplo n.º 8
0
int unifei::expertinos::mrta_vc::tasks::SkillLevels::toCode(unifei::expertinos::mrta_vc::tasks::levels::SkillLevelEnum enumerated)
{
	int code;
	switch (enumerated)
	{
		case unifei::expertinos::mrta_vc::tasks::levels::NONE:
			code = 0;
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::LOW:
			code = 1;
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::MODERATE:
			code = 2;
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::HIGH:
			code = 3;
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::RESOURCEFUL:
			code = 4;
			break;
		default:			
			code = toCode(getDefault());
	}
	return code;
}
Exemplo n.º 9
0
bool PhpParam::defValueNeedsVariable() const {
  DataType cppKindOf = kindOf();

  if (!hasDefault() || !isIndirectPass()) {
    return false;
  }

  fbstring defVal = getDefault();

  if (cppKindOf == KindOfString &&
      ((defVal == "empty_string") ||
       (defVal == "null_string") ||
       (g_knownStringConstants.count(defVal) > 0))) {
    return false;
  }
  if ((cppKindOf == KindOfArray) && (defVal == "null_array")) {
    return false;
  }
  if ((cppKindOf == KindOfObject) && (defVal == "null_object")) {
    return false;
  }
  if ((cppKindOf == KindOfResource) && (defVal == "null_resource")) {
    return false;
  }
  if ((cppKindOf == KindOfAny) && (defVal == "null_variant")) {
    return false;
  }

  return true;
}
Exemplo n.º 10
0
std::string unifei::expertinos::mrta_vc::tasks::SkillLevels::toString(unifei::expertinos::mrta_vc::tasks::levels::SkillLevelEnum enumerated)
{
	std::string enumerated_name;
	switch (enumerated)
	{
		case unifei::expertinos::mrta_vc::tasks::levels::NONE:
			enumerated_name = "NONE";
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::LOW:
			enumerated_name = "LOW";
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::MODERATE:
			enumerated_name = "MODERATE";
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::HIGH:
			enumerated_name = "HIGH";
			break;
		case unifei::expertinos::mrta_vc::tasks::levels::RESOURCEFUL:
			enumerated_name = "RESOURCEFUL";
			break;
		default:
			enumerated_name = toString(getDefault());
	}
	return enumerated_name;
}
Exemplo n.º 11
0
U_NAMESPACE_BEGIN

UnicodeString&
Locale::getDisplayLanguage(UnicodeString& dispLang) const
{
    return this->getDisplayLanguage(getDefault(), dispLang);
}
void
SoNormalBindingElement::init(SoState *)
//
////////////////////////////////////////////////////////////////////////
{
    data = getDefault();
}
Exemplo n.º 13
0
unifei::expertinos::mrta_vc::tasks::levels::SkillLevelEnum unifei::expertinos::mrta_vc::tasks::SkillLevels::toEnumerated(int code)
{
	unifei::expertinos::mrta_vc::tasks::levels::SkillLevelEnum enumerated;
	switch (code)
	{
		case 0:
			enumerated = unifei::expertinos::mrta_vc::tasks::levels::NONE;
			break;
		case 1:
			enumerated = unifei::expertinos::mrta_vc::tasks::levels::LOW;
			break;
		case 2:
			enumerated = unifei::expertinos::mrta_vc::tasks::levels::MODERATE;
			break;
		case 3:
			enumerated = unifei::expertinos::mrta_vc::tasks::levels::HIGH;
			break;
		case 4:
			enumerated = unifei::expertinos::mrta_vc::tasks::levels::RESOURCEFUL;
			break;
		default:
			enumerated = getDefault();
	}
	return enumerated;
}
void
SoLightAttenuationElement::init(SoState *)
//
////////////////////////////////////////////////////////////////////////
{
    attenuation = getDefault();
}
Exemplo n.º 15
0
void WebyPlugin::getResults(QList<InputData>* id, QList<CatItem>* results)
{
	if (id->last().hasLabel(HASH_WEBSITE)) {
		const QString & text = id->last().getText();
		// This is a website, create an entry for it
		results->push_front(CatItem(text + ".weby", text, HASH_WEBY, getIcon()));
	}

	if (id->count() > 1 && (unsigned int) id->first().getTopResult().id == HASH_WEBY) {
		const QString & text = id->last().getText();
		// This is user search text, create an entry for it
		results->push_front(CatItem(text + ".weby", text, HASH_WEBY, getIcon()));
	}

	// If we don't have any results, add default
	if (results->size() == 0 && id->count() <= 1) {
		const QString & text = id->last().getText();
		if (text != "") {
			QString name = getDefault().name;
			if (name != "")
				results->push_back(CatItem(text + ".weby", name, HASH_WEBY, getIcon()));
		}
	}


}
Exemplo n.º 16
0
 bool ParserIntItem::equal(const ParserItem& other) const
 {
     // cast to a pointer to avoid bad_cast exception
     const ParserIntItem* rhs = dynamic_cast<const ParserIntItem*>(&other);
     if (rhs && ParserItem::equal(other) && (getDefault() == rhs->getDefault()))
         return true;
     else
         return false;
 }
Exemplo n.º 17
0
void
SoTextureImageElement::init(SoState *state)
//
////////////////////////////////////////////////////////////////////////
{
    SoReplacedElement::init(state);

    bytes = getDefault(size, numComponents);
}
Exemplo n.º 18
0
    std::string ParserDoubleItem::createCode() const {
        std::stringstream ss;

        ss << "new ParserDoubleItem(" << "\"" << name() << "\"" << ",Opm::" << ParserItemSizeEnum2String( sizeType() );
        if (m_defaultSet)
            ss << "," << boost::lexical_cast<std::string>(getDefault());
        ss << ")";

        return ss.str();
    }
Exemplo n.º 19
0
    std::string ParserIntItem::createCode() const {
        std::stringstream ss;

        ss << "new ParserIntItem(" << "\"" << name() << "\"" << ",Opm::" << ParserItemSizeEnum2String( sizeType() );
        if (m_defaultSet)
            ss << "," << getDefault();
        ss << ")";

        return ss.str();
    }
Exemplo n.º 20
0
    const Otype &getOptionParser(const String&name)const {
        typename OptionMap::const_iterator where=mOptionParsers.find(name);
        if (where==mOptionParsers.end()) {
            if (name.length()==0&&getDefault().length()) {
                return getDefaultOptionParser();
            }
            return mNop;
        }

        return where->second;
        
    }
Exemplo n.º 21
0
    void SensorImpl::setEnabled(const bool enabled)
    {
        if (enabled == isEnabled() || !isAvailable())
            return;

        if (enabled)
        {
            if (ASensorEventQueue_enableSensor(ns_sensorEventQueue, getDefault(m_type)) >= 0)
            {
                m_sensor = getDefault(m_type);

                if (auto rate = ASensor_getMinDelay(m_sensor))
                    ASensorEventQueue_setEventRate(ns_sensorEventQueue, m_sensor, rate);
            }
        }
        else
        {
            ASensorEventQueue_disableSensor(ns_sensorEventQueue, m_sensor);
            m_sensor = NULL;
        }
    }
Exemplo n.º 22
0
std::string ExternCompiler::readResult(StructuredLogEntry* log) const {
  const auto line = readline(m_out);
  const auto header = folly::parseJson(line);
  const std::string type = header.getDefault("type", "").asString();
  const std::size_t bytes = header.getDefault("bytes", 0).asInt();

  const auto logResult = [&] (auto name, auto t) {
    if (log != nullptr) log->setInt(name, t);
    FTRACE(2, "{} took {} us\n", name, t);
  };

  if (RuntimeOption::EvalLogExternCompilerPerf) {
    if (auto parsing_time = header.get_ptr("parsing_time")) {
      logResult("extern_parsing", parsing_time->asInt());
    }
    if (auto codegen_time = header.get_ptr("codegen_time")) {
      logResult("extern_codegen", codegen_time->asInt());
    }
    if (auto printing_time = header.get_ptr("printing_time")) {
      logResult("extern_printing", printing_time->asInt());
    }
  }

  if (type == "success") {
    std::string program(bytes, '\0');
    if (bytes != 0 && fread(&program[0], bytes, 1, m_out) != 1) {
      throwErrno("reading input program");
    }
    return program;
  } else if (type == "error") {
    // We don't need to restart the pipe -- the compiler just wasn't able to
    // build this file...
    throw CompilerFatal(
      header.getDefault("error", "[no 'error' field]").asString());
  } else {
    throw CompilerFatal("unknown message type, " + type);
  }

  not_reached();
}
Exemplo n.º 23
0
Format& FormatRegistry::getOrDefault(const std::string& name)
{
    {
        std::lock_guard<std::mutex> guard(_mutex);
        for (unsigned int i = 0; i < _formats.size(); i++) {
            if (_formats[i].name == name) {
                return _formats[i];
            }
        }
    }

    return getDefault();
}
Exemplo n.º 24
0
bool ParameterRuleset::matchArguments(list<TokenList*>* arguments) {
  list<string> parameters = getKeywords();
  list<TokenList*>::iterator ait  = arguments->begin();
  list<string>::iterator pit = parameters.begin();

  for(; pit != parameters.end(); pit++) {
    if (ait != arguments->end()) 
      ait++;
    else if (getDefault(*pit) == NULL) 
      return false;
  }
  return (ait == arguments->end() || unlimitedArguments);
}
Exemplo n.º 25
0
std::string ExternCompiler::readProgram() const {
  const auto line = readline(m_out);
  const auto header = folly::parseJson(line);
  const std::string type = header.getDefault("type", "").asString();
  const std::size_t bytes = header.getDefault("bytes", 0).asInt();

  if (type == "hhas") {
    std::string program(bytes, '\0');
    if (fread(&program[0], bytes, 1, m_out) != 1) {
      throwErrno("reading input program");
    }
    return program;
  } else if (type == "error") {
    // We don't need to restart the pipe -- the compiler just wasn't able to
    // build this file...
    throw std::runtime_error(
      header.getDefault("error", "[no 'error' field]").asString());
  } else {
    throw std::runtime_error("unknown message type, " + type);
  }

  not_reached();
}
Exemplo n.º 26
0
int main(int argc, char* argv[])
try {
    const auto prm    = example::initParam(argc, argv);
    const auto cellID = prm.getDefault("cell", 0);

    const auto rset  = example::identifyResultSet(prm);
    const auto init  = Opm::ECLInitFileData(rset.initFile());
    const auto graph = Opm::ECLGraph::load(rset.gridFile(), init);

    auto pvtCC = Opm::ECLPVT::ECLPvtCurveCollection(graph, init);
    if (prm.has("unit")) {
        pvtCC.setOutputUnits(makeUnits(prm.get<std::string>("unit"), init));
    }

    const auto x = CellState{ graph, rset, cellID };

    auto props = std::vector<Property>{};

    for (const auto& prop : enumerateProperties()) {
        if (prm.getDefault(prop.first, false)) {
            props.push_back(Property{ prop.first, (*prop.second)(pvtCC, x) });
        }
    }

    if (! props.empty()) {
        std::cout.precision(16);
        std::cout.setf(std::ios_base::scientific);

        writeResults(x, props);
    }
}
catch (const std::exception& e) {
    std::cerr << "Caught Exception: " << e.what() << '\n';

    return EXIT_FAILURE;
}
Exemplo n.º 27
0
bool ParameterRuleset::putArguments(ValueProcessor* valueProcessor,
                                    list<TokenList*>* arguments) {
  list<string> parameters = getKeywords();
  list<TokenList*>::iterator ait  = arguments->begin();
  list<string>::iterator pit = parameters.begin();
  TokenList* argsCombined = new TokenList();
  TokenList* restVar = NULL;
  TokenList* variable;

  if (unlimitedArguments && rest != "")
    restVar = new TokenList();
  
  // combine with parameter names and add to local scope
  for(; pit != parameters.end(); pit++) {
    if (ait != arguments->end()) {
      valueProcessor->putVariable(*pit, *ait);
      argsCombined->push((*ait)->clone());
      ait++;
    } else {
      variable = getDefault(*pit);
      if (variable == NULL) {
        delete argsCombined;
        return false;
      }
      valueProcessor->putVariable(*pit, variable->clone());
      argsCombined->push(variable->clone());
    }
    argsCombined->push(new Token(" ", Token::WHITESPACE));
  }
  
  if (argsCombined->size() > 0)
    delete argsCombined->pop();

  if (restVar != NULL) {
    while (ait != arguments->end()) {
      restVar->push(*ait);
      restVar->push(new Token(" ", Token::WHITESPACE));
      ait++;
    }
    if (restVar->size() > 0)
      delete restVar->pop();
    valueProcessor->putVariable(rest, restVar);
  }
  
  valueProcessor->putVariable("@arguments", argsCombined);
  return true;
}
Exemplo n.º 28
0
void SettingRegistry::_loadSettingValues(SettingConfig* config, const rapidjson::GenericValue< rapidjson::UTF8< char > >::ConstMemberIterator& json_object_it, SettingsBase* settings_base)
{
    const rapidjson::Value& data = json_object_it->value;
    /// Fill the setting config object with data we have in the json file.
    if (data.HasMember("type") && data["type"].IsString())
    {
        config->setType(data["type"].GetString());
    }

    config->setDefault(getDefault(json_object_it));

    if (data.HasMember("unit") && data["unit"].IsString())
    {
        config->setUnit(data["unit"].GetString());
    }

    settings_base->_setSetting(config->getKey(), config->getDefaultValue());
}
std::string sinalization_modes::SinalizationModes::toString(sinalization_modes::SinalizationModeEnum mode)
{
	std::string mode_name;
	switch (mode)
	{
		case BLINK:
			mode_name = "BLINK";
			break;
		case ALTERNATE:
			mode_name = "ALTERNATE";
			break;
		case LIGHT:
			mode_name = "LIGHT";
			break;
		default:
			mode_name = toString(getDefault());
	}
	return mode_name;
}
int sinalization_modes::SinalizationModes::toCode(sinalization_modes::SinalizationModeEnum mode)
{
	int mode_code;
	switch (mode)
	{
		case BLINK:
			mode_code = 0;
			break;
		case ALTERNATE:
			mode_code = 1;
			break;
		case LIGHT:
			mode_code = 2;
			break;
		default:			
			mode_code = toCode(getDefault());
	}
	return mode_code;
}